@fibery/ui-kit 1.40.3 → 1.40.4
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 +4 -7
- package/src/__snapshots__/design-system.test.ts.snap +7265 -0
- package/src/a11y-color.test.ts +181 -0
- package/src/a11y-color.ts +13 -20
- package/src/actions-menu/actions-menu-item.tsx +7 -7
- package/src/antd/ant-modal.tsx +10 -5
- package/src/antd/styles.ts +6 -6
- package/src/app-icon-with-fallback.tsx +2 -2
- package/src/app-icon.tsx +2 -2
- package/src/button/button.tsx +1 -0
- package/src/button/make-button-colors.ts +5 -13
- package/src/checkbox.tsx +2 -2
- package/src/color-picker/ColorPickerOrLoader.js +2 -2
- package/src/color-utils.test.ts +317 -0
- package/src/color-utils.ts +180 -0
- package/src/comment.tsx +3 -2
- package/src/context-menu/index.tsx +12 -7
- package/src/create-inline-theme.ts +9 -8
- package/src/design-system.colors.ts +760 -0
- package/src/design-system.test.ts +287 -7
- package/src/design-system.ts +146 -940
- package/src/dropdown-menu/index.tsx +21 -16
- package/src/emoji-picker/app-icon-picker.tsx +5 -5
- package/src/emoji-picker/emoji-picker-content-with-color.tsx +4 -4
- package/src/emoji-picker/icon-emoji-picker.tsx +2 -2
- package/src/favorites-icon.tsx +1 -1
- package/src/file-item/file-icon.tsx +169 -0
- package/src/file-item/file-menu-items.tsx +68 -0
- package/src/file-item/file-preview-actions.tsx +38 -0
- package/src/file-item/file-title.tsx +48 -0
- package/src/file-item/types.ts +27 -0
- package/src/file-item/use-register-in-image-gallery.tsx +70 -0
- package/src/file-item-2.tsx +35 -345
- package/src/file-item.tsx +6 -2
- package/src/hue-shift.test.ts +91 -0
- package/src/icons/ast/FileCounter.ts +8 -0
- package/src/icons/ast/FileMultiple.ts +8 -0
- package/src/icons/ast/ValueEdit.ts +8 -0
- package/src/icons/ast/index.tsx +3 -0
- package/src/icons/react/FileCounter.tsx +13 -0
- package/src/icons/react/FileMultiple.tsx +13 -0
- package/src/icons/react/ValueEdit.tsx +13 -0
- package/src/icons/react/index.tsx +3 -0
- package/src/icons/svg/file-counter.svg +3 -0
- package/src/icons/svg/file-multiple.svg +3 -0
- package/src/icons/svg/value-edit.svg +3 -0
- package/src/images-gallery/slide-buttons.tsx +4 -11
- package/src/lists/actions-menu-row-surface.tsx +5 -5
- package/src/mobile-keyboard-aware-popup.tsx +4 -3
- package/src/palette-generator.test.ts +566 -0
- package/src/palette-generator.ts +166 -0
- package/src/palette.ts +71 -55
- package/src/platform.ts +0 -3
- package/src/popover/index.tsx +13 -15
- package/src/progress.tsx +2 -2
- package/src/reactions/reaction-button.tsx +12 -6
- package/src/root-theme-provider.test.tsx +316 -0
- package/src/scale-generator.ts +347 -0
- package/src/select/components/menu-list-virtualized.tsx +7 -22
- package/src/select/components/menu.tsx +12 -2
- package/src/select/select.tsx +2 -1
- package/src/select/styles.ts +0 -1
- package/src/static-palettes.ts +146 -0
- package/src/thematic-color-picker.tsx +266 -0
- package/src/thematic-constants.tsx +27 -0
- package/src/thematic-controls.tsx +144 -0
- package/src/thematic-scales.tsx +122 -0
- package/src/thematic-state.ts +333 -0
- package/src/thematic.tsx +382 -0
- package/src/theme-provider.test.tsx +808 -0
- package/src/theme-provider.tsx +132 -69
- package/src/theme-settings.ts +1 -1
- package/src/theme-styles.ts +12 -5
- package/src/toast/toast-action.tsx +1 -1
- package/src/toggle-on-off.tsx +2 -2
- package/src/toggle.tsx +5 -6
- package/src/tooltip.tsx +13 -10
- package/src/type-badge.tsx +3 -3
- package/src/unit/styles.ts +2 -2
- package/src/unit/unit-with-tooltip.tsx +3 -2
- package/src/use-long-press.tsx +2 -2
package/src/theme-provider.tsx
CHANGED
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
import invariant from "invariant";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
defaultDarkTheme,
|
|
4
|
+
defaultDarkThemeStyles,
|
|
5
|
+
defaultLightTheme,
|
|
6
|
+
defaultLightThemeStyles,
|
|
7
|
+
defaultPalette,
|
|
8
|
+
themeStyles,
|
|
9
|
+
} from "./theme-styles";
|
|
3
10
|
import {layoutStyles} from "./layout-styles";
|
|
4
|
-
import {
|
|
5
|
-
|
|
11
|
+
import {
|
|
12
|
+
createContext,
|
|
13
|
+
PropsWithChildren,
|
|
14
|
+
ReactNode,
|
|
15
|
+
useContext,
|
|
16
|
+
useEffect,
|
|
17
|
+
useLayoutEffect,
|
|
18
|
+
useMemo,
|
|
19
|
+
useState,
|
|
20
|
+
} from "react";
|
|
21
|
+
import {createInlineTheme, getThemeColors, rejectNoKeys, ThemeColors} from "./design-system";
|
|
22
|
+
import {ThemePalette} from "./palette-generator";
|
|
6
23
|
import {
|
|
7
24
|
subscribeOnThemeMenuPreferenceChange,
|
|
8
25
|
subscribeOnThemeModeChange,
|
|
@@ -11,18 +28,29 @@ import {
|
|
|
11
28
|
ThemeMode,
|
|
12
29
|
ThemePreference,
|
|
13
30
|
} from "./theme-settings";
|
|
31
|
+
import {css} from "@linaria/core";
|
|
32
|
+
import {ThemeStyles} from "./create-inline-theme";
|
|
14
33
|
|
|
15
|
-
const
|
|
16
|
-
const FiberyThemeMenuPreferenceContext = createContext<ThemeMenuPreference | null>(null);
|
|
34
|
+
const ThemePreferenceContext = createContext<ThemePreference | null>(null);
|
|
17
35
|
|
|
18
|
-
|
|
36
|
+
export function useThemePreference(): ThemePreference {
|
|
37
|
+
const themePreference = useContext(ThemePreferenceContext);
|
|
38
|
+
invariant(themePreference, `please ensure the component is wrapped in a <RootThemeProvider>`);
|
|
39
|
+
return themePreference;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const ThemeMenuPreferenceContext = createContext<ThemeMenuPreference | null>(null);
|
|
19
43
|
|
|
20
|
-
function
|
|
21
|
-
|
|
44
|
+
export function useThemeMenuPreference(): ThemeMenuPreference {
|
|
45
|
+
const themeMenuPreference = useContext(ThemeMenuPreferenceContext);
|
|
46
|
+
invariant(themeMenuPreference, `please ensure the component is wrapped in a <RootThemeProvider>`);
|
|
47
|
+
return themeMenuPreference;
|
|
22
48
|
}
|
|
23
49
|
|
|
50
|
+
const ThemeColorsContext = createContext<ThemeColors>(defaultLightTheme);
|
|
51
|
+
|
|
24
52
|
export function useTheme(): ThemeColors {
|
|
25
|
-
return useContext(
|
|
53
|
+
return useContext(ThemeColorsContext);
|
|
26
54
|
}
|
|
27
55
|
|
|
28
56
|
export function useThemeMode(): ThemeMode {
|
|
@@ -30,36 +58,84 @@ export function useThemeMode(): ThemeMode {
|
|
|
30
58
|
return theme.mode;
|
|
31
59
|
}
|
|
32
60
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
invariant(
|
|
37
|
-
themePreference,
|
|
38
|
-
"could not find theme preference context value; please ensure the component is wrapped in a <FiberyThemePreferenceContext>"
|
|
39
|
-
);
|
|
61
|
+
const RootThemeStylesContext = createContext<ThemeStyles>(defaultLightThemeStyles);
|
|
62
|
+
const ThemeStylesContext = createContext<ThemeStyles>(defaultLightThemeStyles);
|
|
40
63
|
|
|
41
|
-
|
|
64
|
+
export function useThemeStyles(): ThemeStyles {
|
|
65
|
+
return useContext(ThemeStylesContext);
|
|
42
66
|
}
|
|
43
67
|
|
|
44
|
-
|
|
45
|
-
const themeMenuPreference = useContext(FiberyThemeMenuPreferenceContext);
|
|
68
|
+
const ThemePaletteContext = createContext<ThemePalette>(defaultPalette);
|
|
46
69
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
70
|
+
type ThematicContextValue = {
|
|
71
|
+
palette: ThemePalette;
|
|
72
|
+
setPalette: (palette: ThemePalette) => void;
|
|
73
|
+
};
|
|
51
74
|
|
|
52
|
-
|
|
75
|
+
const ThematicContext = createContext<ThematicContextValue>({
|
|
76
|
+
palette: defaultPalette,
|
|
77
|
+
setPalette: () => {},
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
export function useThematic(): ThematicContextValue {
|
|
81
|
+
return useContext(ThematicContext);
|
|
53
82
|
}
|
|
54
83
|
|
|
55
|
-
export function
|
|
56
|
-
|
|
57
|
-
|
|
84
|
+
export function ThemeProvider({
|
|
85
|
+
theme: themeOverride,
|
|
86
|
+
color: colorOverride,
|
|
87
|
+
mode: modeOverride,
|
|
88
|
+
portal,
|
|
89
|
+
children,
|
|
90
|
+
}: PropsWithChildren<
|
|
91
|
+
{portal?: true} & (
|
|
92
|
+
| {theme: ThemeColors; color?: never; mode?: never}
|
|
93
|
+
| {color?: string; theme?: never; mode?: ThemeMode}
|
|
94
|
+
)
|
|
95
|
+
>) {
|
|
96
|
+
const palette = useContext(ThemePaletteContext);
|
|
97
|
+
const parentTheme = useContext(ThemeColorsContext);
|
|
98
|
+
|
|
99
|
+
const mode = modeOverride ?? parentTheme.mode;
|
|
100
|
+
const color = colorOverride ?? parentTheme.primary;
|
|
101
|
+
const theme = themeOverride ?? getThemeColors(color, mode, palette);
|
|
102
|
+
|
|
103
|
+
const parentStyles = useContext(portal ? RootThemeStylesContext : ThemeStylesContext);
|
|
104
|
+
const styles = createInlineTheme(theme, rejectNoKeys);
|
|
105
|
+
const stylesDiff = useMemo(() => {
|
|
106
|
+
if (styles === parentStyles) {
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
const diff: ThemeStyles = {};
|
|
110
|
+
for (const key of Object.keys(styles)) {
|
|
111
|
+
if (styles[key] !== parentStyles[key]) {
|
|
112
|
+
diff[key] = styles[key];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return diff;
|
|
116
|
+
}, [styles, parentStyles]);
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<ThemeColorsContext.Provider value={theme}>
|
|
120
|
+
<ThemeStylesContext.Provider value={styles}>
|
|
121
|
+
<div
|
|
122
|
+
style={stylesDiff}
|
|
123
|
+
className={css`
|
|
124
|
+
display: contents;
|
|
125
|
+
`}
|
|
126
|
+
>
|
|
127
|
+
{children}
|
|
128
|
+
</div>
|
|
129
|
+
</ThemeStylesContext.Provider>
|
|
130
|
+
</ThemeColorsContext.Provider>
|
|
131
|
+
);
|
|
58
132
|
}
|
|
59
133
|
|
|
60
134
|
export function MenuThemeProvider({children}: {children: ReactNode}) {
|
|
61
|
-
const
|
|
62
|
-
|
|
135
|
+
const themeMode = useThemeMode();
|
|
136
|
+
// light2 = always dark menu
|
|
137
|
+
const mode = themeMode === "light" ? "light" : "dark";
|
|
138
|
+
return <ThemeProvider mode={mode}>{children}</ThemeProvider>;
|
|
63
139
|
}
|
|
64
140
|
|
|
65
141
|
export function RootThemeProvider({
|
|
@@ -74,19 +150,33 @@ export function RootThemeProvider({
|
|
|
74
150
|
children: ReactNode;
|
|
75
151
|
}): JSX.Element {
|
|
76
152
|
const [themeMode, setThemeMode] = useState<ThemeMode>(initialThemeMode);
|
|
153
|
+
useEffect(() => subscribeOnThemeModeChange(setThemeMode), []);
|
|
154
|
+
|
|
155
|
+
const [palette, setPalette] = useState<ThemePalette>(defaultPalette);
|
|
156
|
+
|
|
157
|
+
let res = <ThemeProvider theme={getThemeColors(null, themeMode, palette)}>{children}</ThemeProvider>;
|
|
158
|
+
|
|
159
|
+
// Set base context to what global CSS has, so ThemeProvider diffs against it
|
|
160
|
+
const cssThemeStyles = themeMode === "dark" ? defaultDarkThemeStyles : defaultLightThemeStyles;
|
|
161
|
+
res = <ThemeStylesContext.Provider value={cssThemeStyles}>{res}</ThemeStylesContext.Provider>;
|
|
162
|
+
res = <RootThemeStylesContext.Provider value={cssThemeStyles}>{res}</RootThemeStylesContext.Provider>;
|
|
163
|
+
|
|
164
|
+
const cssThemeColors = themeMode === "dark" ? defaultDarkTheme : defaultLightTheme;
|
|
165
|
+
res = <ThemeColorsContext.Provider value={cssThemeColors}>{res}</ThemeColorsContext.Provider>;
|
|
166
|
+
|
|
167
|
+
res = <ThemePaletteContext.Provider value={palette}>{res}</ThemePaletteContext.Provider>;
|
|
168
|
+
|
|
169
|
+
const thematicContextValue = useMemo<ThematicContextValue>(() => ({palette, setPalette}), [palette]);
|
|
170
|
+
res = <ThematicContext.Provider value={thematicContextValue}>{res}</ThematicContext.Provider>;
|
|
171
|
+
|
|
77
172
|
const [themePreference, setThemePreference] = useState<ThemePreference>(initialPreference);
|
|
173
|
+
useEffect(() => subscribeOnThemePreferenceChange(setThemePreference), []);
|
|
174
|
+
res = <ThemePreferenceContext.Provider value={themePreference}>{res}</ThemePreferenceContext.Provider>;
|
|
175
|
+
|
|
78
176
|
const [themeMenuPreference, setThemeMenuPreference] = useState<ThemeMenuPreference>(initialMenuPreference);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const unsubscribePreference = subscribeOnThemePreferenceChange(setThemePreference);
|
|
83
|
-
const unsubscribeMenuPreference = subscribeOnThemeMenuPreferenceChange(setThemeMenuPreference);
|
|
84
|
-
return () => {
|
|
85
|
-
unsubscribeMode();
|
|
86
|
-
unsubscribePreference();
|
|
87
|
-
unsubscribeMenuPreference();
|
|
88
|
-
};
|
|
89
|
-
}, []);
|
|
177
|
+
useEffect(() => subscribeOnThemeMenuPreferenceChange(setThemeMenuPreference), []);
|
|
178
|
+
res = <ThemeMenuPreferenceContext.Provider value={themeMenuPreference}>{res}</ThemeMenuPreferenceContext.Provider>;
|
|
179
|
+
|
|
90
180
|
useLayoutEffect(() => {
|
|
91
181
|
const documentElement = document.documentElement;
|
|
92
182
|
documentElement.classList.add(layoutStyles);
|
|
@@ -94,6 +184,7 @@ export function RootThemeProvider({
|
|
|
94
184
|
documentElement.classList.remove(layoutStyles);
|
|
95
185
|
};
|
|
96
186
|
}, []);
|
|
187
|
+
|
|
97
188
|
useEffect(() => {
|
|
98
189
|
const darkThemeClassName = "dark-theme";
|
|
99
190
|
const lightThemeAndDarkMenuClassName = "light-theme-and-dark-menu";
|
|
@@ -119,33 +210,5 @@ export function RootThemeProvider({
|
|
|
119
210
|
};
|
|
120
211
|
}, [themeMode]);
|
|
121
212
|
|
|
122
|
-
return
|
|
123
|
-
<FiberyThemePreferenceContext.Provider value={themePreference}>
|
|
124
|
-
<FiberyThemeMenuPreferenceContext.Provider value={themeMenuPreference}>
|
|
125
|
-
<ThemeProvider theme={theme}>{children}</ThemeProvider>
|
|
126
|
-
</FiberyThemeMenuPreferenceContext.Provider>
|
|
127
|
-
</FiberyThemePreferenceContext.Provider>
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
interface WithThemeModeProps {
|
|
132
|
-
themeMode: ThemeMode;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export function withThemeMode<T extends WithThemeModeProps = WithThemeModeProps>(
|
|
136
|
-
WrappedComponent: React.ComponentType<T>
|
|
137
|
-
) {
|
|
138
|
-
const displayName = WrappedComponent.displayName || WrappedComponent.name || "Component";
|
|
139
|
-
|
|
140
|
-
const ComponentWithThemeMode = (props: Omit<T, keyof WithThemeModeProps>) => {
|
|
141
|
-
const themeMode = useThemeMode();
|
|
142
|
-
|
|
143
|
-
return <WrappedComponent {...(props as T)} themeMode={themeMode} />;
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
ComponentWithThemeMode.displayName = `withThemeMode(${displayName})`;
|
|
147
|
-
|
|
148
|
-
return ComponentWithThemeMode;
|
|
213
|
+
return res;
|
|
149
214
|
}
|
|
150
|
-
|
|
151
|
-
export {ThemeProvider};
|
package/src/theme-settings.ts
CHANGED
|
@@ -42,7 +42,7 @@ export function getThemeMenuPreference(): ThemeMenuPreference {
|
|
|
42
42
|
return "auto";
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
export const alignTheme = (theme: ThemeMode) => {
|
|
45
|
+
export const alignTheme = (theme: ThemeMode): "light" | "dark" => {
|
|
46
46
|
if (theme === "light2") {
|
|
47
47
|
return "light";
|
|
48
48
|
}
|
package/src/theme-styles.ts
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import {css} from "@linaria/core";
|
|
2
|
-
import {createInlineTheme, getThemeColors,
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import {createInlineTheme, getThemeColors, themeVars} from "./design-system";
|
|
3
|
+
import {makeDefaultPalette} from "./palette-generator";
|
|
4
|
+
|
|
5
|
+
export const defaultPalette = makeDefaultPalette();
|
|
6
|
+
|
|
7
|
+
export const defaultLightTheme = getThemeColors(themeVars.brandColors.blue, "light", defaultPalette);
|
|
8
|
+
export const defaultDarkTheme = getThemeColors(themeVars.brandColors.blue, "dark", defaultPalette);
|
|
9
|
+
|
|
10
|
+
export const defaultLightThemeStyles = createInlineTheme(defaultLightTheme, []);
|
|
11
|
+
export const defaultDarkThemeStyles = createInlineTheme(defaultDarkTheme, []);
|
|
5
12
|
|
|
6
13
|
export const themeStyles = css`
|
|
7
14
|
:global() {
|
|
8
15
|
html:root {
|
|
9
|
-
${
|
|
16
|
+
${defaultLightThemeStyles}
|
|
10
17
|
&.dark-theme {
|
|
11
|
-
${
|
|
18
|
+
${defaultDarkThemeStyles}
|
|
12
19
|
}
|
|
13
20
|
}
|
|
14
21
|
}
|
|
@@ -19,7 +19,7 @@ export const ToastAction = forwardRef<
|
|
|
19
19
|
ButtonProps & {altText: ToastActionProps["altText"]}
|
|
20
20
|
>(({children, altText, ...props}, ref) => {
|
|
21
21
|
const theme = useTheme();
|
|
22
|
-
const buttonColors = theme.mode === "dark" ? makeButtonColors(theme.textColor, "outline") : {};
|
|
22
|
+
const buttonColors = theme.mode === "dark" ? makeButtonColors(theme.textColor, "outline", theme) : {};
|
|
23
23
|
return (
|
|
24
24
|
<RadixToastAction className={toastActionCss} ref={ref} altText={altText} asChild>
|
|
25
25
|
<Button style={buttonColors} variant="outline" color="neutral" {...props}>
|
package/src/toggle-on-off.tsx
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import chroma from "chroma-js";
|
|
2
1
|
import {FC, ComponentProps, useMemo} from "react";
|
|
2
|
+
import {isValidColor} from "./color-utils";
|
|
3
3
|
import {ThemeColors} from "./design-system";
|
|
4
4
|
import {useTheme} from "./theme-provider";
|
|
5
5
|
import {Toggle} from "./toggle";
|
|
6
6
|
import {useIsPhone} from "./use-is-phone";
|
|
7
7
|
|
|
8
8
|
const getBackgroundColors = (accentColor: string | undefined, theme: ThemeColors) => {
|
|
9
|
-
return accentColor &&
|
|
9
|
+
return accentColor && isValidColor(accentColor)
|
|
10
10
|
? {
|
|
11
11
|
enabledColor: accentColor,
|
|
12
12
|
disabledColor: theme.colorBgButtonSoftNeutralHover,
|
package/src/toggle.tsx
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {css, cx} from "@linaria/core";
|
|
2
2
|
import {styled} from "@linaria/react";
|
|
3
|
-
import chroma from "chroma-js";
|
|
4
3
|
import {ComponentProps, FC, ReactNode} from "react";
|
|
5
4
|
import {space, textStyles, transition} from "./design-system";
|
|
6
5
|
import _ from "lodash";
|
|
7
6
|
import SpinnerIcon from "./icons/react/Spinner";
|
|
8
7
|
import {mobileRootSelector} from "./mobile-styles";
|
|
8
|
+
import {darkenChroma, getAlpha, produceColor, setAlpha} from "./color-utils";
|
|
9
9
|
|
|
10
10
|
const toggleIconHeightVar = "--fibery-toggle-icon-height";
|
|
11
11
|
const toggleIconWidthVar = "--fibery-toggle-icon-width";
|
|
@@ -49,13 +49,11 @@ const labelWrapperStyle = css`
|
|
|
49
49
|
`;
|
|
50
50
|
|
|
51
51
|
const getOutlineColor = _.memoize((color: string) => {
|
|
52
|
-
const alpha =
|
|
52
|
+
const alpha = getAlpha(color);
|
|
53
53
|
if (alpha < 1) {
|
|
54
|
-
return
|
|
55
|
-
.alpha(alpha + 0.3)
|
|
56
|
-
.css();
|
|
54
|
+
return produceColor(color, (c) => setAlpha(c, Math.min(1, alpha + 0.3)));
|
|
57
55
|
} else {
|
|
58
|
-
return
|
|
56
|
+
return produceColor(color, (c) => darkenChroma(c, 1));
|
|
59
57
|
}
|
|
60
58
|
});
|
|
61
59
|
|
|
@@ -124,6 +122,7 @@ type ToggleProps = Omit<ComponentProps<"input">, "value" | "size"> & {
|
|
|
124
122
|
size?: ToggleSize;
|
|
125
123
|
};
|
|
126
124
|
|
|
125
|
+
/** @deprecated implementation detail */
|
|
127
126
|
export const Toggle: FC<ToggleProps> = ({
|
|
128
127
|
value,
|
|
129
128
|
label,
|
package/src/tooltip.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import {css, cx} from "@linaria/core";
|
|
|
2
2
|
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
3
3
|
import {forwardRef, type ReactNode, type SyntheticEvent} from "react";
|
|
4
4
|
import {border, fontWeight, lineHeight, space, themeVars, tooltipDelay} from "./design-system";
|
|
5
|
+
import {ThemeProvider} from "./theme-provider";
|
|
5
6
|
|
|
6
7
|
const isFlagPresent = (flag: string) => new RegExp(`[?&]${flag}\\b`).test(window.location.search);
|
|
7
8
|
|
|
@@ -204,16 +205,18 @@ export const Tooltip = forwardRef<HTMLButtonElement, TooltipProps>(
|
|
|
204
205
|
{children}
|
|
205
206
|
</TooltipPrimitive.Trigger>
|
|
206
207
|
<TooltipPrimitive.Portal container={container}>
|
|
207
|
-
<
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
208
|
+
<ThemeProvider portal>
|
|
209
|
+
<TooltipPrimitive.Content
|
|
210
|
+
ref={setContentElement}
|
|
211
|
+
side={side}
|
|
212
|
+
sideOffset={sideOffset}
|
|
213
|
+
align={align}
|
|
214
|
+
alignOffset={alignOffset}
|
|
215
|
+
className={cx(tooltipStyle, whiteBg && whiteBgStyle, tooltipContentStyle)}
|
|
216
|
+
>
|
|
217
|
+
{content}
|
|
218
|
+
</TooltipPrimitive.Content>
|
|
219
|
+
</ThemeProvider>
|
|
217
220
|
</TooltipPrimitive.Portal>
|
|
218
221
|
</TooltipPrimitive.Root>
|
|
219
222
|
);
|
package/src/type-badge.tsx
CHANGED
|
@@ -5,7 +5,6 @@ import {CSSProperties, forwardRef, memo, ReactNode} from "react";
|
|
|
5
5
|
import {a11yColor} from "./a11y-color";
|
|
6
6
|
import {
|
|
7
7
|
border,
|
|
8
|
-
colors,
|
|
9
8
|
fontWeight,
|
|
10
9
|
getDarkenColor,
|
|
11
10
|
getTextColor,
|
|
@@ -13,6 +12,7 @@ import {
|
|
|
13
12
|
opacity,
|
|
14
13
|
space,
|
|
15
14
|
textStyles,
|
|
15
|
+
themeVars,
|
|
16
16
|
transition,
|
|
17
17
|
} from "./design-system";
|
|
18
18
|
import {useTheme} from "./theme-provider";
|
|
@@ -210,9 +210,9 @@ export const TypeBadge = memo(
|
|
|
210
210
|
|
|
211
211
|
const resultingStyle = {
|
|
212
212
|
...style,
|
|
213
|
-
[colorProp]: baseColor ? textBadgeColor :
|
|
213
|
+
[colorProp]: baseColor ? textBadgeColor : themeVars.inversedTextColor,
|
|
214
214
|
//[colorProp]: baseColor ? getTextColor(baseColor) : colors.inversedTextColor,
|
|
215
|
-
[colorBackgroundProp]: backgroundBadgeColor ||
|
|
215
|
+
[colorBackgroundProp]: backgroundBadgeColor || themeVars.shades.opacity25,
|
|
216
216
|
//[colorBackgroundProp]: baseColor || colors.shades.opacity25,
|
|
217
217
|
[colorBorderProp]: backgroundBadgeColor,
|
|
218
218
|
[colorDarkProp]: getDarkenColor(baseColor),
|
package/src/unit/styles.ts
CHANGED
|
@@ -8,7 +8,7 @@ export const textEllipsisClassName = css`
|
|
|
8
8
|
`;
|
|
9
9
|
|
|
10
10
|
export const basicUnitClassName = css`
|
|
11
|
-
border-radius: ${space.
|
|
11
|
+
border-radius: ${space.s6}px;
|
|
12
12
|
border: none;
|
|
13
13
|
`;
|
|
14
14
|
|
|
@@ -84,7 +84,7 @@ export const borderClassName = css`
|
|
|
84
84
|
bottom: 0;
|
|
85
85
|
box-shadow: ${themeVars.inputBorderColor} inset;
|
|
86
86
|
mix-blend-mode: ${themeVars.inputBorderBlendMode};
|
|
87
|
-
border-radius: ${space.
|
|
87
|
+
border-radius: ${space.s6}px;
|
|
88
88
|
pointer-events: none;
|
|
89
89
|
}
|
|
90
90
|
|
|
@@ -13,9 +13,10 @@ type Props = {
|
|
|
13
13
|
children: React.ReactElement;
|
|
14
14
|
title: React.ReactNode;
|
|
15
15
|
description: React.ReactNode;
|
|
16
|
+
hidden?: boolean;
|
|
16
17
|
};
|
|
17
18
|
|
|
18
|
-
export const UnitWithTooltip = ({children, title, description}: Props) => {
|
|
19
|
+
export const UnitWithTooltip = ({children, title, description, hidden}: Props) => {
|
|
19
20
|
const [shouldDisplayTooltip, setShouldDisplayTooltip] = useState(false);
|
|
20
21
|
const unitElementRef = useRef<HTMLDivElement>(null);
|
|
21
22
|
const isHoveredRef = useRef(false);
|
|
@@ -57,7 +58,7 @@ export const UnitWithTooltip = ({children, title, description}: Props) => {
|
|
|
57
58
|
|
|
58
59
|
return (
|
|
59
60
|
<Tooltip
|
|
60
|
-
visible={shouldDisplayTooltip}
|
|
61
|
+
visible={!hidden && shouldDisplayTooltip}
|
|
61
62
|
content={
|
|
62
63
|
<div className={contentCss}>
|
|
63
64
|
<TooltipTitle>{title}</TooltipTitle>
|
package/src/use-long-press.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import {$TSFixMe} from "./tsfixme";
|
|
|
3
3
|
|
|
4
4
|
function on<T extends Window | Document | HTMLElement | EventTarget>(
|
|
5
5
|
obj: T | null,
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-function-type -- DOM API compatibility
|
|
7
7
|
...args: Parameters<T["addEventListener"]> | [string, Function | null, ...any]
|
|
8
8
|
): void {
|
|
9
9
|
if (obj && obj.addEventListener) {
|
|
@@ -13,7 +13,7 @@ function on<T extends Window | Document | HTMLElement | EventTarget>(
|
|
|
13
13
|
|
|
14
14
|
export function off<T extends Window | Document | HTMLElement | EventTarget>(
|
|
15
15
|
obj: T | null,
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-function-type -- DOM API compatibility
|
|
17
17
|
...args: Parameters<T["removeEventListener"]> | [string, Function | null, ...any]
|
|
18
18
|
): void {
|
|
19
19
|
if (obj && obj.removeEventListener) {
|