Skip to content

Commit aa9454b

Browse files
committed
align property names with color hash helper functions
1 parent 8a6a1ac commit aa9454b

2 files changed

Lines changed: 19 additions & 19 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
1515
- component for hiding elements in specific media
1616
- `<InlineText />`
1717
- force children to get displayed as inline content
18-
- `<DecoupledOverlay />`
19-
- similar to `ContextOverlay` component but not directly linked to a React element, it specifies the target in the DOM to get connected lazy
18+
- `<DecoupledOverlay />`
19+
- similar to `ContextOverlay` component but not directly linked to a React element, it specifies the target in the DOM to get connected lazy
2020
- `<StringPreviewContentBlobToggler />`
2121
- `useOnly` property: specify if only parts of the content should be used for the shortened preview, this property replaces `firstNonEmptyLineOnly`
2222
- `<ContextOverlay />`
2323
- `paddingSize` property to add easily some white space
2424
- `<RadioButton />`
2525
- `hideIndicator` property: hide the radio inout indicator but click on children can be processed via `onChange` event
2626
- `<ColorField />`
27-
- input component for colors, uses the configured palette by default but it also allows to enter custom colors
27+
- input component for colors, uses the configured palette by default, but it also allows to enter custom colors
2828
- CSS custom properties
2929
- beside the color palette we now mirror the most important layout configuration variables as CSS custom properties
3030
- new icons:

src/components/ColorField/ColorField.tsx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@ export interface ColorFieldProps extends Omit<TextFieldProps, "invisibleCharacte
2121
/**
2222
* What color weights should be included in the set of allowed colors.
2323
*/
24-
colorWeightFilter?: ColorWeight[];
24+
includeColorWeight?: ColorWeight[];
2525
/**
2626
* What palette groups should be included in the set of allowed colors.
2727
*/
28-
paletteGroupFilter?: PaletteGroup[];
28+
includePaletteGroup?: PaletteGroup[];
2929
}
3030

3131
/**
3232
* Color input field that provides resets from the configured color palette.
33-
* Use `colorWeightFilter` and `paletteGroupFilter` to filter them.
33+
* Use `includeColorWeight` and `includePaletteGroup` to filter them.
3434
*/
3535
export const ColorField = ({
3636
className = "",
3737
allowCustomColor = false,
38-
colorWeightFilter = [100, 300, 700, 900],
39-
paletteGroupFilter = ["layout"],
38+
includeColorWeight = [100, 300, 700, 900], // on default, we only include color weights that can have enough contrasts to black/white
39+
includePaletteGroup = ["layout"],
4040
defaultValue,
4141
value,
4242
onChange,
@@ -49,19 +49,19 @@ export const ColorField = ({
4949
let allowedPaletteColors, disableNativePicker, disabled;
5050
const updateConfig = () => {
5151
allowedPaletteColors = utils.getEnabledColorPropertiesFromPalette({
52-
includePaletteGroup: paletteGroupFilter,
53-
includeColorWeight: colorWeightFilter,
52+
includePaletteGroup: includePaletteGroup,
53+
includeColorWeight: includeColorWeight,
5454
minimalColorDistance: 0, // we use all allowed colors, and do not check distances between them
5555
});
5656

5757
disableNativePicker =
58-
colorWeightFilter.length > 0 && paletteGroupFilter.length > 0 && allowedPaletteColors.length > 0;
58+
includeColorWeight.length > 0 && includePaletteGroup.length > 0 && allowedPaletteColors.length > 0;
5959
disabled = (!disableNativePicker && !allowCustomColor) || otherTextFieldProps.disabled;
6060
};
6161
updateConfig();
6262
React.useEffect(() => {
6363
updateConfig();
64-
}, [allowCustomColor, colorWeightFilter, paletteGroupFilter, otherTextFieldProps]);
64+
}, [allowCustomColor, includeColorWeight, includePaletteGroup, otherTextFieldProps]);
6565

6666
React.useEffect(() => {
6767
setColorValue(defaultValue || value || "#000000");
@@ -124,7 +124,7 @@ export const ColorField = ({
124124
<FieldSet>
125125
<TagList
126126
className={`${eccgui}-colorfield__palette ${eccgui}-colorfield__palette--${
127-
colorWeightFilter.length >= 3 ? colorWeightFilter.length * 2 : "8"
127+
includeColorWeight.length >= 3 ? includeColorWeight.length * 2 : "8"
128128
}col`}
129129
>
130130
{allowedPaletteColors!.map((color: [string, string], idx: number) => [
@@ -146,7 +146,7 @@ export const ColorField = ({
146146
</Tooltip>
147147
</RadioButton>,
148148
// Looks like we cannot force some type of line break in the tag list via CSS only
149-
(idx + 1) % (colorWeightFilter.length >= 3 ? colorWeightFilter.length * 2 : 8) ===
149+
(idx + 1) % (includeColorWeight.length >= 3 ? includeColorWeight.length * 2 : 8) ===
150150
0 && (
151151
<>
152152
<br className={`${eccgui}-colorfield__palette-linebreak`} />
@@ -167,7 +167,7 @@ export const ColorField = ({
167167

168168
type calculateColorHashValueProps = Pick<
169169
ColorFieldProps,
170-
"allowCustomColor" | "colorWeightFilter" | "paletteGroupFilter"
170+
"allowCustomColor" | "includeColorWeight" | "includePaletteGroup"
171171
>;
172172

173173
/**
@@ -178,17 +178,17 @@ ColorField.calculateColorHashValue = (
178178
text: string,
179179
options: calculateColorHashValueProps = {
180180
allowCustomColor: false,
181-
colorWeightFilter: [100, 300, 700, 900],
182-
paletteGroupFilter: ["layout"],
181+
includeColorWeight: [100, 300, 700, 900],
182+
includePaletteGroup: ["layout"],
183183
}
184184
) => {
185185
const hash = utils.textToColorHash({
186186
text,
187187
options: {
188188
returnValidColorsDirectly: options.allowCustomColor as boolean,
189189
enabledColors: utils.getEnabledColorsFromPalette({
190-
includePaletteGroup: options.paletteGroupFilter,
191-
includeColorWeight: options.colorWeightFilter,
190+
includePaletteGroup: options.includePaletteGroup,
191+
includeColorWeight: options.includeColorWeight,
192192
minimalColorDistance: 0,
193193
}),
194194
},

0 commit comments

Comments
 (0)