@datalayer/primer-addons 1.0.11 → 1.0.13
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/App.d.ts +1 -0
- package/lib/App.js +1 -0
- package/lib/components/appearance/AppearanceControls.d.ts +10 -0
- package/lib/components/appearance/AppearanceControls.js +42 -0
- package/lib/components/appearance/AppearanceControlsWithStore.d.ts +8 -0
- package/lib/{theme/ThemeSwitcher.js → components/appearance/AppearanceControlsWithStore.js} +5 -3
- package/lib/components/appearance/index.d.ts +2 -0
- package/lib/components/appearance/index.js +6 -0
- package/lib/components/index.d.ts +4 -0
- package/lib/components/index.js +4 -0
- package/lib/components/logo/DatalayerLogo.d.ts +39 -0
- package/lib/components/logo/DatalayerLogo.js +116 -0
- package/lib/components/logo/DatalayerLogoText.d.ts +30 -0
- package/lib/components/logo/DatalayerLogoText.js +30 -0
- package/lib/components/logo/DatalayerText.d.ts +22 -0
- package/lib/components/logo/DatalayerText.js +21 -0
- package/lib/components/logo/index.d.ts +3 -0
- package/lib/components/logo/index.js +3 -0
- package/lib/index.js +0 -1
- package/lib/theme/colors/datalayerColors.js +1 -1
- package/lib/theme/colors/earthColors.d.ts +39 -0
- package/lib/theme/colors/earthColors.js +51 -0
- package/lib/theme/colors/index.d.ts +14 -0
- package/lib/theme/colors/index.js +24 -0
- package/lib/theme/colors/indicatorColors.d.ts +50 -0
- package/lib/theme/colors/indicatorColors.js +68 -0
- package/lib/theme/index.d.ts +1 -2
- package/lib/theme/index.js +1 -2
- package/lib/theme/themeRegistry.d.ts +1 -1
- package/lib/theme/themeRegistry.js +51 -1
- package/lib/theme/themes/datalayerTheme.d.ts +0 -2
- package/lib/theme/themes/datalayerTheme.js +0 -2
- package/lib/theme/themes/earthTheme.d.ts +1091 -0
- package/lib/theme/themes/earthTheme.js +193 -0
- package/lib/theme/themes/lovelyTheme.d.ts +0 -2
- package/lib/theme/themes/lovelyTheme.js +0 -2
- package/lib/theme/themes/matrixTheme.d.ts +0 -2
- package/lib/theme/themes/matrixTheme.js +0 -2
- package/lib/theme/themes/spatialTheme.d.ts +0 -2
- package/lib/theme/themes/spatialTheme.js +0 -2
- package/lib/theme/useThemeStore.d.ts +0 -1
- package/lib/utils/Portals.d.ts +4 -0
- package/lib/utils/Portals.js +61 -9
- package/package.json +1 -1
- package/lib/_utils/story-helpers.d.ts +0 -31
- package/lib/_utils/story-helpers.js +0 -105
- package/lib/theme/Palette.d.ts +0 -4
- package/lib/theme/Palette.js +0 -10
- package/lib/theme/ThemeSwitcher.d.ts +0 -17
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Earth Theme for Primer React.
|
|
7
|
+
*
|
|
8
|
+
* Ocean blues (sea), forest greens (plants), golden yellows (sun) —
|
|
9
|
+
* the Blue Planet, inspired by satellite observations of Earth.
|
|
10
|
+
* Theming is applied via **CSS custom-property overrides**.
|
|
11
|
+
*/
|
|
12
|
+
import { theme as primerTheme } from '@primer/react';
|
|
13
|
+
import { earthColors } from '../colors/earthColors';
|
|
14
|
+
import { buildThemeStyles } from './createThemeCSSVars';
|
|
15
|
+
/* ── Light-mode colour definitions ───────────────────────────────────── */
|
|
16
|
+
const earthLight = {
|
|
17
|
+
canvas: {
|
|
18
|
+
default: earthColors.white,
|
|
19
|
+
},
|
|
20
|
+
fg: {
|
|
21
|
+
default: '#1A2332',
|
|
22
|
+
muted: earthColors.gray,
|
|
23
|
+
onEmphasis: earthColors.white,
|
|
24
|
+
},
|
|
25
|
+
accent: {
|
|
26
|
+
fg: earthColors.oceanText,
|
|
27
|
+
emphasis: earthColors.oceanBrand,
|
|
28
|
+
muted: earthColors.oceanAccent,
|
|
29
|
+
},
|
|
30
|
+
success: {
|
|
31
|
+
fg: earthColors.forestBrand,
|
|
32
|
+
emphasis: earthColors.forestBrand,
|
|
33
|
+
muted: earthColors.forestAccent,
|
|
34
|
+
},
|
|
35
|
+
border: {
|
|
36
|
+
default: '#C1D0DD',
|
|
37
|
+
muted: '#DAE4ED',
|
|
38
|
+
},
|
|
39
|
+
btn: {
|
|
40
|
+
text: '#1A2332',
|
|
41
|
+
bg: earthColors.white,
|
|
42
|
+
border: '#A8BDD0',
|
|
43
|
+
hoverBg: earthColors.oceanTint,
|
|
44
|
+
hoverBorder: earthColors.gray,
|
|
45
|
+
activeBg: earthColors.oceanTint,
|
|
46
|
+
activeBorder: earthColors.gray,
|
|
47
|
+
selectedBg: earthColors.white,
|
|
48
|
+
counterBg: earthColors.gray,
|
|
49
|
+
primary: {
|
|
50
|
+
text: earthColors.white,
|
|
51
|
+
bg: earthColors.oceanText,
|
|
52
|
+
border: earthColors.oceanText,
|
|
53
|
+
hoverBg: earthColors.oceanHover,
|
|
54
|
+
hoverBorder: earthColors.oceanHover,
|
|
55
|
+
selectedBg: earthColors.oceanHover,
|
|
56
|
+
disabledText: 'rgba(255, 255, 255, 0.8)',
|
|
57
|
+
disabledBg: '#7DB8D8',
|
|
58
|
+
disabledBorder: '#7DB8D8',
|
|
59
|
+
icon: earthColors.white,
|
|
60
|
+
counterBg: 'rgba(0, 0, 0, 0.2)',
|
|
61
|
+
},
|
|
62
|
+
outline: {
|
|
63
|
+
text: earthColors.oceanText,
|
|
64
|
+
hoverText: earthColors.white,
|
|
65
|
+
hoverBg: earthColors.oceanText,
|
|
66
|
+
hoverBorder: earthColors.oceanText,
|
|
67
|
+
hoverCounterBg: 'rgba(255, 255, 255, 0.2)',
|
|
68
|
+
selectedText: earthColors.white,
|
|
69
|
+
selectedBg: earthColors.oceanHover,
|
|
70
|
+
selectedBorder: earthColors.oceanHover,
|
|
71
|
+
disabledText: earthColors.gray,
|
|
72
|
+
disabledBg: earthColors.oceanTint,
|
|
73
|
+
disabledCounterBg: 'rgba(0, 0, 0, 0.05)',
|
|
74
|
+
counterBg: 'rgba(0, 0, 0, 0.05)',
|
|
75
|
+
counterFg: earthColors.oceanText,
|
|
76
|
+
hoverCounterFg: earthColors.white,
|
|
77
|
+
disabledCounterFg: earthColors.gray,
|
|
78
|
+
},
|
|
79
|
+
danger: {
|
|
80
|
+
text: '#d32f2f',
|
|
81
|
+
hoverText: earthColors.white,
|
|
82
|
+
hoverBg: '#d32f2f',
|
|
83
|
+
hoverBorder: '#d32f2f',
|
|
84
|
+
hoverCounterBg: 'rgba(255, 255, 255, 0.2)',
|
|
85
|
+
selectedText: earthColors.white,
|
|
86
|
+
selectedBg: '#b71c1c',
|
|
87
|
+
selectedBorder: '#b71c1c',
|
|
88
|
+
disabledText: 'rgba(211, 47, 47, 0.5)',
|
|
89
|
+
disabledBg: earthColors.oceanTint,
|
|
90
|
+
disabledCounterBg: 'rgba(211, 47, 47, 0.05)',
|
|
91
|
+
counterBg: 'rgba(211, 47, 47, 0.1)',
|
|
92
|
+
counterFg: '#d32f2f',
|
|
93
|
+
hoverCounterFg: earthColors.white,
|
|
94
|
+
disabledCounterFg: 'rgba(211, 47, 47, 0.5)',
|
|
95
|
+
icon: '#d32f2f',
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
/* ── Dark-mode colour definitions ────────────────────────────────────── */
|
|
100
|
+
const earthDark = {
|
|
101
|
+
canvas: {
|
|
102
|
+
default: earthColors.black,
|
|
103
|
+
subtle: '#0E1D30',
|
|
104
|
+
},
|
|
105
|
+
fg: {
|
|
106
|
+
default: '#D4E4DC',
|
|
107
|
+
muted: '#8A9BA8',
|
|
108
|
+
onEmphasis: earthColors.white,
|
|
109
|
+
},
|
|
110
|
+
accent: {
|
|
111
|
+
fg: earthColors.oceanAccent,
|
|
112
|
+
emphasis: earthColors.oceanBright,
|
|
113
|
+
muted: earthColors.oceanBrand,
|
|
114
|
+
subtle: '#0C2440',
|
|
115
|
+
},
|
|
116
|
+
success: {
|
|
117
|
+
fg: earthColors.forestAccent,
|
|
118
|
+
emphasis: earthColors.forestAccent,
|
|
119
|
+
muted: earthColors.forestBrand,
|
|
120
|
+
subtle: '#0C2D18',
|
|
121
|
+
},
|
|
122
|
+
btn: {
|
|
123
|
+
text: '#D4E4DC',
|
|
124
|
+
bg: '#162236',
|
|
125
|
+
border: 'rgba(212, 228, 220, 0.12)',
|
|
126
|
+
hoverBg: '#1E3048',
|
|
127
|
+
hoverBorder: '#8A9BA8',
|
|
128
|
+
activeBg: '#162236',
|
|
129
|
+
activeBorder: '#6B7C88',
|
|
130
|
+
selectedBg: '#0E1D30',
|
|
131
|
+
counterBg: '#1E3048',
|
|
132
|
+
primary: {
|
|
133
|
+
text: earthColors.white,
|
|
134
|
+
bg: earthColors.oceanAccent,
|
|
135
|
+
border: 'rgba(212, 228, 220, 0.12)',
|
|
136
|
+
hoverBg: earthColors.oceanBright,
|
|
137
|
+
hoverBorder: 'rgba(212, 228, 220, 0.12)',
|
|
138
|
+
selectedBg: earthColors.oceanBright,
|
|
139
|
+
disabledText: 'rgba(255, 255, 255, 0.5)',
|
|
140
|
+
disabledBg: 'rgba(3, 105, 161, 0.35)',
|
|
141
|
+
disabledBorder: 'rgba(3, 105, 161, 0.2)',
|
|
142
|
+
icon: earthColors.white,
|
|
143
|
+
counterBg: 'rgba(0, 0, 0, 0.2)',
|
|
144
|
+
},
|
|
145
|
+
outline: {
|
|
146
|
+
text: earthColors.oceanAccent,
|
|
147
|
+
hoverText: earthColors.white,
|
|
148
|
+
hoverBg: earthColors.oceanAccent,
|
|
149
|
+
hoverBorder: earthColors.oceanAccent,
|
|
150
|
+
hoverCounterBg: 'rgba(255, 255, 255, 0.2)',
|
|
151
|
+
selectedText: earthColors.white,
|
|
152
|
+
selectedBg: earthColors.oceanBright,
|
|
153
|
+
selectedBorder: earthColors.oceanBright,
|
|
154
|
+
disabledText: 'rgba(14, 165, 233, 0.5)',
|
|
155
|
+
disabledBg: 'rgba(14, 165, 233, 0.1)',
|
|
156
|
+
disabledCounterBg: 'rgba(14, 165, 233, 0.05)',
|
|
157
|
+
counterBg: 'rgba(14, 165, 233, 0.1)',
|
|
158
|
+
counterFg: earthColors.oceanAccent,
|
|
159
|
+
hoverCounterFg: earthColors.white,
|
|
160
|
+
disabledCounterFg: 'rgba(14, 165, 233, 0.5)',
|
|
161
|
+
},
|
|
162
|
+
danger: {
|
|
163
|
+
text: '#f85149',
|
|
164
|
+
hoverText: earthColors.white,
|
|
165
|
+
hoverBg: '#da3633',
|
|
166
|
+
hoverBorder: '#f85149',
|
|
167
|
+
hoverCounterBg: 'rgba(255, 255, 255, 0.2)',
|
|
168
|
+
selectedText: earthColors.white,
|
|
169
|
+
selectedBg: '#b62324',
|
|
170
|
+
selectedBorder: '#ff7b72',
|
|
171
|
+
disabledText: 'rgba(248, 81, 73, 0.5)',
|
|
172
|
+
disabledBg: 'rgba(248, 81, 73, 0.1)',
|
|
173
|
+
disabledCounterBg: 'rgba(248, 81, 73, 0.05)',
|
|
174
|
+
counterBg: 'rgba(248, 81, 73, 0.1)',
|
|
175
|
+
counterFg: '#f85149',
|
|
176
|
+
hoverCounterFg: earthColors.white,
|
|
177
|
+
disabledCounterFg: 'rgba(248, 81, 73, 0.5)',
|
|
178
|
+
icon: '#f85149',
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
/* ── Exports ─────────────────────────────────────────────────────────── */
|
|
183
|
+
/**
|
|
184
|
+
* The Primer theme object.
|
|
185
|
+
*
|
|
186
|
+
* Since theming is now done entirely via CSS custom properties
|
|
187
|
+
* (see `earthThemeStyles`), this is just the unmodified
|
|
188
|
+
* default Primer theme kept for backward compatibility.
|
|
189
|
+
*/
|
|
190
|
+
export const earthTheme = primerTheme;
|
|
191
|
+
/** Comprehensive Primer CSS-variable overrides for light & dark mode. */
|
|
192
|
+
export const earthThemeStyles = buildThemeStyles(earthLight, earthDark);
|
|
193
|
+
export default earthTheme;
|
|
@@ -11,8 +11,6 @@
|
|
|
11
11
|
import { theme as primerTheme } from '@primer/react';
|
|
12
12
|
import { lovelyColors } from '../colors';
|
|
13
13
|
import { buildThemeStyles } from './createThemeCSSVars';
|
|
14
|
-
// Re-export so existing consumers keep working.
|
|
15
|
-
export { lovelyColors };
|
|
16
14
|
/* ── Light-mode colour definitions ───────────────────────────────────── */
|
|
17
15
|
const lovelyLight = {
|
|
18
16
|
canvas: {
|
|
@@ -11,8 +11,6 @@
|
|
|
11
11
|
import { theme as primerTheme } from '@primer/react';
|
|
12
12
|
import { matrixColors } from '../colors';
|
|
13
13
|
import { buildThemeStyles } from './createThemeCSSVars';
|
|
14
|
-
// Re-export so existing consumers keep working.
|
|
15
|
-
export { matrixColors };
|
|
16
14
|
/* ── Light-mode colour definitions ───────────────────────────────────── */
|
|
17
15
|
const matrixLight = {
|
|
18
16
|
canvas: {
|
|
@@ -11,8 +11,6 @@
|
|
|
11
11
|
import { theme as primerTheme } from '@primer/react';
|
|
12
12
|
import { spatialColors } from '../colors';
|
|
13
13
|
import { buildThemeStyles } from './createThemeCSSVars';
|
|
14
|
-
// Re-export so existing consumers keep working.
|
|
15
|
-
export { spatialColors };
|
|
16
14
|
/* ── Light-mode colour definitions ───────────────────────────────────── */
|
|
17
15
|
const spatialLight = {
|
|
18
16
|
canvas: {
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
import { type StoreApi, type UseBoundStore } from 'zustand';
|
|
10
10
|
import type { ThemeVariant } from './themeRegistry';
|
|
11
11
|
import type { ColorMode } from './DatalayerBrandThemeProvider';
|
|
12
|
-
export type { ThemeVariant, ColorMode };
|
|
13
12
|
export interface ThemeState {
|
|
14
13
|
/** Current color mode (light, dark, or auto = follow OS). */
|
|
15
14
|
colorMode: ColorMode;
|
package/lib/utils/Portals.d.ts
CHANGED
|
@@ -4,6 +4,10 @@ type Colormode = 'light' | 'dark' | 'auto';
|
|
|
4
4
|
/**
|
|
5
5
|
* Ensure we define a root for Primer portal root.
|
|
6
6
|
*
|
|
7
|
+
* Creates a dedicated `<div>` appended to `<body>` with a high z-index
|
|
8
|
+
* so that portaled content (overlays, tooltips, action menus) renders
|
|
9
|
+
* above other positioned UI elements such as chat panels.
|
|
10
|
+
*
|
|
7
11
|
* @see https://github.com/primer/react/blob/main/packages/react/src/Portal/Portal.tsx#L23
|
|
8
12
|
* @see https://github.com/primer/react/blob/030fe020b48b7f12c2994c6614e5d4191fe764ee/src/Portal/Portal.tsx#L33
|
|
9
13
|
*/
|
package/lib/utils/Portals.js
CHANGED
|
@@ -19,21 +19,73 @@ const resolveColormode = (colormode) => {
|
|
|
19
19
|
}
|
|
20
20
|
return colormode;
|
|
21
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* Infer current app color mode from existing DOM theme markers.
|
|
24
|
+
*
|
|
25
|
+
* This avoids accidentally forcing light mode when callers invoke
|
|
26
|
+
* setupPrimerPortals() without passing an explicit mode.
|
|
27
|
+
*/
|
|
28
|
+
const inferCurrentColormode = () => {
|
|
29
|
+
const portalRoot = document.getElementById(PRIMER_PORTAL_ROOT_ID);
|
|
30
|
+
const portalMode = portalRoot?.getAttribute('data-color-mode');
|
|
31
|
+
if (portalMode === 'light' || portalMode === 'dark' || portalMode === 'auto') {
|
|
32
|
+
return portalMode;
|
|
33
|
+
}
|
|
34
|
+
const htmlMode = document.documentElement.getAttribute('data-color-mode');
|
|
35
|
+
if (htmlMode === 'light' || htmlMode === 'dark' || htmlMode === 'auto') {
|
|
36
|
+
return htmlMode;
|
|
37
|
+
}
|
|
38
|
+
const bodyMode = document.body.getAttribute('data-color-mode');
|
|
39
|
+
if (bodyMode === 'light' || bodyMode === 'dark' || bodyMode === 'auto') {
|
|
40
|
+
return bodyMode;
|
|
41
|
+
}
|
|
42
|
+
return 'auto';
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Infer Primer light/dark theme names from existing DOM markers.
|
|
46
|
+
*/
|
|
47
|
+
const inferCurrentThemeNames = () => {
|
|
48
|
+
const portalRoot = document.getElementById(PRIMER_PORTAL_ROOT_ID);
|
|
49
|
+
const lightTheme = portalRoot?.getAttribute('data-light-theme') ||
|
|
50
|
+
document.documentElement.getAttribute('data-light-theme') ||
|
|
51
|
+
document.body.getAttribute('data-light-theme') ||
|
|
52
|
+
'light';
|
|
53
|
+
const darkTheme = portalRoot?.getAttribute('data-dark-theme') ||
|
|
54
|
+
document.documentElement.getAttribute('data-dark-theme') ||
|
|
55
|
+
document.body.getAttribute('data-dark-theme') ||
|
|
56
|
+
'dark';
|
|
57
|
+
return { lightTheme, darkTheme };
|
|
58
|
+
};
|
|
22
59
|
/**
|
|
23
60
|
* Ensure we define a root for Primer portal root.
|
|
24
61
|
*
|
|
62
|
+
* Creates a dedicated `<div>` appended to `<body>` with a high z-index
|
|
63
|
+
* so that portaled content (overlays, tooltips, action menus) renders
|
|
64
|
+
* above other positioned UI elements such as chat panels.
|
|
65
|
+
*
|
|
25
66
|
* @see https://github.com/primer/react/blob/main/packages/react/src/Portal/Portal.tsx#L23
|
|
26
67
|
* @see https://github.com/primer/react/blob/030fe020b48b7f12c2994c6614e5d4191fe764ee/src/Portal/Portal.tsx#L33
|
|
27
68
|
*/
|
|
28
|
-
export const setupPrimerPortals = (colormode
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
69
|
+
export const setupPrimerPortals = (colormode) => {
|
|
70
|
+
const effectiveColormode = colormode ?? inferCurrentColormode();
|
|
71
|
+
const resolved = resolveColormode(effectiveColormode);
|
|
72
|
+
const { lightTheme, darkTheme } = inferCurrentThemeNames();
|
|
73
|
+
// Create or reuse a dedicated portal root div.
|
|
74
|
+
let portalRoot = document.getElementById(PRIMER_PORTAL_ROOT_ID);
|
|
75
|
+
if (!portalRoot) {
|
|
76
|
+
portalRoot = document.createElement('div');
|
|
77
|
+
portalRoot.id = PRIMER_PORTAL_ROOT_ID;
|
|
78
|
+
document.body.appendChild(portalRoot);
|
|
79
|
+
}
|
|
80
|
+
// Primer theme attributes — required for proper theming inside portals.
|
|
81
|
+
portalRoot.dataset['portalRoot'] = 'true';
|
|
82
|
+
portalRoot.dataset['colorMode'] = resolved;
|
|
83
|
+
portalRoot.dataset['lightTheme'] = lightTheme;
|
|
84
|
+
portalRoot.dataset['darkTheme'] = darkTheme;
|
|
85
|
+
// High z-index so overlays render above positioned UI (e.g. chat z-index 1001).
|
|
86
|
+
portalRoot.style.position = 'relative';
|
|
87
|
+
portalRoot.style.zIndex = '9999';
|
|
88
|
+
registerPortalRoot(portalRoot);
|
|
37
89
|
};
|
|
38
90
|
/* ─── camelCase → kebab-case ─────────────────────────────────────────── */
|
|
39
91
|
const camelToKebab = (s) => s.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
package/package.json
CHANGED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ArgTypes } from '@storybook/react';
|
|
3
|
-
import { Icon } from '@primer/octicons-react';
|
|
4
|
-
type StoryContext = Record<string, unknown> & {
|
|
5
|
-
globals: {
|
|
6
|
-
colorScheme: string;
|
|
7
|
-
};
|
|
8
|
-
parameters: Record<string, unknown>;
|
|
9
|
-
};
|
|
10
|
-
export declare const colormodeFromScheme: (colorScheme: string) => "dark" | "light";
|
|
11
|
-
export declare const withThemeProvider: (Story: React.FC<React.PropsWithChildren<StoryContext>>, context: StoryContext) => string | number | boolean | Iterable<React.ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
12
|
-
export declare const toolbarTypes: {
|
|
13
|
-
colorScheme: {
|
|
14
|
-
name: string;
|
|
15
|
-
description: string;
|
|
16
|
-
defaultValue: string;
|
|
17
|
-
toolbar: {
|
|
18
|
-
icon: string;
|
|
19
|
-
items: string[];
|
|
20
|
-
title: string;
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
export declare const inputWrapperArgTypes: ArgTypes;
|
|
25
|
-
export declare const getTextInputArgTypes: (category?: string) => Record<string, unknown>;
|
|
26
|
-
export declare const OcticonArgType: (iconList: Icon[]) => {
|
|
27
|
-
options: string[];
|
|
28
|
-
control: string;
|
|
29
|
-
mapping: Record<string, Icon>;
|
|
30
|
-
};
|
|
31
|
-
export {};
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { createGlobalStyle } from 'styled-components';
|
|
3
|
-
import { ThemeProvider, themeGet, BaseStyles, theme } from '@primer/react';
|
|
4
|
-
// set global theme styles for each story
|
|
5
|
-
const GlobalStyle = createGlobalStyle `
|
|
6
|
-
body,
|
|
7
|
-
.docs-story {
|
|
8
|
-
background-color: ${themeGet('colors.canvas.default')};
|
|
9
|
-
color: ${themeGet('colors.fg.default')};
|
|
10
|
-
}
|
|
11
|
-
`;
|
|
12
|
-
export const colormodeFromScheme = (colorScheme) => {
|
|
13
|
-
return colorScheme.startsWith('light') ? 'light' : 'dark';
|
|
14
|
-
};
|
|
15
|
-
export const withThemeProvider = (Story, context) => {
|
|
16
|
-
// used for testing ThemeProvider.stories.tsx
|
|
17
|
-
if (context.parameters.disableThemeDecorator)
|
|
18
|
-
return Story(context);
|
|
19
|
-
const { colorScheme } = context.globals;
|
|
20
|
-
return (_jsxs(ThemeProvider, { theme: theme, colorMode: colormodeFromScheme(colorScheme), dayScheme: colorScheme, nightScheme: colorScheme, children: [colorScheme.startsWith('light') ? (_jsx(GlobalStyle, { "$lightTheme": true })) : (_jsx(GlobalStyle, {})), _jsx(BaseStyles, { children: _jsx("div", { id: "html-addon-root", children: Story(context) }) })] }));
|
|
21
|
-
};
|
|
22
|
-
export const toolbarTypes = {
|
|
23
|
-
colorScheme: {
|
|
24
|
-
name: 'Color Scheme',
|
|
25
|
-
description: 'Switch color scheme',
|
|
26
|
-
defaultValue: 'light',
|
|
27
|
-
toolbar: {
|
|
28
|
-
icon: 'photo',
|
|
29
|
-
items: [...Object.keys(theme.colorSchemes)],
|
|
30
|
-
title: 'Color Scheme',
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
export const inputWrapperArgTypes = {
|
|
35
|
-
block: {
|
|
36
|
-
defaultValue: false,
|
|
37
|
-
control: 'boolean',
|
|
38
|
-
},
|
|
39
|
-
contrast: {
|
|
40
|
-
defaultValue: false,
|
|
41
|
-
control: 'boolean',
|
|
42
|
-
},
|
|
43
|
-
disabled: {
|
|
44
|
-
defaultValue: false,
|
|
45
|
-
control: 'boolean',
|
|
46
|
-
},
|
|
47
|
-
placeholder: {
|
|
48
|
-
defaultValue: '',
|
|
49
|
-
control: 'text',
|
|
50
|
-
},
|
|
51
|
-
size: {
|
|
52
|
-
name: 'size (input)', // TODO: remove '(input)'
|
|
53
|
-
defaultValue: 'medium',
|
|
54
|
-
options: ['small', 'medium', 'large'],
|
|
55
|
-
control: 'radio',
|
|
56
|
-
},
|
|
57
|
-
validationStatus: {
|
|
58
|
-
defaultValue: undefined,
|
|
59
|
-
options: ['error', 'success', undefined],
|
|
60
|
-
control: 'radio',
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
const textInputArgTypesUnsorted = {
|
|
64
|
-
...inputWrapperArgTypes,
|
|
65
|
-
loading: {
|
|
66
|
-
defaultValue: false,
|
|
67
|
-
control: 'boolean',
|
|
68
|
-
},
|
|
69
|
-
loaderPosition: {
|
|
70
|
-
defaultValue: 'auto',
|
|
71
|
-
options: ['auto', 'leading', 'trailing'],
|
|
72
|
-
control: 'radio',
|
|
73
|
-
},
|
|
74
|
-
monospace: {
|
|
75
|
-
defaultValue: false,
|
|
76
|
-
control: 'boolean',
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
// Alphabetize and optionally categorize the props
|
|
80
|
-
export const getTextInputArgTypes = (category) => Object.keys(textInputArgTypesUnsorted)
|
|
81
|
-
.sort()
|
|
82
|
-
.reduce((obj, key) => {
|
|
83
|
-
obj[key] = category
|
|
84
|
-
? {
|
|
85
|
-
// have to do weird type casting so we can spread the object
|
|
86
|
-
...textInputArgTypesUnsorted[key],
|
|
87
|
-
table: {
|
|
88
|
-
category,
|
|
89
|
-
},
|
|
90
|
-
}
|
|
91
|
-
: textInputArgTypesUnsorted[key];
|
|
92
|
-
return obj;
|
|
93
|
-
}, {});
|
|
94
|
-
// Use this function for icon options in the controls. Desired icons are passed in as an array of Octicons
|
|
95
|
-
export const OcticonArgType = (iconList) => {
|
|
96
|
-
const icons = iconList.reduce((obj, icon) => {
|
|
97
|
-
obj[icon.displayName || 'Icon'] = icon;
|
|
98
|
-
return obj;
|
|
99
|
-
}, {});
|
|
100
|
-
return {
|
|
101
|
-
options: Object.keys(icons),
|
|
102
|
-
control: 'select',
|
|
103
|
-
mapping: icons,
|
|
104
|
-
};
|
|
105
|
-
};
|
package/lib/theme/Palette.d.ts
DELETED
package/lib/theme/Palette.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
-
* Distributed under the terms of the Modified BSD License.
|
|
4
|
-
*/
|
|
5
|
-
// export const RESERVATION_CIRCLE_COLOR_VAR = '--data-yellow-color';
|
|
6
|
-
export const RESERVATION_CIRCLE_COLOR = '#656D76';
|
|
7
|
-
// export const CREDITS_CIRCLE_COLOR_VAR = '--data-blue-color';
|
|
8
|
-
export const CREDITS_CIRCLE_COLOR = '#16A085';
|
|
9
|
-
export const JOINED_INVITE_COLOR = '#0366d6';
|
|
10
|
-
export const PENDING_INVITE_COLOR = '#cfd3d7';
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ThemeSwitcher – Themed colour circles + light/dark/auto segmented control.
|
|
3
|
-
*
|
|
4
|
-
* The component requires an external Zustand `ThemeState` store (created
|
|
5
|
-
* with `createThemeStore`). Consumers pass the `useStore` hook as a prop
|
|
6
|
-
* so the switcher is completely decoupled from any specific app's store.
|
|
7
|
-
*
|
|
8
|
-
* @module theme/ThemeSwitcher
|
|
9
|
-
*/
|
|
10
|
-
import React from 'react';
|
|
11
|
-
import type { ThemeState } from './useThemeStore';
|
|
12
|
-
import type { UseBoundStore, StoreApi } from 'zustand';
|
|
13
|
-
export interface ThemeSwitcherProps {
|
|
14
|
-
/** A Zustand store hook created via `createThemeStore()`. */
|
|
15
|
-
useStore: UseBoundStore<StoreApi<ThemeState>>;
|
|
16
|
-
}
|
|
17
|
-
export declare const ThemeSwitcher: React.FC<ThemeSwitcherProps>;
|