@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/theme-provider.tsx
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
useState,
|
|
14
14
|
} from "react";
|
|
15
15
|
import {Styles, stylesFromTheme, Theme, themeFromPalette} from "./design-system";
|
|
16
|
-
import {selectPalette
|
|
16
|
+
import {selectPalette} from "./palette-generator";
|
|
17
17
|
import {
|
|
18
18
|
subscribeOnThemeMenuPreferenceChange,
|
|
19
19
|
subscribeOnThemeModeChange,
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
useWarmPreference,
|
|
25
25
|
} from "./theme-settings";
|
|
26
26
|
import {css} from "@linaria/core";
|
|
27
|
+
import type {ThemePalette} from "./design-system/types";
|
|
27
28
|
|
|
28
29
|
const ThemePreferenceContext = createContext<ThemePreference | null>(null);
|
|
29
30
|
|
|
@@ -182,6 +183,7 @@ export function RootThemeProvider({
|
|
|
182
183
|
}): JSX.Element {
|
|
183
184
|
const [mode, setMode] = useState<ThemeMode>(initialThemeMode);
|
|
184
185
|
useEffect(() => subscribeOnThemeModeChange(setMode), []);
|
|
186
|
+
const dark = mode === "dark";
|
|
185
187
|
|
|
186
188
|
const [warm] = useWarmPreference();
|
|
187
189
|
useEffect(() => chooseGlobalStyles(mode, warm), [mode, warm]);
|
|
@@ -199,8 +201,12 @@ export function RootThemeProvider({
|
|
|
199
201
|
themes: [lightThemeColors, darkThemeColors],
|
|
200
202
|
styles: [lightThemeStyles, darkThemeStyles],
|
|
201
203
|
} = locateThemeBundle(warm);
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
+
const cssThemeColors = dark ? darkThemeColors : lightThemeColors;
|
|
205
|
+
let cssThemeStyles = dark ? darkThemeStyles : lightThemeStyles;
|
|
206
|
+
if (process.env.NODE_ENV === "development") {
|
|
207
|
+
// In dev build, we use empty styles as a reference to force all vars inline in top themeproviders — avoids stale Linaria/babel cache.
|
|
208
|
+
cssThemeStyles = {};
|
|
209
|
+
}
|
|
204
210
|
res = <ThemeStylesContext.Provider value={cssThemeStyles}>{res}</ThemeStylesContext.Provider>;
|
|
205
211
|
res = <RootThemeStylesContext.Provider value={cssThemeStyles}>{res}</RootThemeStylesContext.Provider>;
|
|
206
212
|
res = <ThemeContext.Provider value={cssThemeColors}>{res}</ThemeContext.Provider>;
|
package/src/theme-styles.ts
CHANGED
|
@@ -5,7 +5,8 @@ import {neutralUserPalette} from "./palettes/neutral-user";
|
|
|
5
5
|
import {ThemeMode} from "./theme-settings";
|
|
6
6
|
import {defsFromPalette} from "./design-system/colors";
|
|
7
7
|
import {themeFromDefs} from "./design-system/theme";
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
import type {ThemePalette} from "./design-system/types";
|
|
9
10
|
|
|
10
11
|
type Pair<T> = readonly [light: T, dark: T];
|
|
11
12
|
|
package/src/link-input/index.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import {css} from "@linaria/core";
|
|
2
|
-
import {useCallback} from "react";
|
|
3
|
-
import {AntTextAreaWithCustomReadState} from "./components/AntTextAreaWithCustomReadState";
|
|
4
|
-
import {getURL} from "./utils";
|
|
5
|
-
|
|
6
|
-
const urlLinkClassname = css`
|
|
7
|
-
word-break: break-word;
|
|
8
|
-
margin-right: 20px;
|
|
9
|
-
`;
|
|
10
|
-
|
|
11
|
-
export const UrlInputLink = ({value, children, ...rest}) => {
|
|
12
|
-
const normalizedUrl = getURL(value);
|
|
13
|
-
if (!normalizedUrl) {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
return (
|
|
17
|
-
<a
|
|
18
|
-
draggable={false}
|
|
19
|
-
target="_blank"
|
|
20
|
-
className={urlLinkClassname}
|
|
21
|
-
rel="noopener noreferrer nofollow"
|
|
22
|
-
href={normalizedUrl}
|
|
23
|
-
{...rest}
|
|
24
|
-
>
|
|
25
|
-
{children}
|
|
26
|
-
</a>
|
|
27
|
-
);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export const UrlInput = (props) => {
|
|
31
|
-
const handleClick = useCallback((e) => e.stopPropagation(), []);
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<AntTextAreaWithCustomReadState
|
|
35
|
-
{...props}
|
|
36
|
-
renderReadState={() => (
|
|
37
|
-
<UrlInputLink value={props.value} onClick={handleClick}>
|
|
38
|
-
{props.value}
|
|
39
|
-
</UrlInputLink>
|
|
40
|
-
)}
|
|
41
|
-
/>
|
|
42
|
-
);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const PhoneInputLink = ({value, children, ...rest}) => {
|
|
46
|
-
return (
|
|
47
|
-
<a draggable={false} href={`tel:${value}`} {...rest}>
|
|
48
|
-
{children}
|
|
49
|
-
</a>
|
|
50
|
-
);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export const PhoneInput = (props) => {
|
|
54
|
-
const handleClick = useCallback((e) => e.stopPropagation(), []);
|
|
55
|
-
|
|
56
|
-
return (
|
|
57
|
-
<AntTextAreaWithCustomReadState
|
|
58
|
-
{...props}
|
|
59
|
-
renderReadState={() => (
|
|
60
|
-
<PhoneInputLink value={props.value} onClick={handleClick}>
|
|
61
|
-
{props.value}
|
|
62
|
-
</PhoneInputLink>
|
|
63
|
-
)}
|
|
64
|
-
/>
|
|
65
|
-
);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export const EmailInputLink = ({value, children, ...rest}) => {
|
|
69
|
-
return (
|
|
70
|
-
<a draggable={false} href={`mailto:${value}`} {...rest}>
|
|
71
|
-
{children}
|
|
72
|
-
</a>
|
|
73
|
-
);
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export const EmailInput = (props) => {
|
|
77
|
-
const handleClick = useCallback((e) => e.stopPropagation(), []);
|
|
78
|
-
|
|
79
|
-
return (
|
|
80
|
-
<AntTextAreaWithCustomReadState
|
|
81
|
-
{...props}
|
|
82
|
-
renderReadState={() => (
|
|
83
|
-
<EmailInputLink value={props.value} onClick={handleClick}>
|
|
84
|
-
{props.value}
|
|
85
|
-
</EmailInputLink>
|
|
86
|
-
)}
|
|
87
|
-
/>
|
|
88
|
-
);
|
|
89
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import flow from "lodash/flow";
|
|
2
|
-
import isNil from "lodash/isNil";
|
|
3
|
-
import trimEnd from "lodash/trimEnd";
|
|
4
|
-
|
|
5
|
-
const isEmpty = (value) => isNil(value) || value === "";
|
|
6
|
-
|
|
7
|
-
const getPrecision = (value) => {
|
|
8
|
-
if (isEmpty(value)) {
|
|
9
|
-
return 0;
|
|
10
|
-
}
|
|
11
|
-
const [, decimalPart = ""] = String(value).split(".");
|
|
12
|
-
return decimalPart.length;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const removeTrailingZeros = (value) => {
|
|
16
|
-
if (isEmpty(value)) {
|
|
17
|
-
return value;
|
|
18
|
-
}
|
|
19
|
-
const hasDecimalPart = value.indexOf(".") > 0;
|
|
20
|
-
return hasDecimalPart ? trimEnd(trimEnd(value, "0"), ".") : value;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const add = flow([
|
|
24
|
-
(first, second) => {
|
|
25
|
-
const result = Number(first) + Number(second);
|
|
26
|
-
const maxPrecision = Math.max(getPrecision(first), getPrecision(second));
|
|
27
|
-
return result.toFixed(maxPrecision);
|
|
28
|
-
},
|
|
29
|
-
removeTrailingZeros,
|
|
30
|
-
]);
|
|
31
|
-
|
|
32
|
-
export const sub = flow([
|
|
33
|
-
(first, second) => {
|
|
34
|
-
return add(first, -second);
|
|
35
|
-
},
|
|
36
|
-
removeTrailingZeros,
|
|
37
|
-
]);
|
|
38
|
-
|
|
39
|
-
export const multiplyByHundred = flow([
|
|
40
|
-
(value) => {
|
|
41
|
-
if (isEmpty(value)) {
|
|
42
|
-
return value;
|
|
43
|
-
}
|
|
44
|
-
const result = value * 100;
|
|
45
|
-
const precision = Math.max(0, getPrecision(value) - 2);
|
|
46
|
-
return result.toFixed(precision);
|
|
47
|
-
},
|
|
48
|
-
removeTrailingZeros,
|
|
49
|
-
]);
|
|
50
|
-
|
|
51
|
-
export const divideByHundred = flow([
|
|
52
|
-
(value) => {
|
|
53
|
-
if (isEmpty(value)) {
|
|
54
|
-
return value;
|
|
55
|
-
}
|
|
56
|
-
const result = value / 100;
|
|
57
|
-
const precision = getPrecision(value) + 2;
|
|
58
|
-
return result.toFixed(precision);
|
|
59
|
-
},
|
|
60
|
-
removeTrailingZeros,
|
|
61
|
-
]);
|