@datalayer/primer-addons 1.0.17 → 1.0.19
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/lib/components/appearance/AppearanceControls.d.ts +3 -2
- package/lib/components/appearance/AppearanceControls.js +71 -3
- package/lib/components/appearance/AppearanceMenu.d.ts +30 -0
- package/lib/components/appearance/AppearanceMenu.js +15 -0
- package/lib/components/appearance/ColorModeCircle.d.ts +28 -0
- package/lib/components/appearance/ColorModeCircle.js +132 -0
- package/lib/components/appearance/ThemeCircle.d.ts +21 -0
- package/lib/components/appearance/ThemeCircle.js +46 -0
- package/lib/components/appearance/ThemePreviewCard.d.ts +12 -0
- package/lib/components/appearance/ThemePreviewCard.js +83 -0
- package/lib/components/appearance/index.d.ts +4 -0
- package/lib/components/appearance/index.js +4 -0
- package/lib/components/box/Box.d.ts +1 -1
- package/lib/components/closeable-flash/CloseableFlash.js +58 -1
- package/lib/components/color/ColorSwatch.d.ts +23 -0
- package/lib/components/color/ColorSwatch.js +62 -0
- package/lib/components/color/index.d.ts +1 -0
- package/lib/components/color/index.js +5 -0
- package/lib/components/content-loader/ContentLoader.js +4 -2
- package/lib/components/icons/CircleIcon.js +6 -4
- package/lib/components/index.d.ts +7 -1
- package/lib/components/index.js +7 -1
- package/lib/components/logo/AI2.d.ts +20 -0
- package/lib/components/logo/AI2.js +23 -0
- package/lib/components/logo/DI.d.ts +19 -0
- package/lib/components/logo/DI.js +20 -0
- package/lib/components/logo/DatalayerLogo.js +49 -1
- package/lib/components/logo/index.d.ts +2 -0
- package/lib/components/logo/index.js +2 -0
- package/lib/components/{overlay/Overlay.d.ts → side-overlay/SideOverlay.d.ts} +3 -3
- package/lib/components/{overlay/Overlay.js → side-overlay/SideOverlay.js} +16 -16
- package/lib/components/side-overlay/SideOverlay.stories.d.ts +16 -0
- package/lib/components/{overlay/Overlay.stories.js → side-overlay/SideOverlay.stories.js} +13 -13
- package/lib/components/slider/Slider.js +2 -1
- package/lib/components/sliding-panel/SlidingPanel.d.ts +19 -0
- package/lib/components/sliding-panel/SlidingPanel.js +217 -0
- package/lib/components/sliding-panel/SlidingPanel.stories.d.ts +16 -0
- package/lib/components/sliding-panel/SlidingPanel.stories.js +68 -0
- package/lib/components/toolbar/FloatingToolbar.js +2 -2
- package/lib/theme/colors/datalayerColors.d.ts +12 -0
- package/lib/theme/colors/datalayerColors.js +13 -0
- package/lib/theme/colors/earthColors.d.ts +12 -0
- package/lib/theme/colors/earthColors.js +13 -0
- package/lib/theme/colors/index.d.ts +3 -0
- package/lib/theme/colors/index.js +9 -0
- package/lib/theme/colors/ivoryColors.d.ts +46 -0
- package/lib/theme/colors/ivoryColors.js +56 -0
- package/lib/theme/colors/lovelyColors.d.ts +12 -0
- package/lib/theme/colors/lovelyColors.js +13 -0
- package/lib/theme/colors/matrixColors.d.ts +12 -0
- package/lib/theme/colors/matrixColors.js +13 -0
- package/lib/theme/colors/sandColors.d.ts +45 -0
- package/lib/theme/colors/sandColors.js +55 -0
- package/lib/theme/colors/spatialColors.d.ts +12 -0
- package/lib/theme/colors/spatialColors.js +13 -0
- package/lib/theme/colors/sunColors.d.ts +45 -0
- package/lib/theme/colors/sunColors.js +55 -0
- package/lib/theme/css/createThemeCSSVars.d.ts +25 -1
- package/lib/theme/css/createThemeCSSVars.js +63 -3
- package/lib/theme/index.d.ts +3 -0
- package/lib/theme/index.js +3 -0
- package/lib/theme/palettes/ColorPalette.js +121 -1
- package/lib/theme/themeRegistry.d.ts +1 -1
- package/lib/theme/themeRegistry.js +151 -1
- package/lib/theme/themes/datalayerTheme.js +58 -7
- package/lib/theme/themes/earthTheme.js +50 -0
- package/lib/theme/themes/ivoryTheme.d.ts +1091 -0
- package/lib/theme/themes/ivoryTheme.js +257 -0
- package/lib/theme/themes/lovelyTheme.js +58 -7
- package/lib/theme/themes/matrixTheme.js +57 -8
- package/lib/theme/themes/sandTheme.d.ts +1091 -0
- package/lib/theme/themes/sandTheme.js +256 -0
- package/lib/theme/themes/spatialTheme.js +58 -7
- package/lib/theme/themes/sunTheme.d.ts +1091 -0
- package/lib/theme/themes/sunTheme.js +257 -0
- package/lib/theme/useThemeStore.d.ts +5 -3
- package/lib/theme/useThemeStore.js +78 -9
- package/lib/utils/Helper.d.ts +1 -1
- package/lib/utils/Portals.d.ts +0 -1
- package/lib/utils/Portals.js +0 -1
- package/package.json +14 -8
- package/lib/App.d.ts +0 -13
- package/lib/App.js +0 -25
- package/lib/components/overlay/Overlay.stories.d.ts +0 -16
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Sun Theme for Primer React.
|
|
7
|
+
*
|
|
8
|
+
* Warm, radiant golden light with a deep amber accent — energetic,
|
|
9
|
+
* optimistic, and welcoming. Uses a friendly humanist-sans type stack
|
|
10
|
+
* for an approachable, cheerful feel.
|
|
11
|
+
* Theming is applied via **CSS custom-property overrides**.
|
|
12
|
+
*/
|
|
13
|
+
import { theme as primerTheme } from '@primer/react';
|
|
14
|
+
import { sunColors } from '../colors/sunColors';
|
|
15
|
+
import { buildThemeStyles } from '../css/createThemeCSSVars';
|
|
16
|
+
/* ── Light-mode colour definitions ───────────────────────────────────── */
|
|
17
|
+
const sunLight = {
|
|
18
|
+
canvas: {
|
|
19
|
+
default: sunColors.white,
|
|
20
|
+
subtle: '#FFF3D6',
|
|
21
|
+
},
|
|
22
|
+
fg: {
|
|
23
|
+
default: '#2A2210',
|
|
24
|
+
muted: sunColors.gray,
|
|
25
|
+
onEmphasis: '#FFFBF0',
|
|
26
|
+
},
|
|
27
|
+
accent: {
|
|
28
|
+
fg: sunColors.sunText,
|
|
29
|
+
emphasis: sunColors.sunText,
|
|
30
|
+
muted: sunColors.sunAccent,
|
|
31
|
+
subtle: sunColors.sunTint,
|
|
32
|
+
},
|
|
33
|
+
success: {
|
|
34
|
+
fg: '#3E6B47',
|
|
35
|
+
emphasis: '#3E6B47',
|
|
36
|
+
muted: '#5E8A5E',
|
|
37
|
+
subtle: '#E1EEE0',
|
|
38
|
+
},
|
|
39
|
+
attention: {
|
|
40
|
+
fg: sunColors.attentionBrand,
|
|
41
|
+
emphasis: sunColors.attentionBrand,
|
|
42
|
+
muted: sunColors.attentionAccent,
|
|
43
|
+
subtle: sunColors.attentionTint,
|
|
44
|
+
},
|
|
45
|
+
danger: {
|
|
46
|
+
fg: sunColors.dangerBrand,
|
|
47
|
+
emphasis: sunColors.dangerBrand,
|
|
48
|
+
muted: sunColors.dangerAccent,
|
|
49
|
+
subtle: sunColors.dangerTint,
|
|
50
|
+
},
|
|
51
|
+
severe: {
|
|
52
|
+
fg: sunColors.severeBrand,
|
|
53
|
+
emphasis: sunColors.severeBrand,
|
|
54
|
+
muted: sunColors.severeAccent,
|
|
55
|
+
subtle: sunColors.severeTint,
|
|
56
|
+
},
|
|
57
|
+
done: {
|
|
58
|
+
fg: sunColors.doneBrand,
|
|
59
|
+
emphasis: sunColors.doneBrand,
|
|
60
|
+
muted: sunColors.doneAccent,
|
|
61
|
+
subtle: sunColors.doneTint,
|
|
62
|
+
},
|
|
63
|
+
border: {
|
|
64
|
+
default: '#F0E2BE',
|
|
65
|
+
muted: '#F6ECCF',
|
|
66
|
+
},
|
|
67
|
+
btn: {
|
|
68
|
+
text: '#2A2210',
|
|
69
|
+
bg: '#FFFCF3',
|
|
70
|
+
border: '#EEDCB2',
|
|
71
|
+
hoverBg: sunColors.sunTint,
|
|
72
|
+
hoverBorder: sunColors.gray,
|
|
73
|
+
activeBg: sunColors.sunTint,
|
|
74
|
+
activeBorder: sunColors.gray,
|
|
75
|
+
selectedBg: '#FFFCF3',
|
|
76
|
+
counterBg: sunColors.gray,
|
|
77
|
+
primary: {
|
|
78
|
+
text: '#FFFBF0',
|
|
79
|
+
bg: sunColors.sunText,
|
|
80
|
+
border: sunColors.sunText,
|
|
81
|
+
hoverBg: sunColors.sunHover,
|
|
82
|
+
hoverBorder: sunColors.sunHover,
|
|
83
|
+
selectedBg: sunColors.sunHover,
|
|
84
|
+
disabledText: 'rgba(255, 255, 255, 0.8)',
|
|
85
|
+
disabledBg: '#E0BE73',
|
|
86
|
+
disabledBorder: '#E0BE73',
|
|
87
|
+
icon: '#FFFBF0',
|
|
88
|
+
counterBg: 'rgba(0, 0, 0, 0.2)',
|
|
89
|
+
},
|
|
90
|
+
outline: {
|
|
91
|
+
text: sunColors.sunText,
|
|
92
|
+
hoverText: '#FFFBF0',
|
|
93
|
+
hoverBg: sunColors.sunText,
|
|
94
|
+
hoverBorder: sunColors.sunText,
|
|
95
|
+
hoverCounterBg: 'rgba(255, 255, 255, 0.2)',
|
|
96
|
+
selectedText: '#FFFBF0',
|
|
97
|
+
selectedBg: sunColors.sunHover,
|
|
98
|
+
selectedBorder: sunColors.sunHover,
|
|
99
|
+
disabledText: sunColors.gray,
|
|
100
|
+
disabledBg: sunColors.sunTint,
|
|
101
|
+
disabledCounterBg: 'rgba(0, 0, 0, 0.05)',
|
|
102
|
+
counterBg: 'rgba(0, 0, 0, 0.05)',
|
|
103
|
+
counterFg: sunColors.sunText,
|
|
104
|
+
hoverCounterFg: '#FFFBF0',
|
|
105
|
+
disabledCounterFg: sunColors.gray,
|
|
106
|
+
},
|
|
107
|
+
danger: {
|
|
108
|
+
text: '#B42318',
|
|
109
|
+
hoverText: '#FFFBF0',
|
|
110
|
+
hoverBg: '#B42318',
|
|
111
|
+
hoverBorder: '#B42318',
|
|
112
|
+
hoverCounterBg: 'rgba(255, 255, 255, 0.2)',
|
|
113
|
+
selectedText: '#FFFBF0',
|
|
114
|
+
selectedBg: '#8E1B12',
|
|
115
|
+
selectedBorder: '#8E1B12',
|
|
116
|
+
disabledText: 'rgba(180, 35, 24, 0.5)',
|
|
117
|
+
disabledBg: sunColors.sunTint,
|
|
118
|
+
disabledCounterBg: 'rgba(180, 35, 24, 0.05)',
|
|
119
|
+
counterBg: 'rgba(180, 35, 24, 0.1)',
|
|
120
|
+
counterFg: '#B42318',
|
|
121
|
+
hoverCounterFg: '#FFFBF0',
|
|
122
|
+
disabledCounterFg: 'rgba(180, 35, 24, 0.5)',
|
|
123
|
+
icon: '#B42318',
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
/* ── Dark-mode colour definitions ────────────────────────────────────── */
|
|
128
|
+
const sunDark = {
|
|
129
|
+
canvas: {
|
|
130
|
+
default: sunColors.black,
|
|
131
|
+
subtle: '#2A2109',
|
|
132
|
+
},
|
|
133
|
+
fg: {
|
|
134
|
+
default: '#F3E9CF',
|
|
135
|
+
muted: '#BEAC82',
|
|
136
|
+
onEmphasis: '#FFFBF0',
|
|
137
|
+
},
|
|
138
|
+
accent: {
|
|
139
|
+
fg: sunColors.sunBright,
|
|
140
|
+
emphasis: '#8A6E00',
|
|
141
|
+
muted: sunColors.sunBrand,
|
|
142
|
+
subtle: '#33290C',
|
|
143
|
+
},
|
|
144
|
+
success: {
|
|
145
|
+
fg: '#7CB07E',
|
|
146
|
+
emphasis: '#3E6B47',
|
|
147
|
+
muted: '#5E8A5E',
|
|
148
|
+
subtle: '#16261A',
|
|
149
|
+
},
|
|
150
|
+
attention: {
|
|
151
|
+
fg: '#E7C24E',
|
|
152
|
+
emphasis: '#8A6D08',
|
|
153
|
+
muted: sunColors.attentionAccent,
|
|
154
|
+
subtle: '#2E2606',
|
|
155
|
+
},
|
|
156
|
+
danger: {
|
|
157
|
+
fg: '#F08A70',
|
|
158
|
+
emphasis: '#B23A1E',
|
|
159
|
+
muted: sunColors.dangerAccent,
|
|
160
|
+
subtle: '#2E140E',
|
|
161
|
+
},
|
|
162
|
+
severe: {
|
|
163
|
+
fg: '#E6A566',
|
|
164
|
+
emphasis: '#A85D0C',
|
|
165
|
+
muted: sunColors.severeAccent,
|
|
166
|
+
subtle: '#2E1D0A',
|
|
167
|
+
},
|
|
168
|
+
done: {
|
|
169
|
+
fg: '#B09AD0',
|
|
170
|
+
emphasis: '#6A4E9E',
|
|
171
|
+
muted: sunColors.doneAccent,
|
|
172
|
+
subtle: '#1F1830',
|
|
173
|
+
},
|
|
174
|
+
btn: {
|
|
175
|
+
text: '#F3E9CF',
|
|
176
|
+
bg: '#2E2509',
|
|
177
|
+
border: 'rgba(243, 233, 207, 0.12)',
|
|
178
|
+
hoverBg: '#3A2F0D',
|
|
179
|
+
hoverBorder: '#BEAC82',
|
|
180
|
+
activeBg: '#2E2509',
|
|
181
|
+
activeBorder: '#8C7C4A',
|
|
182
|
+
selectedBg: '#241D07',
|
|
183
|
+
counterBg: '#3A2F0D',
|
|
184
|
+
primary: {
|
|
185
|
+
text: '#211A08',
|
|
186
|
+
bg: sunColors.sunBright,
|
|
187
|
+
border: 'rgba(243, 233, 207, 0.12)',
|
|
188
|
+
hoverBg: sunColors.sunAccent,
|
|
189
|
+
hoverBorder: 'rgba(243, 233, 207, 0.12)',
|
|
190
|
+
selectedBg: sunColors.sunAccent,
|
|
191
|
+
disabledText: 'rgba(33, 26, 8, 0.5)',
|
|
192
|
+
disabledBg: 'rgba(255, 213, 74, 0.35)',
|
|
193
|
+
disabledBorder: 'rgba(255, 213, 74, 0.2)',
|
|
194
|
+
icon: '#211A08',
|
|
195
|
+
counterBg: 'rgba(0, 0, 0, 0.2)',
|
|
196
|
+
},
|
|
197
|
+
outline: {
|
|
198
|
+
text: sunColors.sunBright,
|
|
199
|
+
hoverText: '#211A08',
|
|
200
|
+
hoverBg: sunColors.sunBright,
|
|
201
|
+
hoverBorder: sunColors.sunBright,
|
|
202
|
+
hoverCounterBg: 'rgba(0, 0, 0, 0.2)',
|
|
203
|
+
selectedText: '#211A08',
|
|
204
|
+
selectedBg: sunColors.sunAccent,
|
|
205
|
+
selectedBorder: sunColors.sunAccent,
|
|
206
|
+
disabledText: 'rgba(255, 213, 74, 0.5)',
|
|
207
|
+
disabledBg: 'rgba(255, 213, 74, 0.1)',
|
|
208
|
+
disabledCounterBg: 'rgba(255, 213, 74, 0.05)',
|
|
209
|
+
counterBg: 'rgba(255, 213, 74, 0.1)',
|
|
210
|
+
counterFg: sunColors.sunBright,
|
|
211
|
+
hoverCounterFg: '#211A08',
|
|
212
|
+
disabledCounterFg: 'rgba(255, 213, 74, 0.5)',
|
|
213
|
+
},
|
|
214
|
+
danger: {
|
|
215
|
+
text: '#f85149',
|
|
216
|
+
hoverText: '#FFFBF0',
|
|
217
|
+
hoverBg: '#da3633',
|
|
218
|
+
hoverBorder: '#f85149',
|
|
219
|
+
hoverCounterBg: 'rgba(255, 255, 255, 0.2)',
|
|
220
|
+
selectedText: '#FFFBF0',
|
|
221
|
+
selectedBg: '#b62324',
|
|
222
|
+
selectedBorder: '#ff7b72',
|
|
223
|
+
disabledText: 'rgba(248, 81, 73, 0.5)',
|
|
224
|
+
disabledBg: 'rgba(248, 81, 73, 0.1)',
|
|
225
|
+
disabledCounterBg: 'rgba(248, 81, 73, 0.05)',
|
|
226
|
+
counterBg: 'rgba(248, 81, 73, 0.1)',
|
|
227
|
+
counterFg: '#f85149',
|
|
228
|
+
hoverCounterFg: '#FFFBF0',
|
|
229
|
+
disabledCounterFg: 'rgba(248, 81, 73, 0.5)',
|
|
230
|
+
icon: '#f85149',
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
/* ── Exports ─────────────────────────────────────────────────────────── */
|
|
235
|
+
/**
|
|
236
|
+
* The Primer theme object.
|
|
237
|
+
*
|
|
238
|
+
* Since theming is done entirely via CSS custom properties
|
|
239
|
+
* (see `sunThemeStyles`), this is just the unmodified default Primer
|
|
240
|
+
* theme kept for backward compatibility.
|
|
241
|
+
*/
|
|
242
|
+
export const sunTheme = primerTheme;
|
|
243
|
+
/**
|
|
244
|
+
* Friendly humanist-sans font stack for the Sun aesthetic.
|
|
245
|
+
*
|
|
246
|
+
* Leads with warm geometric-humanist sans-serifs (Avenir / Segoe UI /
|
|
247
|
+
* Ubuntu / Cantarell) for an approachable, optimistic feel, with
|
|
248
|
+
* cross-platform fallbacks across macOS / Windows / Linux so it renders
|
|
249
|
+
* consistently everywhere without web-font loading (same no-download
|
|
250
|
+
* approach as the Matrix monospace stack).
|
|
251
|
+
*/
|
|
252
|
+
const sunFontFamily = '"Avenir Next", Avenir, "Segoe UI", Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif';
|
|
253
|
+
/** Comprehensive Primer CSS-variable overrides for light & dark mode. */
|
|
254
|
+
export const sunThemeStyles = buildThemeStyles(sunLight, sunDark, {
|
|
255
|
+
fontFamily: sunFontFamily,
|
|
256
|
+
});
|
|
257
|
+
export default sunTheme;
|
|
@@ -22,11 +22,13 @@
|
|
|
22
22
|
import { type StoreApi, type UseBoundStore } from 'zustand';
|
|
23
23
|
import type { ThemeVariant } from './themeRegistry';
|
|
24
24
|
import type { ColorMode } from './DatalayerBrandThemeProvider';
|
|
25
|
-
|
|
26
|
-
export type VariantDefaults = Record<string, {
|
|
25
|
+
export type VariantPreference = {
|
|
27
26
|
theme: ThemeVariant;
|
|
28
27
|
colorMode: ColorMode;
|
|
29
|
-
|
|
28
|
+
version?: number;
|
|
29
|
+
};
|
|
30
|
+
/** Per-variant theme + colorMode preferences. */
|
|
31
|
+
export type VariantDefaults = Record<string, VariantPreference>;
|
|
30
32
|
export interface ThemeState {
|
|
31
33
|
/** Current color mode (light, dark, or auto = follow OS). */
|
|
32
34
|
colorMode: ColorMode;
|
|
@@ -26,6 +26,33 @@
|
|
|
26
26
|
import { create } from 'zustand';
|
|
27
27
|
import { persist, createJSONStorage } from 'zustand/middleware';
|
|
28
28
|
import { themeConfigs } from './themeRegistry';
|
|
29
|
+
const VARIANT_SCHEMA_VERSION = 1;
|
|
30
|
+
function normalizeVariantPreference(pref) {
|
|
31
|
+
return {
|
|
32
|
+
theme: pref.theme,
|
|
33
|
+
colorMode: pref.colorMode,
|
|
34
|
+
version: typeof pref.version === 'number' ? pref.version : VARIANT_SCHEMA_VERSION,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function normalizeVariants(variants) {
|
|
38
|
+
if (!variants) {
|
|
39
|
+
return {};
|
|
40
|
+
}
|
|
41
|
+
const normalized = {};
|
|
42
|
+
for (const [key, pref] of Object.entries(variants)) {
|
|
43
|
+
if (!pref || typeof pref !== 'object' || !('theme' in pref) || !('colorMode' in pref)) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
normalized[key] = normalizeVariantPreference(pref);
|
|
47
|
+
}
|
|
48
|
+
return normalized;
|
|
49
|
+
}
|
|
50
|
+
function hasMissingVariantVersion(variants) {
|
|
51
|
+
if (!variants || Object.keys(variants).length === 0) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
return Object.values(variants).some(pref => typeof pref?.version !== 'number');
|
|
55
|
+
}
|
|
29
56
|
/* ── Helpers ─────────────────────────────────────────────────────── */
|
|
30
57
|
const colorModeCycle = {
|
|
31
58
|
light: 'dark',
|
|
@@ -49,7 +76,7 @@ export function createThemeStore(storageKey, defaults) {
|
|
|
49
76
|
theme: defaults?.theme ?? 'matrix',
|
|
50
77
|
/* ── variant state ──────────────────────────────────── */
|
|
51
78
|
activeVariant: null,
|
|
52
|
-
variants: defaults?.variants
|
|
79
|
+
variants: normalizeVariants(defaults?.variants),
|
|
53
80
|
/* ── actions ────────────────────────────────────────── */
|
|
54
81
|
toggleColorMode: () => set(state => {
|
|
55
82
|
const next = colorModeCycle[state.colorMode];
|
|
@@ -58,7 +85,11 @@ export function createThemeStore(storageKey, defaults) {
|
|
|
58
85
|
colorMode: next,
|
|
59
86
|
variants: {
|
|
60
87
|
...state.variants,
|
|
61
|
-
[state.activeVariant]: {
|
|
88
|
+
[state.activeVariant]: {
|
|
89
|
+
...state.variants[state.activeVariant],
|
|
90
|
+
colorMode: next,
|
|
91
|
+
version: VARIANT_SCHEMA_VERSION,
|
|
92
|
+
},
|
|
62
93
|
},
|
|
63
94
|
};
|
|
64
95
|
}
|
|
@@ -70,7 +101,11 @@ export function createThemeStore(storageKey, defaults) {
|
|
|
70
101
|
colorMode: mode,
|
|
71
102
|
variants: {
|
|
72
103
|
...state.variants,
|
|
73
|
-
[state.activeVariant]: {
|
|
104
|
+
[state.activeVariant]: {
|
|
105
|
+
...state.variants[state.activeVariant],
|
|
106
|
+
colorMode: mode,
|
|
107
|
+
version: VARIANT_SCHEMA_VERSION,
|
|
108
|
+
},
|
|
74
109
|
},
|
|
75
110
|
};
|
|
76
111
|
}
|
|
@@ -86,7 +121,11 @@ export function createThemeStore(storageKey, defaults) {
|
|
|
86
121
|
colorMode: nextColorMode,
|
|
87
122
|
variants: {
|
|
88
123
|
...state.variants,
|
|
89
|
-
[state.activeVariant]: {
|
|
124
|
+
[state.activeVariant]: {
|
|
125
|
+
theme,
|
|
126
|
+
colorMode: nextColorMode,
|
|
127
|
+
version: VARIANT_SCHEMA_VERSION,
|
|
128
|
+
},
|
|
90
129
|
},
|
|
91
130
|
};
|
|
92
131
|
}
|
|
@@ -96,7 +135,13 @@ export function createThemeStore(storageKey, defaults) {
|
|
|
96
135
|
const merged = { ...state.variants };
|
|
97
136
|
for (const [key, val] of Object.entries(defs)) {
|
|
98
137
|
if (!merged[key]) {
|
|
99
|
-
merged[key] = val;
|
|
138
|
+
merged[key] = normalizeVariantPreference(val);
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
merged[key] = normalizeVariantPreference({
|
|
142
|
+
...merged[key],
|
|
143
|
+
version: merged[key].version ?? VARIANT_SCHEMA_VERSION,
|
|
144
|
+
});
|
|
100
145
|
}
|
|
101
146
|
}
|
|
102
147
|
return { variants: merged };
|
|
@@ -114,7 +159,7 @@ export function createThemeStore(storageKey, defaults) {
|
|
|
114
159
|
}),
|
|
115
160
|
}), {
|
|
116
161
|
name: storageKey,
|
|
117
|
-
version:
|
|
162
|
+
version: 3,
|
|
118
163
|
storage: createJSONStorage(() => localStorage),
|
|
119
164
|
partialize: state => ({
|
|
120
165
|
colorMode: state.colorMode,
|
|
@@ -127,7 +172,31 @@ export function createThemeStore(storageKey, defaults) {
|
|
|
127
172
|
* value the persisted state is discarded and the store starts fresh
|
|
128
173
|
* from code-defined defaults.
|
|
129
174
|
*/
|
|
130
|
-
migrate:
|
|
175
|
+
migrate: persisted => {
|
|
176
|
+
const p = (persisted ?? {});
|
|
177
|
+
const legacyVariants = p.variants;
|
|
178
|
+
const missingVariantVersion = hasMissingVariantVersion(legacyVariants);
|
|
179
|
+
const variants = normalizeVariants(legacyVariants);
|
|
180
|
+
// Legacy snapshots without per-variant versions are upgraded to v1.
|
|
181
|
+
// Anonymous defaults are forced to matrix/dark during this upgrade.
|
|
182
|
+
if (missingVariantVersion) {
|
|
183
|
+
variants['agent-anonymous'] = {
|
|
184
|
+
theme: 'matrix',
|
|
185
|
+
colorMode: 'dark',
|
|
186
|
+
version: VARIANT_SCHEMA_VERSION,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
...p,
|
|
191
|
+
variants,
|
|
192
|
+
...(missingVariantVersion
|
|
193
|
+
? {
|
|
194
|
+
theme: p.activeVariant === 'agent-anonymous' ? 'matrix' : p.theme,
|
|
195
|
+
colorMode: p.activeVariant === 'agent-anonymous' ? 'dark' : p.colorMode,
|
|
196
|
+
}
|
|
197
|
+
: {}),
|
|
198
|
+
};
|
|
199
|
+
},
|
|
131
200
|
/**
|
|
132
201
|
* Deep-merge variants during hydration so that:
|
|
133
202
|
* - Code-defined variants (from defaults or registerVariants) are
|
|
@@ -139,11 +208,11 @@ export function createThemeStore(storageKey, defaults) {
|
|
|
139
208
|
const p = (persisted ?? {});
|
|
140
209
|
// Build merged variants: start from code-defined, then overlay
|
|
141
210
|
// any persisted variant whose prefs differ (user customisations).
|
|
142
|
-
const mergedVariants =
|
|
211
|
+
const mergedVariants = normalizeVariants(current.variants);
|
|
143
212
|
if (p.variants) {
|
|
144
213
|
for (const [key, val] of Object.entries(p.variants)) {
|
|
145
214
|
if (val && typeof val === 'object' && 'theme' in val) {
|
|
146
|
-
mergedVariants[key] = val;
|
|
215
|
+
mergedVariants[key] = normalizeVariantPreference(val);
|
|
147
216
|
}
|
|
148
217
|
}
|
|
149
218
|
}
|
package/lib/utils/Helper.d.ts
CHANGED
package/lib/utils/Portals.d.ts
CHANGED
package/lib/utils/Portals.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
5
|
import { registerPortalRoot } from '@primer/react';
|
|
6
|
-
import '@primer/react-brand/lib/css/main.css';
|
|
7
6
|
const PRIMER_PORTAL_ROOT_ID = '__primerPortalRoot__';
|
|
8
7
|
/**
|
|
9
8
|
* Key used on `document.body` to track the CSS-property names we
|
package/package.json
CHANGED
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datalayer/primer-addons",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.19",
|
|
4
4
|
"license": "BSD-3-Clause",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"build": "
|
|
6
|
+
"build": "npm run build:lib",
|
|
7
7
|
"build-storybook": "storybook build",
|
|
8
8
|
"build:lib": "npm run clean:lib&& tsc -b",
|
|
9
9
|
"clean:lib": "rimraf lib tsconfig.tsbuildinfo",
|
|
10
|
-
"dev": "
|
|
10
|
+
"dev": "npm run gallery",
|
|
11
|
+
"gallery": "npm --prefix examples/gallery run dev",
|
|
12
|
+
"gallery:build": "npm --prefix examples/gallery run build",
|
|
11
13
|
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
12
|
-
"preview": "
|
|
13
|
-
"start": "
|
|
14
|
+
"preview": "npm --prefix examples/gallery run preview",
|
|
15
|
+
"start": "npm run gallery",
|
|
14
16
|
"storybook": "storybook dev -p 6006",
|
|
15
17
|
"watch": "tsc -w",
|
|
16
18
|
"watch:lib": "tsc -b -w"
|
|
17
19
|
},
|
|
18
20
|
"main": "lib/index.js",
|
|
21
|
+
"sideEffects": [
|
|
22
|
+
"*.css",
|
|
23
|
+
"**/*.css"
|
|
24
|
+
],
|
|
19
25
|
"files": [
|
|
20
26
|
"lib",
|
|
21
27
|
"style"
|
|
@@ -27,9 +33,9 @@
|
|
|
27
33
|
"homepage": "https://primer-addons.datalayer.tech",
|
|
28
34
|
"dependencies": {
|
|
29
35
|
"@datalayer/icons-react": "^1.0.0",
|
|
30
|
-
"@primer/octicons-react": "^19.
|
|
31
|
-
"@primer/primitives": "^10.
|
|
32
|
-
"@primer/react": "^37.
|
|
36
|
+
"@primer/octicons-react": "^19.29.1",
|
|
37
|
+
"@primer/primitives": "^10.7.0",
|
|
38
|
+
"@primer/react": "^37.31.0",
|
|
33
39
|
"react": "^18.3.1 || ^19.0.0",
|
|
34
40
|
"react-dom": "^18.3.1 || ^19.0.0",
|
|
35
41
|
"react-loading-skeleton": "^3.5.0",
|
package/lib/App.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import "@primer/primitives/dist/css/base/typography/typography.css";
|
|
2
|
-
import "@primer/primitives/dist/css/base/motion/motion.css";
|
|
3
|
-
import "@primer/primitives/dist/css/functional/themes/light.css";
|
|
4
|
-
import "@primer/primitives/dist/css/functional/size/border.css";
|
|
5
|
-
import "@primer/primitives/dist/css/functional/size/breakpoints.css";
|
|
6
|
-
import "@primer/primitives/dist/css/functional/size/size-coarse.css";
|
|
7
|
-
import "@primer/primitives/dist/css/functional/size/size-fine.css";
|
|
8
|
-
import "@primer/primitives/dist/css/functional/size/size.css";
|
|
9
|
-
import "@primer/primitives/dist/css/functional/size/viewport.css";
|
|
10
|
-
import "@primer/primitives/dist/css/functional/typography/typography.css";
|
|
11
|
-
import "./App.css";
|
|
12
|
-
declare const App: () => import("react/jsx-runtime").JSX.Element;
|
|
13
|
-
export default App;
|
package/lib/App.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useState, useRef } from "react";
|
|
3
|
-
import { BaseStyles, Box, Text, NavList, Heading, ThemeProvider, Button, theme, ActionMenu, IconButton, ActionList } from "@primer/react";
|
|
4
|
-
import { KebabHorizontalIcon } from "@primer/octicons-react";
|
|
5
|
-
import { DatalayerIcon, LogOutIcon, SettingsIcon } from "@datalayer/icons-react";
|
|
6
|
-
import { Slider, Overlay } from ".";
|
|
7
|
-
import "@primer/primitives/dist/css/base/typography/typography.css";
|
|
8
|
-
import "@primer/primitives/dist/css/base/motion/motion.css";
|
|
9
|
-
import "@primer/primitives/dist/css/functional/themes/light.css";
|
|
10
|
-
import "@primer/primitives/dist/css/functional/size/border.css";
|
|
11
|
-
import "@primer/primitives/dist/css/functional/size/breakpoints.css";
|
|
12
|
-
import "@primer/primitives/dist/css/functional/size/size-coarse.css";
|
|
13
|
-
import "@primer/primitives/dist/css/functional/size/size-fine.css";
|
|
14
|
-
import "@primer/primitives/dist/css/functional/size/size.css";
|
|
15
|
-
import "@primer/primitives/dist/css/functional/size/viewport.css";
|
|
16
|
-
import "@primer/primitives/dist/css/functional/typography/typography.css";
|
|
17
|
-
import "./App.css";
|
|
18
|
-
const App = () => {
|
|
19
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
20
|
-
const openButtonRef = useRef(null);
|
|
21
|
-
const closeButtonRef = useRef(null);
|
|
22
|
-
const headingRef = useRef(null);
|
|
23
|
-
return (_jsx(ThemeProvider, { colorMode: "day", theme: theme, children: _jsxs(BaseStyles, { children: [_jsxs(ActionMenu, { children: [_jsx(ActionMenu.Anchor, { children: _jsx(IconButton, { icon: KebabHorizontalIcon, variant: "invisible", "aria-label": "jupyter-runtimes-more" }) }), _jsx(ActionMenu.Overlay, { width: "medium", children: _jsxs(ActionList, { children: [_jsxs(ActionList.Group, { children: [_jsx(ActionList.GroupHeading, { children: "More\u2026" }), _jsxs(ActionList.Item, { onSelect: () => alert('click'), children: [_jsx(ActionList.LeadingVisual, { children: _jsx(SettingsIcon, {}) }), "Settings", _jsx(ActionList.Description, { variant: "block", children: "Configure your personal settings." })] }), _jsxs(ActionList.Item, { onSelect: () => alert('click'), children: [_jsx(ActionList.LeadingVisual, { children: _jsx(DatalayerIcon, {}) }), "About", _jsx(ActionList.Description, { variant: "block", children: "About Runtimes." })] })] }), _jsxs(_Fragment, { children: [_jsx(ActionList.Divider, {}), _jsxs(ActionList.Item, { variant: "danger", onSelect: () => alert('click'), children: [_jsx(ActionList.LeadingVisual, { children: _jsx(LogOutIcon, {}) }), "Logout"] })] })] }) })] }), _jsxs(Box, { bg: "canvas.default", sx: { display: 'flex' }, children: [_jsx(Box, { children: _jsxs(NavList, { children: [_jsx(NavList.Item, { href: "/", "aria-current": "page", children: "Home" }), _jsx(NavList.Item, { href: "/about", children: "About" }), _jsx(NavList.Item, { href: "/contact", children: "Contact" })] }) }), _jsxs(Box, { p: 3, sx: { flexGrow: 1 }, children: [_jsx(Box, { children: _jsx(Text, { children: "Primer React Addons" }) }), _jsx(Box, { children: _jsx(Slider, { id: "slider", name: "slider", min: 1, max: 10, onChange: () => { } }) }), _jsx(Box, { p: 3, bg: "canvas.default", children: _jsxs(Box, { children: [_jsx(Box, { sx: { width: '100%', bg: 'darkgray' }, children: _jsx(Heading, { ref: headingRef, children: "Header" }) }), _jsxs(Box, { children: [_jsx(Button, { ref: openButtonRef, onClick: () => { setIsOpen(!isOpen); }, children: "Open overlay" }), _jsx(Overlay, { isOpen: isOpen, content: _jsxs(Text, { children: ["Look, I am an ", _jsx(Button, { children: "Overlay \uD83D\uDC49" })] }), setIsOpen: setIsOpen, openButtonRef: openButtonRef, closeButtonRef: closeButtonRef, headingRef: headingRef })] })] }) })] })] })] }) }));
|
|
24
|
-
};
|
|
25
|
-
export default App;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { StoryObj } from '@storybook/react';
|
|
2
|
-
import { OverlayProps } from '../..';
|
|
3
|
-
declare const meta: {
|
|
4
|
-
title: string;
|
|
5
|
-
component: ({ width, direction, zIndex, ...rest }: OverlayProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
-
tags: string[];
|
|
7
|
-
parameters: {
|
|
8
|
-
layout: string;
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
export default meta;
|
|
12
|
-
type Story = StoryObj<typeof meta>;
|
|
13
|
-
export declare const OverlayDayLeft: Story;
|
|
14
|
-
export declare const OverlayDayRight: Story;
|
|
15
|
-
export declare const OverlayNightLeft: Story;
|
|
16
|
-
export declare const OverlayNightRight: Story;
|