Skip to content

Commit 3e80ab8

Browse files
authored
ConditionalFormatOptions refactor to use ColorPickerInput (#1905)
### version 7.3.2 *Released*: 15 December 2025 - ConditionalFormatOptions refactor to use ColorPickerInput
1 parent 3cc0954 commit 3e80ab8

7 files changed

Lines changed: 36 additions & 148 deletions

File tree

packages/components/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@labkey/components",
3-
"version": "7.3.1",
3+
"version": "7.3.2",
44
"description": "Components, models, actions, and utility functions for LabKey applications and pages",
55
"sideEffects": false,
66
"files": [

packages/components/releaseNotes/components.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
# @labkey/components
22
Components, models, actions, and utility functions for LabKey applications and pages
33

4+
### version 7.3.2
5+
*Released*: 15 December 2025
6+
- ConditionalFormatOptions refactor to use ColorPickerInput
7+
48
### version 7.3.1
59
*Released*: 13 December 2025
610
- Remove LSID column from provisioned sample tables
711
- Update `getUpdatedData()` utility method to only check for primary keys actually used in data iteration.
12+
- Fix for LKS sample type designer issue with isValid check when metricUnit is not required
813

914
### version 7.3.0
1015
*Released*: 10 December 2025

packages/components/src/internal/components/domainproperties/validation/ConditionalFormatOptions.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ describe('ConditionalFormatOptions', () => {
6262
);
6363
expect(strike.item(0).getAttribute('checked')).toBeNull();
6464

65-
const colorPreviews = document.querySelectorAll('.domain-color-preview');
65+
const colorPreviews = document.querySelectorAll('.color-picker__chip');
6666
expect(colorPreviews.length).toEqual(2);
6767
expect(colorPreviews.item(0).getAttribute('style')).toEqual('background-color: rgb(255, 99, 71);');
6868
expect(colorPreviews.item(1).getAttribute('style')).toEqual('background-color: rgb(0, 0, 128);');

packages/components/src/internal/components/domainproperties/validation/ConditionalFormatOptions.tsx

Lines changed: 26 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import classNames from 'classnames';
21
import React, { PureComponent, ReactNode } from 'react';
3-
import { CompactPicker } from 'react-color';
42

53
import { DomainDesignerCheckbox } from '../DomainDesignerCheckbox';
64

@@ -22,6 +20,7 @@ import { LabelHelpTip } from '../../base/LabelHelpTip';
2220

2321
import { Filters } from './Filters';
2422
import { ValidatorModal } from './ValidatorModal';
23+
import { ColorPickerInput } from '../../forms/input/ColorPickerInput';
2524

2625
interface ConditionalFormatOptionsProps {
2726
dataType: PropDescType;
@@ -36,21 +35,7 @@ interface ConditionalFormatOptionsProps {
3635
validatorIndex: number;
3736
}
3837

39-
interface ConditionalFormatState {
40-
showFillColor: boolean;
41-
showTextColor: boolean;
42-
}
43-
44-
export class ConditionalFormatOptions extends PureComponent<ConditionalFormatOptionsProps, ConditionalFormatState> {
45-
constructor(props) {
46-
super(props);
47-
48-
this.state = {
49-
showTextColor: false,
50-
showFillColor: false,
51-
};
52-
}
53-
38+
export class ConditionalFormatOptions extends PureComponent<ConditionalFormatOptionsProps> {
5439
static isValid = (validator: PropertyValidator): boolean => {
5540
return Filters.isValid(validator.get('formatFilter'), DOMAIN_CONDITIONAL_FORMAT_PREFIX);
5641
};
@@ -91,7 +76,7 @@ export class ConditionalFormatOptions extends PureComponent<ConditionalFormatOpt
9176

9277
firstFilterTooltip = (): ReactNode => {
9378
return (
94-
<LabelHelpTip title="First Condition" required>
79+
<LabelHelpTip required title="First Condition">
9580
Add a condition to this format rule that will be tested against the value for this field.
9681
</LabelHelpTip>
9782
);
@@ -104,9 +89,9 @@ export class ConditionalFormatOptions extends PureComponent<ConditionalFormatOpt
10489
<div className="row">
10590
<div className="col-xs-12 domain-validation-display-checkbox-row">
10691
<DomainDesignerCheckbox
92+
checked={value}
10793
id={createFormInputId(name, domainIndex, validatorIndex)}
10894
name={createFormInputName(name)}
109-
checked={value}
11095
onChange={this.onFieldChange}
11196
>
11297
{label}
@@ -116,68 +101,40 @@ export class ConditionalFormatOptions extends PureComponent<ConditionalFormatOpt
116101
);
117102
};
118103

119-
onColorShow = (evt): void => {
120-
const { showTextColor, showFillColor } = this.state;
121-
let name = getNameFromId(evt.target.id);
122-
123-
// If click on caret icon
124-
if (!name) {
125-
name = getNameFromId(evt.target.parentElement.parentElement.id);
126-
}
127-
128-
// Strange little border between icon and button
129-
if (!name) {
130-
name = getNameFromId(evt.target.parentElement.id);
131-
}
132-
133-
if (name === DOMAIN_CONDITION_FORMAT_TEXT_COLOR) {
134-
this.setState(() => ({ showTextColor: !showTextColor, showFillColor: false }));
135-
}
136-
137-
if (name === DOMAIN_CONDITION_FORMAT_BACKGROUND_COLOR) {
138-
this.setState(() => ({ showFillColor: !showFillColor, showTextColor: false }));
139-
}
140-
};
141-
142-
onColorChange = (color): void => {
104+
onColorChange = (name: string, hexValue: string): void => {
143105
const { onChange, validator, validatorIndex } = this.props;
144-
const { showTextColor } = this.state;
145-
const name = showTextColor ? DOMAIN_CONDITION_FORMAT_TEXT_COLOR : DOMAIN_CONDITION_FORMAT_BACKGROUND_COLOR;
146-
onChange(validator.set(name, color.hex.substring(1)), validatorIndex);
106+
onChange(validator.set(name, hexValue.substring(1)), validatorIndex);
147107
};
148108

149109
renderColorPickers = (): ReactNode => {
150110
const { validator, validatorIndex } = this.props;
151-
const { showTextColor, showFillColor } = this.state;
152111

153112
const textColor = validator.textColor ? '#' + validator.textColor : 'black';
154113
const fillColor = validator.backgroundColor ? '#' + validator.backgroundColor : 'white';
155114

156115
return (
157116
<div className="row domain-validator-color-row">
158-
<div className="col-xs-4">
159-
{this.getColorPickerButton(
160-
DOMAIN_CONDITION_FORMAT_TEXT_COLOR,
161-
'Text Color',
162-
textColor,
163-
showTextColor
164-
)}
117+
<div className="col-xs-5">
118+
<ColorPickerInput
119+
name={DOMAIN_CONDITION_FORMAT_TEXT_COLOR}
120+
onChange={this.onColorChange}
121+
text="Text Color"
122+
value={textColor}
123+
/>
165124
</div>
166125
<div className="col-xs-4">
167-
{this.getColorPickerButton(
168-
DOMAIN_CONDITION_FORMAT_BACKGROUND_COLOR,
169-
'Fill Color',
170-
fillColor,
171-
showFillColor
172-
)}
126+
<ColorPickerInput
127+
name={DOMAIN_CONDITION_FORMAT_BACKGROUND_COLOR}
128+
onChange={this.onColorChange}
129+
text="Fill Color"
130+
value={fillColor}
131+
/>
173132
</div>
174-
<div className="col-xs-1" />
175133
<div className="col-xs-3">
176134
<input
177135
className="form-control"
178-
type="text"
179-
id={'domain-validator-preview-' + validatorIndex}
180136
defaultValue="Preview Text"
137+
id={'domain-validator-preview-' + validatorIndex}
181138
style={{
182139
fontSize: '12px',
183140
width: '100px',
@@ -187,47 +144,13 @@ export class ConditionalFormatOptions extends PureComponent<ConditionalFormatOpt
187144
fontStyle: validator.italic ? 'italic' : 'normal',
188145
textDecoration: validator.strikethrough ? 'line-through' : '',
189146
}}
147+
type="text"
190148
/>
191149
</div>
192150
</div>
193151
);
194152
};
195153

196-
getColorPickerButton = (name: string, label: string, color: string, showColorPicker: boolean): ReactNode => {
197-
const { validatorIndex, domainIndex } = this.props;
198-
const iconClassName = classNames('domain-color-caret', 'fa', 'fa-lg', {
199-
'fa-caret-up': showColorPicker,
200-
'fa-caret-down': !showColorPicker,
201-
});
202-
203-
return (
204-
<div style={{ width: '100%' }}>
205-
<button
206-
className="domain-color-picker-btn btn btn-default"
207-
id={createFormInputId(name, domainIndex, validatorIndex)}
208-
key={createFormInputId(name, domainIndex, validatorIndex)}
209-
name={createFormInputName(name)}
210-
onClick={this.onColorShow}
211-
type="button"
212-
>
213-
{label}
214-
<span className={iconClassName} />
215-
</button>
216-
{showColorPicker && (
217-
<div className="domain-validator-color-popover">
218-
<div
219-
className="domain-validator-color-cover"
220-
id={createFormInputId(name, domainIndex, validatorIndex)}
221-
onClick={this.onColorShow}
222-
/>
223-
<CompactPicker onChangeComplete={this.onColorChange} color={color} />
224-
</div>
225-
)}
226-
<div className="domain-color-preview" style={{ backgroundColor: color }} />
227-
</div>
228-
);
229-
};
230-
231154
render(): ReactNode {
232155
const { validatorIndex, expanded, dataType, validator, mvEnabled, domainIndex } = this.props;
233156

@@ -239,14 +162,14 @@ export class ConditionalFormatOptions extends PureComponent<ConditionalFormatOpt
239162
{expanded && (
240163
<div>
241164
<Filters
242-
validatorIndex={validatorIndex}
243165
domainIndex={domainIndex}
244-
onChange={this.onFilterChange}
245-
type={type}
246-
mvEnabled={mvEnabled}
247166
expression={validator.formatFilter}
248-
prefix={DOMAIN_CONDITIONAL_FORMAT_PREFIX}
249167
firstFilterTooltip={this.firstFilterTooltip()}
168+
mvEnabled={mvEnabled}
169+
onChange={this.onFilterChange}
170+
prefix={DOMAIN_CONDITIONAL_FORMAT_PREFIX}
171+
type={type}
172+
validatorIndex={validatorIndex}
250173
/>
251174
<div className="domain-validation-subtitle">Display Options</div>
252175
{this.renderDisplayCheckbox(DOMAIN_VALIDATOR_BOLD, 'Bold', validator.bold)}

packages/components/src/theme/domainproperties.scss

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -616,24 +616,6 @@
616616
margin-top: 20px;
617617
}
618618

619-
.domain-validator-color-popover {
620-
position: absolute;
621-
z-index: 2;
622-
}
623-
624-
.domain-validator-color-cover {
625-
position: fixed;
626-
top: 0;
627-
right: 0;
628-
bottom: 0;
629-
left: 0;
630-
}
631-
632-
.domain-validator-modal-apply {
633-
display: inline-flex;
634-
float: right;
635-
}
636-
637619
.domain-annotation-table td {
638620
vertical-align: top;
639621

@@ -648,28 +630,6 @@
648630
}
649631
}
650632

651-
.domain-color-preview {
652-
height: 25px;
653-
width: 25px;
654-
border: 1px solid;
655-
display: inline-flex;
656-
vertical-align: bottom;
657-
margin-bottom: 1px;
658-
}
659-
660-
.domain-color-picker-btn {
661-
display: inline-flex;
662-
font-size: 12px;
663-
margin-right: 20px;
664-
width: 70%;
665-
}
666-
667-
.domain-color-caret {
668-
margin-left: 40%;
669-
position: absolute;
670-
float: left;
671-
}
672-
673633
.domain-validator-collapse-icon {
674634
float: right;
675635
cursor: pointer;

packages/components/src/theme/form.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ textarea.form-control {
246246
.color-picker__chip {
247247
display: inline-block;
248248
height: 32px;
249-
margin-left: 2em;
249+
margin-left: 24px;
250250
border-radius: 4px;
251251
border: solid 1px $gray;
252252
width: 32px;

0 commit comments

Comments
 (0)