@fibery/ui-kit 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/package.json +6 -3
- package/src/@types/react-color.d.ts +36 -0
- package/src/antd/{Tabs.js → Tabs.tsx} +5 -2
- package/src/color-filter.test.ts +24 -65
- package/src/color-filter.ts +62 -93
- package/src/color-picker/{ColorPickerOrLoader.js → ColorPickerOrLoader.tsx} +1 -1
- package/src/color-picker/{index.js → index.tsx} +32 -6
- package/src/color-utils.ts +3 -9
- package/src/design-system/colors-css.ts +16 -0
- package/src/design-system/colors.ts +23 -45
- package/src/design-system/def.ts +17 -0
- package/src/design-system/theme.ts +6 -2
- package/src/design-system/types.ts +102 -0
- package/src/design-system/vars.test.ts +9 -2
- package/src/design-system/vars.ts +4 -2
- package/src/design-system.ts +9 -1
- package/src/emoji-picker/emoji-picker-content-with-color.tsx +3 -3
- package/src/heat.ts +8 -0
- package/src/highlight-colors.test.ts +68 -0
- package/src/highlight-colors.ts +91 -0
- package/src/link-input/components/{AntTextAreaWithCustomReadState.js → AntTextAreaWithCustomReadState.tsx} +19 -8
- package/src/link-input/index.tsx +94 -0
- package/src/link-input/{utils.js → utils.ts} +1 -6
- package/src/number-input/decimal.ts +50 -0
- package/src/number-input/utils.ts +2 -2
- package/src/palette-generator.test.ts +2 -1
- package/src/palette-generator.ts +8 -26
- package/src/palettes/_.ts +2 -2
- package/src/palettes/common.ts +31 -0
- package/src/palettes/diff-colors.ts +29 -12
- package/src/palettes/inspect.defs.colors.neutral-arch.test.ts +72 -36
- package/src/palettes/inspect.defs.colors.neutral-user.test.ts +72 -36
- package/src/palettes/inspect.defs.colors.warm-arch.test.ts +226 -190
- package/src/palettes/inspect.defs.colors.warm-user.test.ts +226 -190
- package/src/palettes/neutral-arch.ts +3 -3
- package/src/palettes/neutral-user.ts +3 -3
- package/src/palettes/neutral.ts +4 -2
- package/src/palettes/warm-arch.ts +3 -3
- package/src/palettes/warm-user.ts +3 -3
- package/src/palettes/warm.ts +4 -3
- package/src/pretty-size.ts +5 -2
- package/src/root-theme-provider.test.tsx +1 -1
- package/src/scale-generator.ts +1 -32
- package/src/select/components/menu-list-virtua.tsx +127 -0
- package/src/select/index.tsx +1 -1
- package/src/select/reflection.ts +22 -0
- package/src/select/select.tsx +1 -0
- package/src/static-palettes.ts +2 -1
- package/src/thematic-color-picker.tsx +8 -1
- package/src/thematic-constants.tsx +2 -0
- package/src/thematic-controls.tsx +9 -1
- package/src/thematic-cvd.tsx +73 -0
- package/src/thematic-highlights.tsx +49 -0
- package/src/thematic-scales.tsx +8 -6
- package/src/thematic-state.ts +37 -16
- package/src/thematic.tsx +298 -305
- package/src/theme-provider.tsx +9 -3
- package/src/theme-styles.ts +2 -1
- package/src/link-input/index.js +0 -89
- package/src/number-input/decimal.js +0 -61
package/src/thematic-state.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import {useCallback, useEffect, useMemo, useState} from "react";
|
|
2
2
|
import {useThematic, useThemeMode} from "./theme-provider";
|
|
3
3
|
import {
|
|
4
|
-
type ColorScale,
|
|
5
4
|
DEFAULT_DARK_CURVES,
|
|
6
5
|
DEFAULT_LIGHT_CURVES,
|
|
7
6
|
generateColorScale,
|
|
8
7
|
makeThematicPalette,
|
|
9
8
|
type ScaleCurves,
|
|
10
9
|
type ThematicPrefs,
|
|
11
|
-
type ThemePalette,
|
|
12
10
|
} from "./palette-generator";
|
|
13
11
|
import {getThemePreference, setThemePreference, type ThemePreference} from "./theme-settings";
|
|
14
12
|
import {type ColorFilterSpec} from "./color-filter";
|
|
@@ -16,8 +14,12 @@ import {oklchFrom} from "./color-utils";
|
|
|
16
14
|
import {StaticPalettes} from "./static-palettes";
|
|
17
15
|
import {defaultPrefs, nextThemePref} from "./thematic-constants";
|
|
18
16
|
import {useToast} from "./toast/toast-provider";
|
|
17
|
+
import type {HighlightDefs, ModeDef, ThemePalette} from "./design-system/types";
|
|
18
|
+
import {common} from "./palettes/common";
|
|
19
19
|
|
|
20
|
-
type PaletteScaleKey = Exclude<keyof ThemePalette, "key" | "deneutralize">;
|
|
20
|
+
export type PaletteScaleKey = Exclude<keyof ThemePalette, "key" | "deneutralize" | "highlight">;
|
|
21
|
+
|
|
22
|
+
const highlight = common.highlight;
|
|
21
23
|
|
|
22
24
|
interface StoredState {
|
|
23
25
|
prefs: ThematicPrefs | null;
|
|
@@ -177,9 +179,11 @@ export function useThematicState() {
|
|
|
177
179
|
}
|
|
178
180
|
if (customPalette) {
|
|
179
181
|
const customKey = Object.entries(customPalette)
|
|
180
|
-
.map(([k, v]) => `${k}:${
|
|
182
|
+
.map(([k, v]) => `${k}:${JSON.stringify(v)}`)
|
|
181
183
|
.join("|");
|
|
182
|
-
|
|
184
|
+
const idx = result.key.indexOf("-custom-");
|
|
185
|
+
const stableKey = idx >= 0 ? result.key.slice(0, idx) : result.key;
|
|
186
|
+
result = {...result, key: `${stableKey}-custom-${customKey}`};
|
|
183
187
|
}
|
|
184
188
|
return result;
|
|
185
189
|
}, [
|
|
@@ -219,14 +223,30 @@ export function useThematicState() {
|
|
|
219
223
|
};
|
|
220
224
|
|
|
221
225
|
const updateFilter = (partial: Partial<ColorFilterSpec>) => {
|
|
226
|
+
const sideIdx = editingDark ? 1 : 0;
|
|
222
227
|
if (prefs) {
|
|
223
|
-
const current = prefsPresent.filter ?? {};
|
|
228
|
+
const current = prefsPresent.filter ?? [{}, {}];
|
|
229
|
+
const updated: ModeDef<Partial<ColorFilterSpec>> = [...current];
|
|
230
|
+
updated[sideIdx] = {...updated[sideIdx], ...partial};
|
|
224
231
|
setPrefs({
|
|
225
232
|
...prefsPresent,
|
|
226
|
-
filter:
|
|
233
|
+
filter: updated,
|
|
234
|
+
});
|
|
235
|
+
} else {
|
|
236
|
+
setCustomPalette((prev) => {
|
|
237
|
+
const current = palette.deneutralize ?? [{}, {}];
|
|
238
|
+
const updated: ModeDef<ColorFilterSpec> = [...current];
|
|
239
|
+
updated[sideIdx] = {...updated[sideIdx], ...partial};
|
|
240
|
+
return {...prev, deneutralize: updated};
|
|
227
241
|
});
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
const updateHighlight = (highlight: HighlightDefs) => {
|
|
246
|
+
if (prefs) {
|
|
247
|
+
setPrefs({...prefsPresent, highlight});
|
|
228
248
|
} else {
|
|
229
|
-
setCustomPalette((prev) => ({...prev,
|
|
249
|
+
setCustomPalette((prev) => ({...prev, highlight}));
|
|
230
250
|
}
|
|
231
251
|
};
|
|
232
252
|
|
|
@@ -237,6 +257,7 @@ export function useThematicState() {
|
|
|
237
257
|
baseChroma: Math.random() * 0.1,
|
|
238
258
|
accentHue: Math.random() * 360,
|
|
239
259
|
accentChroma: 0.08 + Math.random() * 0.12,
|
|
260
|
+
highlight,
|
|
240
261
|
});
|
|
241
262
|
};
|
|
242
263
|
|
|
@@ -268,15 +289,10 @@ export function useThematicState() {
|
|
|
268
289
|
};
|
|
269
290
|
|
|
270
291
|
const updateScaleColor = useCallback(
|
|
271
|
-
(
|
|
292
|
+
(key: PaletteScaleKey, index: number, color: string) => {
|
|
272
293
|
setCustomPalette((prev) => {
|
|
273
|
-
const
|
|
274
|
-
|
|
275
|
-
return {...prev, [scaleName]: color};
|
|
276
|
-
}
|
|
277
|
-
const mutableScale = [...currentValue] as unknown as string[];
|
|
278
|
-
mutableScale[index] = color;
|
|
279
|
-
return {...prev, [scaleName]: mutableScale as unknown as ColorScale};
|
|
294
|
+
const colorOrScale = prev?.[key] ?? palette[key];
|
|
295
|
+
return {...prev, [key]: typeof colorOrScale === "string" ? color : colorOrScale.with(index, color)};
|
|
280
296
|
});
|
|
281
297
|
},
|
|
282
298
|
[palette]
|
|
@@ -297,6 +313,8 @@ export function useThematicState() {
|
|
|
297
313
|
}, [prefs, staticPaletteIndex, customPalette]);
|
|
298
314
|
|
|
299
315
|
const editingDark = !isLightMode;
|
|
316
|
+
const dnSide = editingDark ? 1 : 0;
|
|
317
|
+
const deneutralizeSpec = palette.deneutralize?.[dnSide];
|
|
300
318
|
const baseCurves = editingDark ? baseCurvesDark : baseCurvesLight;
|
|
301
319
|
const setBaseCurves = editingDark ? setBaseCurvesDark : setBaseCurvesLight;
|
|
302
320
|
const accentCurves = editingDark ? accentCurvesDark : accentCurvesLight;
|
|
@@ -352,6 +370,8 @@ export function useThematicState() {
|
|
|
352
370
|
|
|
353
371
|
return {
|
|
354
372
|
palette,
|
|
373
|
+
deneutralizeSpec,
|
|
374
|
+
dnSide,
|
|
355
375
|
hoveredInfo,
|
|
356
376
|
isAltPressed,
|
|
357
377
|
pinned,
|
|
@@ -374,6 +394,7 @@ export function useThematicState() {
|
|
|
374
394
|
update,
|
|
375
395
|
updateHueShift,
|
|
376
396
|
updateFilter,
|
|
397
|
+
updateHighlight,
|
|
377
398
|
randomize,
|
|
378
399
|
cycleStaticPalettes,
|
|
379
400
|
cycleTheme,
|