@datalayer/primer-addons 1.0.7 → 1.0.9
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/box/sx.d.ts +3 -1
- package/lib/components/box/sx.js +1 -1
- package/lib/components/overlay/Overlay.js +15 -2
- package/lib/components/toolbar/FloatingToolbar.js +18 -12
- package/lib/components/toolbar/Toolbar.js +1 -1
- package/lib/components/toolbar/ToolbarButton.js +1 -1
- package/lib/components/toolbar/ToolbarDropdown.js +68 -17
- package/lib/components/toolbar/types.d.ts +6 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -0
- package/lib/theme/DatalayerBrandThemeProvider.d.ts +41 -0
- package/lib/theme/DatalayerBrandThemeProvider.js +32 -0
- package/lib/theme/DatalayerThemeProvider.d.ts +36 -0
- package/lib/theme/DatalayerThemeProvider.js +35 -0
- package/lib/theme/Palette.d.ts +4 -0
- package/lib/theme/Palette.js +10 -0
- package/lib/theme/colors/datalayerColors.d.ts +15 -0
- package/lib/theme/colors/datalayerColors.js +21 -0
- package/lib/theme/colors/index.d.ts +4 -0
- package/lib/theme/colors/index.js +8 -0
- package/lib/theme/colors/lovelyColors.d.ts +15 -0
- package/lib/theme/colors/lovelyColors.js +21 -0
- package/lib/theme/colors/matrixColors.d.ts +20 -0
- package/lib/theme/colors/matrixColors.js +26 -0
- package/lib/theme/colors/spatialColors.d.ts +15 -0
- package/lib/theme/colors/spatialColors.js +21 -0
- package/lib/theme/index.d.ts +11 -0
- package/lib/theme/index.js +15 -0
- package/lib/theme/themes/createThemeCSSVars.d.ts +131 -0
- package/lib/theme/themes/createThemeCSSVars.js +172 -0
- package/lib/theme/themes/datalayerTheme.d.ts +1093 -0
- package/lib/theme/themes/datalayerTheme.js +191 -0
- package/lib/theme/themes/lovelyTheme.d.ts +1093 -0
- package/lib/theme/themes/lovelyTheme.js +190 -0
- package/lib/theme/themes/matrixTheme.d.ts +1093 -0
- package/lib/theme/themes/matrixTheme.js +190 -0
- package/lib/theme/themes/spatialTheme.d.ts +1093 -0
- package/lib/theme/themes/spatialTheme.js +190 -0
- package/lib/theme/themes-brand/index.d.ts +1 -0
- package/lib/theme/themes-brand/index.js +5 -0
- package/lib/theme/themes-brand/spatialBrandTheme.d.ts +16 -0
- package/lib/theme/themes-brand/spatialBrandTheme.js +157 -0
- package/lib/theme/useSystemColorMode.d.ts +9 -0
- package/lib/theme/useSystemColorMode.js +26 -0
- package/package.json +1 -1
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { type CSSProperties } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Structured colour definitions that mirror the *old* Primer
|
|
4
|
+
* `colorSchemes.*.colors` shape. Each theme file provides one of
|
|
5
|
+
* these for light mode and one for dark mode.
|
|
6
|
+
*
|
|
7
|
+
* The {@link colorDefsToCSS} helper converts them into a flat
|
|
8
|
+
* `CSSProperties` bag of Primer CSS custom-property overrides so
|
|
9
|
+
* the `<DatalayerThemeProvider>` can apply them via
|
|
10
|
+
* `<BaseStyles style={…}>`.
|
|
11
|
+
*/
|
|
12
|
+
export interface ThemeColorDefs {
|
|
13
|
+
canvas: {
|
|
14
|
+
default: string;
|
|
15
|
+
subtle?: string;
|
|
16
|
+
};
|
|
17
|
+
fg: {
|
|
18
|
+
default: string;
|
|
19
|
+
muted: string;
|
|
20
|
+
onEmphasis: string;
|
|
21
|
+
};
|
|
22
|
+
accent: {
|
|
23
|
+
fg: string;
|
|
24
|
+
emphasis: string;
|
|
25
|
+
muted: string;
|
|
26
|
+
subtle?: string;
|
|
27
|
+
};
|
|
28
|
+
success: {
|
|
29
|
+
fg: string;
|
|
30
|
+
emphasis: string;
|
|
31
|
+
muted: string;
|
|
32
|
+
subtle?: string;
|
|
33
|
+
};
|
|
34
|
+
btn: {
|
|
35
|
+
text: string;
|
|
36
|
+
bg: string;
|
|
37
|
+
border: string;
|
|
38
|
+
hoverBg: string;
|
|
39
|
+
hoverBorder: string;
|
|
40
|
+
activeBg: string;
|
|
41
|
+
activeBorder: string;
|
|
42
|
+
selectedBg: string;
|
|
43
|
+
counterBg: string;
|
|
44
|
+
primary: {
|
|
45
|
+
text: string;
|
|
46
|
+
bg: string;
|
|
47
|
+
border: string;
|
|
48
|
+
hoverBg: string;
|
|
49
|
+
hoverBorder: string;
|
|
50
|
+
selectedBg: string;
|
|
51
|
+
disabledText: string;
|
|
52
|
+
disabledBg: string;
|
|
53
|
+
disabledBorder: string;
|
|
54
|
+
icon: string;
|
|
55
|
+
counterBg: string;
|
|
56
|
+
};
|
|
57
|
+
outline: {
|
|
58
|
+
text: string;
|
|
59
|
+
hoverText: string;
|
|
60
|
+
hoverBg: string;
|
|
61
|
+
hoverBorder: string;
|
|
62
|
+
hoverCounterBg: string;
|
|
63
|
+
selectedText: string;
|
|
64
|
+
selectedBg: string;
|
|
65
|
+
selectedBorder: string;
|
|
66
|
+
disabledText: string;
|
|
67
|
+
disabledBg: string;
|
|
68
|
+
disabledCounterBg: string;
|
|
69
|
+
counterBg: string;
|
|
70
|
+
counterFg: string;
|
|
71
|
+
hoverCounterFg: string;
|
|
72
|
+
disabledCounterFg: string;
|
|
73
|
+
};
|
|
74
|
+
danger: {
|
|
75
|
+
text: string;
|
|
76
|
+
hoverText: string;
|
|
77
|
+
hoverBg: string;
|
|
78
|
+
hoverBorder: string;
|
|
79
|
+
hoverCounterBg: string;
|
|
80
|
+
selectedText: string;
|
|
81
|
+
selectedBg: string;
|
|
82
|
+
selectedBorder: string;
|
|
83
|
+
disabledText: string;
|
|
84
|
+
disabledBg: string;
|
|
85
|
+
disabledCounterBg: string;
|
|
86
|
+
counterBg: string;
|
|
87
|
+
counterFg: string;
|
|
88
|
+
hoverCounterFg: string;
|
|
89
|
+
disabledCounterFg: string;
|
|
90
|
+
icon: string;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Convert a structured `ThemeColorDefs` object into a flat
|
|
96
|
+
* `CSSProperties` bag of Primer React CSS custom-property overrides.
|
|
97
|
+
*
|
|
98
|
+
* These variables are the *functional tokens* consumed by Primer
|
|
99
|
+
* React components (sourced from `@primer/primitives`). Setting
|
|
100
|
+
* them on a parent element is enough to retheme every Primer
|
|
101
|
+
* component in the sub-tree.
|
|
102
|
+
*
|
|
103
|
+
* ### Variable families covered
|
|
104
|
+
*
|
|
105
|
+
* | Family | Example variable |
|
|
106
|
+
* |------------------|----------------------------------------|
|
|
107
|
+
* | Background | `--bgColor-default` |
|
|
108
|
+
* | Foreground | `--fgColor-default` |
|
|
109
|
+
* | Border | `--borderColor-default` |
|
|
110
|
+
* | Link | `--fgColor-link` |
|
|
111
|
+
* | Accent / Success | `--bgColor-accent-emphasis` |
|
|
112
|
+
* | Default button | `--button-default-bgColor-rest` |
|
|
113
|
+
* | Primary button | `--button-primary-bgColor-rest` |
|
|
114
|
+
* | Outline button | `--button-outline-fgColor-rest` |
|
|
115
|
+
* | Danger button | `--button-danger-bgColor-hover` |
|
|
116
|
+
* | Button counters | `--buttonCounter-primary-bgColor-rest` |
|
|
117
|
+
* | Legacy aliases | `--color-btn-primary-bg` |
|
|
118
|
+
* | Brand (custom) | `--brand-color-canvas-default` |
|
|
119
|
+
*/
|
|
120
|
+
export declare function colorDefsToCSS(defs: ThemeColorDefs): CSSProperties;
|
|
121
|
+
/** Light + dark CSS-property pairs for the `themeStyles` prop. */
|
|
122
|
+
export interface ThemeStyles {
|
|
123
|
+
light: CSSProperties;
|
|
124
|
+
dark: CSSProperties;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Build a complete `ThemeStyles` object from light / dark
|
|
128
|
+
* `ThemeColorDefs`. The result is ready to pass straight to
|
|
129
|
+
* `<DatalayerThemeProvider themeStyles={…}>`.
|
|
130
|
+
*/
|
|
131
|
+
export declare function buildThemeStyles(light: ThemeColorDefs, dark: ThemeColorDefs): ThemeStyles;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
/* ─── Helper ──────────────────────────────────────────────────────────── */
|
|
6
|
+
/**
|
|
7
|
+
* Convert a structured `ThemeColorDefs` object into a flat
|
|
8
|
+
* `CSSProperties` bag of Primer React CSS custom-property overrides.
|
|
9
|
+
*
|
|
10
|
+
* These variables are the *functional tokens* consumed by Primer
|
|
11
|
+
* React components (sourced from `@primer/primitives`). Setting
|
|
12
|
+
* them on a parent element is enough to retheme every Primer
|
|
13
|
+
* component in the sub-tree.
|
|
14
|
+
*
|
|
15
|
+
* ### Variable families covered
|
|
16
|
+
*
|
|
17
|
+
* | Family | Example variable |
|
|
18
|
+
* |------------------|----------------------------------------|
|
|
19
|
+
* | Background | `--bgColor-default` |
|
|
20
|
+
* | Foreground | `--fgColor-default` |
|
|
21
|
+
* | Border | `--borderColor-default` |
|
|
22
|
+
* | Link | `--fgColor-link` |
|
|
23
|
+
* | Accent / Success | `--bgColor-accent-emphasis` |
|
|
24
|
+
* | Default button | `--button-default-bgColor-rest` |
|
|
25
|
+
* | Primary button | `--button-primary-bgColor-rest` |
|
|
26
|
+
* | Outline button | `--button-outline-fgColor-rest` |
|
|
27
|
+
* | Danger button | `--button-danger-bgColor-hover` |
|
|
28
|
+
* | Button counters | `--buttonCounter-primary-bgColor-rest` |
|
|
29
|
+
* | Legacy aliases | `--color-btn-primary-bg` |
|
|
30
|
+
* | Brand (custom) | `--brand-color-canvas-default` |
|
|
31
|
+
*/
|
|
32
|
+
export function colorDefsToCSS(defs) {
|
|
33
|
+
const optional = {};
|
|
34
|
+
if (defs.canvas.subtle) {
|
|
35
|
+
optional['--bgColor-muted'] = defs.canvas.subtle;
|
|
36
|
+
}
|
|
37
|
+
if (defs.accent.subtle) {
|
|
38
|
+
optional['--bgColor-accent-subtle'] = defs.accent.subtle;
|
|
39
|
+
}
|
|
40
|
+
if (defs.success.subtle) {
|
|
41
|
+
optional['--bgColor-success-subtle'] = defs.success.subtle;
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
/* ── Canvas / Background ─────────────────────────────────────── */
|
|
45
|
+
'--bgColor-default': defs.canvas.default,
|
|
46
|
+
'--bgColor-inset': defs.canvas.default,
|
|
47
|
+
...optional,
|
|
48
|
+
/* ── Foreground / Text ───────────────────────────────────────── */
|
|
49
|
+
'--fgColor-default': defs.fg.default,
|
|
50
|
+
'--fgColor-muted': defs.fg.muted,
|
|
51
|
+
'--fgColor-onEmphasis': defs.fg.onEmphasis,
|
|
52
|
+
/* ── Links ───────────────────────────────────────────────────── */
|
|
53
|
+
'--fgColor-link': defs.accent.fg,
|
|
54
|
+
/* ── Accent ──────────────────────────────────────────────────── */
|
|
55
|
+
'--fgColor-accent': defs.accent.fg,
|
|
56
|
+
'--bgColor-accent-emphasis': defs.accent.emphasis,
|
|
57
|
+
'--bgColor-accent-muted': defs.accent.muted,
|
|
58
|
+
'--borderColor-accent-emphasis': defs.accent.emphasis,
|
|
59
|
+
'--borderColor-accent-muted': defs.accent.muted,
|
|
60
|
+
/* ── Success ─────────────────────────────────────────────────── */
|
|
61
|
+
'--fgColor-success': defs.success.fg,
|
|
62
|
+
'--bgColor-success-emphasis': defs.success.emphasis,
|
|
63
|
+
'--bgColor-success-muted': defs.success.muted,
|
|
64
|
+
'--borderColor-success-emphasis': defs.success.emphasis,
|
|
65
|
+
'--borderColor-success-muted': defs.success.muted,
|
|
66
|
+
/* ── Border (generic) ────────────────────────────────────────── */
|
|
67
|
+
'--borderColor-default': defs.btn.border,
|
|
68
|
+
'--borderColor-muted': defs.btn.border,
|
|
69
|
+
/* ── Default button ──────────────────────────────────────────── */
|
|
70
|
+
'--button-default-fgColor-rest': defs.btn.text,
|
|
71
|
+
'--button-default-bgColor-rest': defs.btn.bg,
|
|
72
|
+
'--button-default-borderColor-rest': defs.btn.border,
|
|
73
|
+
'--button-default-bgColor-hover': defs.btn.hoverBg,
|
|
74
|
+
'--button-default-borderColor-hover': defs.btn.hoverBorder,
|
|
75
|
+
'--button-default-bgColor-active': defs.btn.activeBg,
|
|
76
|
+
'--button-default-borderColor-active': defs.btn.activeBorder,
|
|
77
|
+
'--button-default-bgColor-selected': defs.btn.selectedBg,
|
|
78
|
+
'--button-default-bgColor-disabled': defs.btn.bg,
|
|
79
|
+
'--button-default-borderColor-disabled': defs.btn.border,
|
|
80
|
+
'--buttonCounter-default-bgColor-rest': defs.btn.counterBg,
|
|
81
|
+
'--buttonCounter-default-fgColor-rest': defs.btn.text,
|
|
82
|
+
/* ── Primary button ──────────────────────────────────────────── */
|
|
83
|
+
'--button-primary-fgColor-rest': defs.btn.primary.text,
|
|
84
|
+
'--button-primary-bgColor-rest': defs.btn.primary.bg,
|
|
85
|
+
'--button-primary-borderColor-rest': defs.btn.primary.border,
|
|
86
|
+
'--button-primary-bgColor-hover': defs.btn.primary.hoverBg,
|
|
87
|
+
'--button-primary-borderColor-hover': defs.btn.primary.hoverBorder,
|
|
88
|
+
'--button-primary-bgColor-active': defs.btn.primary.selectedBg,
|
|
89
|
+
'--button-primary-borderColor-active': defs.btn.primary.hoverBorder,
|
|
90
|
+
'--button-primary-fgColor-disabled': defs.btn.primary.disabledText,
|
|
91
|
+
'--button-primary-bgColor-disabled': defs.btn.primary.disabledBg,
|
|
92
|
+
'--button-primary-borderColor-disabled': defs.btn.primary.disabledBorder,
|
|
93
|
+
'--button-primary-iconColor-rest': defs.btn.primary.icon,
|
|
94
|
+
'--buttonCounter-primary-bgColor-rest': defs.btn.primary.counterBg,
|
|
95
|
+
'--buttonCounter-primary-fgColor-rest': defs.btn.primary.text,
|
|
96
|
+
/* ── Outline button ──────────────────────────────────────────── */
|
|
97
|
+
'--button-outline-fgColor-rest': defs.btn.outline.text,
|
|
98
|
+
'--button-outline-bgColor-rest': 'transparent',
|
|
99
|
+
'--button-outline-borderColor-rest': defs.btn.outline.text,
|
|
100
|
+
'--button-outline-fgColor-hover': defs.btn.outline.hoverText,
|
|
101
|
+
'--button-outline-bgColor-hover': defs.btn.outline.hoverBg,
|
|
102
|
+
'--button-outline-borderColor-hover': defs.btn.outline.hoverBorder,
|
|
103
|
+
'--button-outline-fgColor-active': defs.btn.outline.selectedText,
|
|
104
|
+
'--button-outline-bgColor-active': defs.btn.outline.selectedBg,
|
|
105
|
+
'--button-outline-borderColor-active': defs.btn.outline.selectedBorder,
|
|
106
|
+
'--button-outline-fgColor-disabled': defs.btn.outline.disabledText,
|
|
107
|
+
'--button-outline-bgColor-disabled': defs.btn.outline.disabledBg,
|
|
108
|
+
'--buttonCounter-outline-bgColor-rest': defs.btn.outline.counterBg,
|
|
109
|
+
'--buttonCounter-outline-fgColor-rest': defs.btn.outline.counterFg,
|
|
110
|
+
'--buttonCounter-outline-bgColor-hover': defs.btn.outline.hoverCounterBg,
|
|
111
|
+
'--buttonCounter-outline-fgColor-hover': defs.btn.outline.hoverCounterFg,
|
|
112
|
+
'--buttonCounter-outline-fgColor-disabled': defs.btn.outline.disabledCounterFg,
|
|
113
|
+
'--buttonCounter-outline-bgColor-disabled': defs.btn.outline.disabledCounterBg,
|
|
114
|
+
/* ── Danger button ───────────────────────────────────────────── */
|
|
115
|
+
'--button-danger-fgColor-rest': defs.btn.danger.text,
|
|
116
|
+
'--button-danger-bgColor-rest': 'transparent',
|
|
117
|
+
'--button-danger-borderColor-rest': defs.btn.danger.text,
|
|
118
|
+
'--button-danger-fgColor-hover': defs.btn.danger.hoverText,
|
|
119
|
+
'--button-danger-bgColor-hover': defs.btn.danger.hoverBg,
|
|
120
|
+
'--button-danger-borderColor-hover': defs.btn.danger.hoverBorder,
|
|
121
|
+
'--button-danger-fgColor-active': defs.btn.danger.selectedText,
|
|
122
|
+
'--button-danger-bgColor-active': defs.btn.danger.selectedBg,
|
|
123
|
+
'--button-danger-borderColor-active': defs.btn.danger.selectedBorder,
|
|
124
|
+
'--button-danger-fgColor-disabled': defs.btn.danger.disabledText,
|
|
125
|
+
'--button-danger-bgColor-disabled': defs.btn.danger.disabledBg,
|
|
126
|
+
'--button-danger-iconColor-rest': defs.btn.danger.icon,
|
|
127
|
+
'--button-danger-iconColor-hover': defs.btn.danger.hoverText,
|
|
128
|
+
'--buttonCounter-danger-bgColor-rest': defs.btn.danger.counterBg,
|
|
129
|
+
'--buttonCounter-danger-fgColor-rest': defs.btn.danger.counterFg,
|
|
130
|
+
'--buttonCounter-danger-bgColor-hover': defs.btn.danger.hoverCounterBg,
|
|
131
|
+
'--buttonCounter-danger-fgColor-hover': defs.btn.danger.hoverCounterFg,
|
|
132
|
+
'--buttonCounter-danger-fgColor-disabled': defs.btn.danger.disabledCounterFg,
|
|
133
|
+
'--buttonCounter-danger-bgColor-disabled': defs.btn.danger.disabledCounterBg,
|
|
134
|
+
/* ── Invisible button (inherit from defaults) ────────────────── */
|
|
135
|
+
'--button-invisible-fgColor-rest': defs.fg.default,
|
|
136
|
+
'--button-invisible-bgColor-hover': defs.btn.hoverBg,
|
|
137
|
+
'--button-invisible-fgColor-hover': defs.fg.default,
|
|
138
|
+
'--button-invisible-bgColor-active': defs.btn.activeBg,
|
|
139
|
+
'--button-invisible-fgColor-active': defs.fg.default,
|
|
140
|
+
'--button-invisible-fgColor-disabled': defs.fg.muted,
|
|
141
|
+
'--button-invisible-iconColor-rest': defs.fg.muted,
|
|
142
|
+
'--button-invisible-iconColor-hover': defs.fg.default,
|
|
143
|
+
'--button-invisible-iconColor-disabled': defs.fg.muted,
|
|
144
|
+
/* ── Legacy / compat aliases ─────────────────────────────────── */
|
|
145
|
+
'--color-btn-primary-bg': defs.btn.primary.bg,
|
|
146
|
+
'--color-btn-primary-hover-bg': defs.btn.primary.hoverBg,
|
|
147
|
+
/* ── Datalayer brand tokens (consumed by custom components) ─── */
|
|
148
|
+
'--brand-color-canvas-default': defs.canvas.default,
|
|
149
|
+
'--brand-color-text-default': defs.fg.default,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Build a complete `ThemeStyles` object from light / dark
|
|
154
|
+
* `ThemeColorDefs`. The result is ready to pass straight to
|
|
155
|
+
* `<DatalayerThemeProvider themeStyles={…}>`.
|
|
156
|
+
*/
|
|
157
|
+
export function buildThemeStyles(light, dark) {
|
|
158
|
+
return {
|
|
159
|
+
light: {
|
|
160
|
+
backgroundColor: light.canvas.default,
|
|
161
|
+
color: light.fg.default,
|
|
162
|
+
fontSize: 'var(--text-body-size-medium)',
|
|
163
|
+
...colorDefsToCSS(light),
|
|
164
|
+
},
|
|
165
|
+
dark: {
|
|
166
|
+
backgroundColor: dark.canvas.default,
|
|
167
|
+
color: dark.fg.default,
|
|
168
|
+
fontSize: 'var(--text-body-size-medium)',
|
|
169
|
+
...colorDefsToCSS(dark),
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
}
|