@fibery/ui-kit 1.40.2 → 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 +14 -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/Icon.tsx +1 -0
- package/src/icons/ast/FileCounter.ts +8 -0
- package/src/icons/ast/FileMultiple.ts +8 -0
- package/src/icons/ast/Print.ts +8 -0
- package/src/icons/ast/ValueEdit.ts +8 -0
- package/src/icons/ast/index.tsx +4 -0
- package/src/icons/react/Dividers.tsx +1 -1
- package/src/icons/react/FileCounter.tsx +13 -0
- package/src/icons/react/FileMultiple.tsx +13 -0
- package/src/icons/react/Print.tsx +13 -0
- package/src/icons/react/ValueEdit.tsx +13 -0
- package/src/icons/react/index.tsx +4 -0
- package/src/icons/svg/file-counter.svg +3 -0
- package/src/icons/svg/file-multiple.svg +3 -0
- package/src/icons/svg/print.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 +20 -28
- 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
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import {
|
|
2
|
+
blackAScale,
|
|
3
|
+
indigoDarkScale,
|
|
4
|
+
indigoScale,
|
|
5
|
+
redDarkScale,
|
|
6
|
+
redScale,
|
|
7
|
+
slateDarkScale,
|
|
8
|
+
slateScale,
|
|
9
|
+
tealDarkScale,
|
|
10
|
+
tealScale,
|
|
11
|
+
whiteAScale,
|
|
12
|
+
yellowDarkScale,
|
|
13
|
+
yellowScale,
|
|
14
|
+
} from "./palette";
|
|
15
|
+
import {
|
|
16
|
+
BasedScale12,
|
|
17
|
+
DEFAULT_DARK_CURVES,
|
|
18
|
+
DEFAULT_LIGHT_CURVES,
|
|
19
|
+
generateBlackScale,
|
|
20
|
+
generateColorScale,
|
|
21
|
+
generateGrayScale,
|
|
22
|
+
generateInterpolatedScale,
|
|
23
|
+
generatePresetScale,
|
|
24
|
+
generateWhiteScale,
|
|
25
|
+
type InterpolatedScaleConfig,
|
|
26
|
+
type Scale12,
|
|
27
|
+
paletteFromHue,
|
|
28
|
+
paletteFromHueBoth,
|
|
29
|
+
SCALE_PRESETS,
|
|
30
|
+
type ScaleConfig,
|
|
31
|
+
type ScaleCurves,
|
|
32
|
+
} from "./scale-generator";
|
|
33
|
+
|
|
34
|
+
export type ColorScale = BasedScale12<string>;
|
|
35
|
+
|
|
36
|
+
export interface ThemePalette {
|
|
37
|
+
key: string;
|
|
38
|
+
white: ColorScale;
|
|
39
|
+
black: ColorScale;
|
|
40
|
+
base: ColorScale;
|
|
41
|
+
baseDark: ColorScale;
|
|
42
|
+
accent: ColorScale;
|
|
43
|
+
accentDark: ColorScale;
|
|
44
|
+
red: ColorScale;
|
|
45
|
+
redDark: ColorScale;
|
|
46
|
+
teal: ColorScale;
|
|
47
|
+
tealDark: ColorScale;
|
|
48
|
+
yellow: ColorScale;
|
|
49
|
+
yellowDark: ColorScale;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const defaultPaletteKey = "default";
|
|
53
|
+
export function makeDefaultPalette(): ThemePalette {
|
|
54
|
+
return {
|
|
55
|
+
key: defaultPaletteKey,
|
|
56
|
+
white: whiteAScale,
|
|
57
|
+
black: blackAScale,
|
|
58
|
+
base: slateScale,
|
|
59
|
+
baseDark: slateDarkScale,
|
|
60
|
+
accent: indigoScale,
|
|
61
|
+
accentDark: indigoDarkScale,
|
|
62
|
+
red: redScale,
|
|
63
|
+
redDark: redDarkScale,
|
|
64
|
+
teal: tealScale,
|
|
65
|
+
tealDark: tealDarkScale,
|
|
66
|
+
yellow: yellowScale,
|
|
67
|
+
yellowDark: yellowDarkScale,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export type ThematicPrefs = {
|
|
72
|
+
baseHue?: number;
|
|
73
|
+
baseChroma?: number;
|
|
74
|
+
accentHue: number;
|
|
75
|
+
accentChroma: number;
|
|
76
|
+
contrast?: number;
|
|
77
|
+
whiteLuminosity?: number;
|
|
78
|
+
whiteChroma?: number;
|
|
79
|
+
blackLuminosity?: number;
|
|
80
|
+
blackChroma?: number;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
function shiftHueTowards(hue: number, targetHue: number, amount: number): number {
|
|
84
|
+
// Find shortest path on hue circle
|
|
85
|
+
let diff = targetHue - hue;
|
|
86
|
+
if (diff > 180) {
|
|
87
|
+
diff -= 360;
|
|
88
|
+
} else if (diff < -180) {
|
|
89
|
+
diff += 360;
|
|
90
|
+
}
|
|
91
|
+
return (hue + diff * amount + 360) % 360;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function makeThematicPalette(config: ThematicPrefs): ThemePalette {
|
|
95
|
+
const {baseHue = 0, baseChroma = 0, accentHue, accentChroma, contrast} = config;
|
|
96
|
+
|
|
97
|
+
const white = generateWhiteScale(baseHue, baseChroma, config.whiteLuminosity, config.whiteChroma);
|
|
98
|
+
const black = generateBlackScale(baseHue, baseChroma, config.blackLuminosity, config.blackChroma);
|
|
99
|
+
|
|
100
|
+
// Generate base/gray scales with tinted base colors
|
|
101
|
+
const base = generateGrayScale({hue: baseHue, chroma: baseChroma, mode: "light", contrast, base: white[0]});
|
|
102
|
+
const baseDark = generateGrayScale({hue: baseHue, chroma: baseChroma, mode: "dark", contrast, base: black[0]});
|
|
103
|
+
|
|
104
|
+
// Generate accent scales
|
|
105
|
+
const accent = generateColorScale({hue: accentHue, chroma: accentChroma, mode: "light", contrast});
|
|
106
|
+
const accentDark = generateColorScale({hue: accentHue, chroma: accentChroma, mode: "dark", contrast});
|
|
107
|
+
|
|
108
|
+
// Shift semantic hues towards base hue when baseChroma is high
|
|
109
|
+
const hueShift = Math.min(baseChroma * 2, 0.3); // max 30% shift at chroma 0.15+
|
|
110
|
+
const redHue = shiftHueTowards(SCALE_PRESETS.red.hue, baseHue, hueShift);
|
|
111
|
+
const tealHue = shiftHueTowards(SCALE_PRESETS.teal.hue, baseHue, hueShift);
|
|
112
|
+
const yellowHue = shiftHueTowards(SCALE_PRESETS.yellow.hue, baseHue, hueShift);
|
|
113
|
+
|
|
114
|
+
const red = generateColorScale({hue: redHue, chroma: SCALE_PRESETS.red.chroma, mode: "light", contrast});
|
|
115
|
+
const redDark = generateColorScale({hue: redHue, chroma: SCALE_PRESETS.red.chroma, mode: "dark", contrast});
|
|
116
|
+
const teal = generateColorScale({hue: tealHue, chroma: SCALE_PRESETS.teal.chroma, mode: "light", contrast});
|
|
117
|
+
const tealDark = generateColorScale({hue: tealHue, chroma: SCALE_PRESETS.teal.chroma, mode: "dark", contrast});
|
|
118
|
+
const yellow = generateColorScale({
|
|
119
|
+
hue: yellowHue,
|
|
120
|
+
chroma: SCALE_PRESETS.yellow.chroma,
|
|
121
|
+
mode: "light",
|
|
122
|
+
contrast,
|
|
123
|
+
curves: SCALE_PRESETS.yellow.lightCurves,
|
|
124
|
+
});
|
|
125
|
+
const yellowDark = generateColorScale({
|
|
126
|
+
hue: yellowHue,
|
|
127
|
+
chroma: SCALE_PRESETS.yellow.chroma,
|
|
128
|
+
mode: "dark",
|
|
129
|
+
contrast,
|
|
130
|
+
curves: SCALE_PRESETS.yellow.darkCurves,
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
return {
|
|
134
|
+
key: JSON.stringify(config),
|
|
135
|
+
white,
|
|
136
|
+
black,
|
|
137
|
+
base,
|
|
138
|
+
baseDark,
|
|
139
|
+
accent,
|
|
140
|
+
accentDark,
|
|
141
|
+
red,
|
|
142
|
+
redDark,
|
|
143
|
+
teal,
|
|
144
|
+
tealDark,
|
|
145
|
+
yellow,
|
|
146
|
+
yellowDark,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export {
|
|
151
|
+
generateBlackScale,
|
|
152
|
+
generateColorScale,
|
|
153
|
+
generateGrayScale,
|
|
154
|
+
generateInterpolatedScale,
|
|
155
|
+
generatePresetScale,
|
|
156
|
+
generateWhiteScale,
|
|
157
|
+
paletteFromHue,
|
|
158
|
+
paletteFromHueBoth,
|
|
159
|
+
SCALE_PRESETS,
|
|
160
|
+
DEFAULT_LIGHT_CURVES,
|
|
161
|
+
DEFAULT_DARK_CURVES,
|
|
162
|
+
type Scale12,
|
|
163
|
+
type ScaleConfig,
|
|
164
|
+
type ScaleCurves,
|
|
165
|
+
type InterpolatedScaleConfig,
|
|
166
|
+
};
|
package/src/palette.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type {ColorScale} from "./palette-generator";
|
|
2
|
+
import {throwError} from "./errors";
|
|
3
|
+
|
|
4
|
+
const base = "hsl(0, 0%, 100%)";
|
|
5
|
+
|
|
6
|
+
const slate = {
|
|
7
|
+
slateBase: base,
|
|
3
8
|
slate1: "hsl(206, 0%, 99%)",
|
|
4
9
|
slate2: "hsl(210, 0%, 97%)",
|
|
5
10
|
slate3: "hsl(209, 0%, 96%)",
|
|
@@ -14,6 +19,9 @@ export const slate = {
|
|
|
14
19
|
slate12: "hsl(200, 0%, 9%)",
|
|
15
20
|
} as const;
|
|
16
21
|
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated use themeVars
|
|
24
|
+
*/
|
|
17
25
|
export const slateDark = {
|
|
18
26
|
slateBase: "hsl(0, 0%, 5%)",
|
|
19
27
|
slate1: "hsl(200, 0%, 9%)",
|
|
@@ -30,6 +38,9 @@ export const slateDark = {
|
|
|
30
38
|
slate12: "hsl(210, 0%, 93%)",
|
|
31
39
|
} as const;
|
|
32
40
|
|
|
41
|
+
/**
|
|
42
|
+
* @deprecated use themeVars
|
|
43
|
+
*/
|
|
33
44
|
export const teal = {
|
|
34
45
|
teal1: "hsl(165, 60%, 99%)",
|
|
35
46
|
teal2: "hsl(169, 65%, 97%)",
|
|
@@ -45,6 +56,9 @@ export const teal = {
|
|
|
45
56
|
teal12: "hsl(170, 50%, 13%)",
|
|
46
57
|
} as const;
|
|
47
58
|
|
|
59
|
+
/**
|
|
60
|
+
* @deprecated use themeVars
|
|
61
|
+
*/
|
|
48
62
|
export const tealDark = {
|
|
49
63
|
teal1: "hsl(168, 48%, 6%)",
|
|
50
64
|
teal2: "hsl(169, 78%, 7%)",
|
|
@@ -60,6 +74,9 @@ export const tealDark = {
|
|
|
60
74
|
teal12: "hsl(166, 73%, 93%)",
|
|
61
75
|
} as const;
|
|
62
76
|
|
|
77
|
+
/**
|
|
78
|
+
* @deprecated use themeVars
|
|
79
|
+
*/
|
|
63
80
|
export const indigo = {
|
|
64
81
|
indigo1: "hsl(220, 60%, 99%)",
|
|
65
82
|
indigo2: "hsl(220, 90%, 99%)",
|
|
@@ -75,6 +92,9 @@ export const indigo = {
|
|
|
75
92
|
indigo12: "hsl(220, 62%, 17%)",
|
|
76
93
|
} as const;
|
|
77
94
|
|
|
95
|
+
/**
|
|
96
|
+
* @deprecated use themeVars
|
|
97
|
+
*/
|
|
78
98
|
export const indigoDark = {
|
|
79
99
|
indigo1: "hsl(222, 24%, 10%)",
|
|
80
100
|
indigo2: "hsl(222, 36%, 13%)",
|
|
@@ -90,6 +110,9 @@ export const indigoDark = {
|
|
|
90
110
|
indigo12: "hsl(222, 83%, 96%)",
|
|
91
111
|
} as const;
|
|
92
112
|
|
|
113
|
+
/**
|
|
114
|
+
* @deprecated use themeVars
|
|
115
|
+
*/
|
|
93
116
|
export const red = {
|
|
94
117
|
red1: "hsl(359, 100%, 99%)",
|
|
95
118
|
red2: "hsl(359, 100%, 99%)",
|
|
@@ -105,6 +128,9 @@ export const red = {
|
|
|
105
128
|
red12: "hsl(354, 50%, 15%)",
|
|
106
129
|
} as const;
|
|
107
130
|
|
|
131
|
+
/**
|
|
132
|
+
* @deprecated use themeVars
|
|
133
|
+
*/
|
|
108
134
|
export const redDark = {
|
|
109
135
|
red1: "hsl(353, 23%, 10%)",
|
|
110
136
|
red2: "hsl(357, 34%, 12%)",
|
|
@@ -120,36 +146,6 @@ export const redDark = {
|
|
|
120
146
|
red12: "hsl(351, 89%, 96%)",
|
|
121
147
|
} as const;
|
|
122
148
|
|
|
123
|
-
export const blue = {
|
|
124
|
-
blue1: "hsl(206, 100%, 99%)",
|
|
125
|
-
blue2: "hsl(210, 100%, 98%)",
|
|
126
|
-
blue3: "hsl(209, 100%, 96%)",
|
|
127
|
-
blue4: "hsl(210, 99%, 94%)",
|
|
128
|
-
blue5: "hsl(209, 95%, 90%)",
|
|
129
|
-
blue6: "hsl(209, 81%, 84%)",
|
|
130
|
-
blue7: "hsl(208, 77%, 77%)",
|
|
131
|
-
blue8: "hsl(206, 82%, 65%)",
|
|
132
|
-
blue9: "hsl(206, 100%, 50%)",
|
|
133
|
-
blue10: "hsl(208, 100%, 47%)",
|
|
134
|
-
blue11: "hsl(211, 100%, 43%)",
|
|
135
|
-
blue12: "hsl(211, 100%, 15%)",
|
|
136
|
-
} as const;
|
|
137
|
-
|
|
138
|
-
export const blueDark = {
|
|
139
|
-
blue1: "hsl(212, 35%, 9%)",
|
|
140
|
-
blue2: "hsl(216, 50%, 12%)",
|
|
141
|
-
blue3: "hsl(214, 59%, 15%)",
|
|
142
|
-
blue4: "hsl(214, 66%, 18%)",
|
|
143
|
-
blue5: "hsl(213, 71%, 20%)",
|
|
144
|
-
blue6: "hsl(212, 77%, 23%)",
|
|
145
|
-
blue7: "hsl(211, 85%, 27%)",
|
|
146
|
-
blue8: "hsl(211, 90%, 34%)",
|
|
147
|
-
blue9: "hsl(206, 100%, 50%)",
|
|
148
|
-
blue10: "hsl(209, 100%, 61%)",
|
|
149
|
-
blue11: "hsl(210, 100%, 66%)",
|
|
150
|
-
blue12: "hsl(206, 98%, 96%)",
|
|
151
|
-
} as const;
|
|
152
|
-
|
|
153
149
|
export const yellow = {
|
|
154
150
|
yellow1: "hsl(60, 54%, 98%)",
|
|
155
151
|
yellow2: "hsl(52, 100%, 95%)",
|
|
@@ -165,6 +161,9 @@ export const yellow = {
|
|
|
165
161
|
yellow12: "hsl(40, 55%, 13%)",
|
|
166
162
|
} as const;
|
|
167
163
|
|
|
164
|
+
/**
|
|
165
|
+
* @deprecated use themeVars
|
|
166
|
+
*/
|
|
168
167
|
export const yellowDark = {
|
|
169
168
|
yellow1: "hsl(45, 100%, 5%)",
|
|
170
169
|
yellow2: "hsl(46, 100%, 7%)",
|
|
@@ -180,6 +179,9 @@ export const yellowDark = {
|
|
|
180
179
|
yellow12: "hsl(53, 100%, 91%)",
|
|
181
180
|
} as const;
|
|
182
181
|
|
|
182
|
+
/**
|
|
183
|
+
* @deprecated use themeVars
|
|
184
|
+
*/
|
|
183
185
|
export const blackA = {
|
|
184
186
|
blackA0: "#000000",
|
|
185
187
|
blackA1: "hsla(0, 0%, 0%, 0.01)",
|
|
@@ -196,6 +198,9 @@ export const blackA = {
|
|
|
196
198
|
blackA12: "hsla(0, 0%, 0%, 0.91)",
|
|
197
199
|
} as const;
|
|
198
200
|
|
|
201
|
+
/**
|
|
202
|
+
* @deprecated use themeVars
|
|
203
|
+
*/
|
|
199
204
|
export const whiteA = {
|
|
200
205
|
whiteA0: "#FFFFFF",
|
|
201
206
|
whiteA1: "hsla(0, 0%, 100%, 0)",
|
|
@@ -212,26 +217,37 @@ export const whiteA = {
|
|
|
212
217
|
whiteA12: "hsla(0, 0%, 100%, 0.92)",
|
|
213
218
|
} as const;
|
|
214
219
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
220
|
+
/**
|
|
221
|
+
* Converts a Radix color object ({prefix1, prefix2, ...}) to a ColorScale array.
|
|
222
|
+
* Index 0 uses prefixBase if available, otherwise prefixStep1.
|
|
223
|
+
*/
|
|
224
|
+
export function toColorScale<K extends string>(radixScale: Record<string, string>, prefix: K): ColorScale {
|
|
225
|
+
return [
|
|
226
|
+
radixScale[`${prefix}0`] ?? radixScale[`${prefix}Base`] ?? base,
|
|
227
|
+
radixScale[`${prefix}1`],
|
|
228
|
+
radixScale[`${prefix}2`],
|
|
229
|
+
radixScale[`${prefix}3`],
|
|
230
|
+
radixScale[`${prefix}4`],
|
|
231
|
+
radixScale[`${prefix}5`],
|
|
232
|
+
radixScale[`${prefix}6`],
|
|
233
|
+
radixScale[`${prefix}7`],
|
|
234
|
+
radixScale[`${prefix}8`],
|
|
235
|
+
radixScale[`${prefix}9`],
|
|
236
|
+
radixScale[`${prefix}10`],
|
|
237
|
+
radixScale[`${prefix}11`],
|
|
238
|
+
radixScale[`${prefix}12`],
|
|
239
|
+
].map((x, i) => x ?? throwError(prefix + i)) as unknown as ColorScale;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export const whiteAScale = toColorScale(whiteA, "whiteA");
|
|
243
|
+
export const blackAScale = toColorScale(blackA, "blackA");
|
|
244
|
+
export const slateScale = toColorScale(slate, "slate");
|
|
245
|
+
export const slateDarkScale = toColorScale(slateDark, "slate");
|
|
246
|
+
export const indigoScale = toColorScale(indigo, "indigo");
|
|
247
|
+
export const indigoDarkScale = toColorScale(indigoDark, "indigo");
|
|
248
|
+
export const redScale = toColorScale(red, "red");
|
|
249
|
+
export const redDarkScale = toColorScale(redDark, "red");
|
|
250
|
+
export const tealScale = toColorScale(teal, "teal");
|
|
251
|
+
export const tealDarkScale = toColorScale(tealDark, "teal");
|
|
252
|
+
export const yellowScale = toColorScale(yellow, "yellow");
|
|
253
|
+
export const yellowDarkScale = toColorScale(yellowDark, "yellow");
|
package/src/platform.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {UAParser} from "ua-parser-js";
|
|
2
|
-
|
|
3
1
|
export const isMac = navigator.platform.startsWith("Mac");
|
|
4
2
|
export const isWindows = navigator.platform.startsWith("Win");
|
|
5
3
|
export const isLinux = navigator.platform.startsWith("Linux");
|
|
6
|
-
export const isMobile = new UAParser(navigator.userAgent).getDevice().type === "mobile";
|
package/src/popover/index.tsx
CHANGED
|
@@ -28,11 +28,11 @@ import {
|
|
|
28
28
|
} from "../mobile-styles";
|
|
29
29
|
import {createPortal} from "react-dom";
|
|
30
30
|
import {usePopper} from "react-popper";
|
|
31
|
-
import {
|
|
31
|
+
import {space, textStyles, themeVars, transition} from "../design-system";
|
|
32
32
|
import {IconButton} from "../button/icon-button";
|
|
33
33
|
import CloseIcon from "../icons/react/Close";
|
|
34
34
|
import ArrowLeftIcon from "../icons/react/ArrowLeft";
|
|
35
|
-
import {
|
|
35
|
+
import {ThemeProvider} from "../theme-provider";
|
|
36
36
|
import {$TSFixMe} from "../tsfixme";
|
|
37
37
|
import {useIsPhone} from "../use-is-phone";
|
|
38
38
|
import {usePopupModifiers} from "./popup-modifiers-context";
|
|
@@ -101,8 +101,6 @@ export function MobilePopup({
|
|
|
101
101
|
onClose?: () => void;
|
|
102
102
|
onNavigateBack?: () => void;
|
|
103
103
|
}) {
|
|
104
|
-
const theme = useTheme();
|
|
105
|
-
|
|
106
104
|
const {title: contextTitle, headerSlot} = useMobilePopup();
|
|
107
105
|
|
|
108
106
|
const headerContent = headerSlot ?? (
|
|
@@ -165,7 +163,7 @@ export function MobilePopup({
|
|
|
165
163
|
</>
|
|
166
164
|
);
|
|
167
165
|
|
|
168
|
-
|
|
166
|
+
const res = (
|
|
169
167
|
<div
|
|
170
168
|
className={cx(
|
|
171
169
|
css`
|
|
@@ -184,7 +182,6 @@ export function MobilePopup({
|
|
|
184
182
|
`
|
|
185
183
|
)}
|
|
186
184
|
style={{
|
|
187
|
-
...createInlineTheme(theme),
|
|
188
185
|
...mobilePopupStyle,
|
|
189
186
|
...(height ? {gridTemplateRows: `1fr ${height}`} : {}),
|
|
190
187
|
}}
|
|
@@ -216,6 +213,7 @@ export function MobilePopup({
|
|
|
216
213
|
)}
|
|
217
214
|
</div>
|
|
218
215
|
);
|
|
216
|
+
return <ThemeProvider portal>{res}</ThemeProvider>;
|
|
219
217
|
}
|
|
220
218
|
|
|
221
219
|
type PortalProps = {
|
|
@@ -238,20 +236,14 @@ type TriggerProps = {
|
|
|
238
236
|
const Trigger = ({asChild = false, reference, children, onMouseDown, ...props}: TriggerProps) => {
|
|
239
237
|
const {setTriggerElement, disabled, open, onOpen, onClose} = useContext();
|
|
240
238
|
|
|
241
|
-
const onMouseDownCb: React.MouseEventHandler<HTMLElement> = composeEventHandlers(
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
if (disabled) {
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
if (e.button === 0) {
|
|
248
|
-
open ? onClose?.(e as unknown as Event) : onOpen?.();
|
|
249
|
-
}
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
checkForDefaultPrevented: false,
|
|
239
|
+
const onMouseDownCb: React.MouseEventHandler<HTMLElement> = composeEventHandlers(onMouseDown, (e) => {
|
|
240
|
+
if (disabled) {
|
|
241
|
+
return;
|
|
253
242
|
}
|
|
254
|
-
|
|
243
|
+
if (e.button === 0) {
|
|
244
|
+
open ? onClose?.(e as unknown as Event) : onOpen?.();
|
|
245
|
+
}
|
|
246
|
+
});
|
|
255
247
|
|
|
256
248
|
useEffect(() => {
|
|
257
249
|
if (reference) {
|
|
@@ -264,13 +256,14 @@ const Trigger = ({asChild = false, reference, children, onMouseDown, ...props}:
|
|
|
264
256
|
return null;
|
|
265
257
|
}
|
|
266
258
|
|
|
267
|
-
if (asChild && isValidElement(children)) {
|
|
268
|
-
return cloneElement(children, {
|
|
269
|
-
ref: setTriggerElement,
|
|
259
|
+
if (asChild && isValidElement<React.HTMLAttributes<HTMLElement>>(children)) {
|
|
260
|
+
return cloneElement<React.HTMLAttributes<HTMLElement> & React.RefAttributes<HTMLElement>>(children, {
|
|
270
261
|
"aria-expanded": open,
|
|
271
262
|
"aria-haspopup": true,
|
|
272
|
-
onMouseDown: onMouseDownCb,
|
|
273
263
|
...props,
|
|
264
|
+
ref: setTriggerElement,
|
|
265
|
+
className: cx(children.props.className, props.className),
|
|
266
|
+
onMouseDown: onMouseDownCb,
|
|
274
267
|
});
|
|
275
268
|
}
|
|
276
269
|
|
|
@@ -349,7 +342,6 @@ const Content = forwardRef<ContentRef, ContentProps>(function PopoverContentInne
|
|
|
349
342
|
const {open, onClose, triggerElement, popupElement, setPopupElement} = useContext();
|
|
350
343
|
|
|
351
344
|
const popupModifiers = usePopupModifiers();
|
|
352
|
-
const theme = useTheme();
|
|
353
345
|
const isPhone = useIsPhone();
|
|
354
346
|
|
|
355
347
|
// We get infinite popup renders if this is not in a separate memo
|
|
@@ -433,8 +425,8 @@ const Content = forwardRef<ContentRef, ContentProps>(function PopoverContentInne
|
|
|
433
425
|
};
|
|
434
426
|
|
|
435
427
|
const contentStyles = useMemo(() => {
|
|
436
|
-
return {...styles.popper, ...
|
|
437
|
-
}, [popupStyle, styles.popper
|
|
428
|
+
return {...styles.popper, ...popupStyle};
|
|
429
|
+
}, [popupStyle, styles.popper]);
|
|
438
430
|
|
|
439
431
|
if (!open) {
|
|
440
432
|
return null;
|
|
@@ -459,7 +451,7 @@ const Content = forwardRef<ContentRef, ContentProps>(function PopoverContentInne
|
|
|
459
451
|
);
|
|
460
452
|
}
|
|
461
453
|
return (
|
|
462
|
-
|
|
454
|
+
<ThemeProvider portal>
|
|
463
455
|
{renderBackdrop && <Backdrop className={backdropClassName} />}
|
|
464
456
|
<div
|
|
465
457
|
ref={setPopupElement}
|
|
@@ -478,7 +470,7 @@ const Content = forwardRef<ContentRef, ContentProps>(function PopoverContentInne
|
|
|
478
470
|
{children}
|
|
479
471
|
</div>
|
|
480
472
|
</div>
|
|
481
|
-
|
|
473
|
+
</ThemeProvider>
|
|
482
474
|
);
|
|
483
475
|
});
|
|
484
476
|
|
package/src/progress.tsx
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {Line, Circle, ProgressProps} from "rc-progress";
|
|
2
2
|
import {FC} from "react";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
type CircleProgressProps = ProgressProps;
|
|
5
5
|
|
|
6
6
|
export const CircleProgress: FC<CircleProgressProps> = (props) => {
|
|
7
7
|
return <Circle trailWidth={12} strokeWidth={12} {...props} />;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
type ProgressBarProps = ProgressProps;
|
|
11
11
|
|
|
12
12
|
export const ProgressBar: FC<ProgressBarProps> = (props) => {
|
|
13
13
|
return <Line className={props.className} trailWidth={8} strokeWidth={8} {...props} />;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {css} from "@linaria/core";
|
|
2
|
-
import {Fragment, ReactEventHandler, ReactNode, useCallback,
|
|
2
|
+
import {Fragment, ReactEventHandler, ReactNode, useCallback, useRef, useState} from "react";
|
|
3
3
|
import {createPortal} from "react-dom";
|
|
4
4
|
import {fontSize, fontWeight, space, themeVars} from "../design-system";
|
|
5
|
+
import {ThemeProvider} from "../theme-provider";
|
|
5
6
|
import {Emoji} from "../emoji-picker/emoji";
|
|
6
7
|
import {ToggleButton} from "../toggle-button/toggle-button";
|
|
7
8
|
import {Tooltip} from "../tooltip";
|
|
@@ -10,7 +11,7 @@ import {mobileRootSelector, safeAreaInsetBottomVar} from "../mobile-styles";
|
|
|
10
11
|
import {useLongPress} from "../use-long-press";
|
|
11
12
|
import {getWordDivider} from "./get-word-divider";
|
|
12
13
|
import {EmojiTooltipDescription, EmojiTooltipTitle} from "./tootltip";
|
|
13
|
-
import {
|
|
14
|
+
import {tabButton, TabNavLink, TabNavList, TabNavRoot} from "../tab-nav/tab-nav";
|
|
14
15
|
import {AvatarImage} from "../avatar";
|
|
15
16
|
import {getPopupContainerElement} from "../utils-dom";
|
|
16
17
|
|
|
@@ -46,7 +47,12 @@ const overlayClassName = css`
|
|
|
46
47
|
`;
|
|
47
48
|
|
|
48
49
|
function TouchOverlay({onClick}: {onClick: () => void}) {
|
|
49
|
-
return createPortal(
|
|
50
|
+
return createPortal(
|
|
51
|
+
<ThemeProvider portal>
|
|
52
|
+
<div className={overlayClassName} onClick={onClick} />
|
|
53
|
+
</ThemeProvider>,
|
|
54
|
+
getPopupContainerElement()
|
|
55
|
+
);
|
|
50
56
|
}
|
|
51
57
|
|
|
52
58
|
function MobileOverlay({content, onClose}: {content: ReactNode; onClose: () => void}) {
|
|
@@ -57,7 +63,7 @@ function MobileOverlay({content, onClose}: {content: ReactNode; onClose: () => v
|
|
|
57
63
|
},
|
|
58
64
|
[onClose]
|
|
59
65
|
);
|
|
60
|
-
|
|
66
|
+
const res = (
|
|
61
67
|
<div className={overlayClassName}>
|
|
62
68
|
<div
|
|
63
69
|
onPointerDown={handleClose}
|
|
@@ -79,9 +85,9 @@ function MobileOverlay({content, onClose}: {content: ReactNode; onClose: () => v
|
|
|
79
85
|
>
|
|
80
86
|
{content}
|
|
81
87
|
</div>
|
|
82
|
-
</div
|
|
83
|
-
getPopupContainerElement()
|
|
88
|
+
</div>
|
|
84
89
|
);
|
|
90
|
+
return createPortal(<ThemeProvider portal>{res}</ThemeProvider>, getPopupContainerElement());
|
|
85
91
|
}
|
|
86
92
|
|
|
87
93
|
const navLinkClassName = css`
|