@datalayer/primer-addons 1.0.22 → 1.0.24

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.
Files changed (39) hide show
  1. package/README.md +1 -1
  2. package/lib/components/box/Box.js +1 -2
  3. package/lib/components/box/sx.js +1 -2
  4. package/lib/components/closeable-flash/CloseableFlash.d.ts +23 -1
  5. package/lib/components/closeable-flash/CloseableFlash.js +52 -4
  6. package/lib/components/content-loader/ContentLoader.js +4 -0
  7. package/lib/components/date-picker/DatePicker.d.ts +36 -1
  8. package/lib/components/date-picker/DatePicker.js +122 -16
  9. package/lib/components/date-picker/TimeColumns.d.ts +23 -0
  10. package/lib/components/date-picker/TimeColumns.js +88 -0
  11. package/lib/components/icons/CircleIcon.js +4 -0
  12. package/lib/components/index.js +4 -0
  13. package/lib/components/logo/DatalayerLogo.js +18 -1
  14. package/lib/components/logo/index.js +4 -0
  15. package/lib/components/side-overlay/SideOverlay.js +4 -0
  16. package/lib/components/side-overlay/SideOverlay.stories.js +4 -0
  17. package/lib/components/slider/Slider.js +4 -0
  18. package/lib/components/slider/Slider.stories.js +4 -0
  19. package/lib/components/sliding-panel/SlidingPanel.js +17 -1
  20. package/lib/components/sliding-panel/SlidingPanel.stories.js +4 -0
  21. package/lib/index.js +4 -0
  22. package/lib/reactor/page-layout/PageLayout.js +68 -52
  23. package/lib/story-helpers.d.ts +1 -1
  24. package/lib/theme/colors/index.d.ts +1 -0
  25. package/lib/theme/colors/index.js +3 -0
  26. package/lib/theme/colors/loopColors.d.ts +91 -0
  27. package/lib/theme/colors/loopColors.js +128 -0
  28. package/lib/theme/css/createThemeCSSVars.d.ts +8 -0
  29. package/lib/theme/css/createThemeCSSVars.js +2 -0
  30. package/lib/theme/index.d.ts +1 -0
  31. package/lib/theme/index.js +1 -0
  32. package/lib/theme/palettes/ColorPalette.js +42 -3
  33. package/lib/theme/palettes/index.js +1 -2
  34. package/lib/theme/themeRegistry.d.ts +1 -1
  35. package/lib/theme/themeRegistry.js +52 -1
  36. package/lib/theme/themes/loopTheme.d.ts +1105 -0
  37. package/lib/theme/themes/loopTheme.js +309 -0
  38. package/lib/utils/Portals.js +3 -1
  39. package/package.json +10 -4
@@ -0,0 +1,309 @@
1
+ /*
2
+ * Copyright (c) 2023-2025 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ /**
6
+ * Loop Theme for Primer React.
7
+ *
8
+ * Very clean: one accent, neutral everything else. A white (or near-black)
9
+ * canvas, near-black (or near-white) text, hairlines for borders, and a
10
+ * filled button that is ink on paper rather than a colour. Uses Inter,
11
+ * with the system sans-serif stack behind it.
12
+ * Theming is applied via **CSS custom-property overrides**.
13
+ *
14
+ * Unlike the other themes it also sets **shape**: rounder corners, and
15
+ * its own `--loop-*` properties for what an application is drawn with —
16
+ * its accent, the stage behind it, a bubble, a frame, a face.
17
+ */
18
+ import { theme as primerTheme } from '@primer/react';
19
+ import { loopAccentVars, loopColors } from '../colors/loopColors';
20
+ import { buildThemeStyles } from '../css/createThemeCSSVars';
21
+ /* ── Light-mode colour definitions ───────────────────────────────────── */
22
+ const loopLight = {
23
+ canvas: {
24
+ default: loopColors.white,
25
+ subtle: loopColors.subtle,
26
+ },
27
+ fg: {
28
+ default: loopColors.ink,
29
+ muted: loopColors.gray,
30
+ onEmphasis: '#FFFFFF',
31
+ },
32
+ accent: {
33
+ fg: loopColors.loopText,
34
+ emphasis: loopColors.loopText,
35
+ muted: loopColors.loopBrand,
36
+ subtle: loopColors.loopTint,
37
+ },
38
+ success: {
39
+ fg: loopColors.successBrand,
40
+ emphasis: loopColors.successBrand,
41
+ muted: loopColors.successAccent,
42
+ subtle: loopColors.successTint,
43
+ },
44
+ attention: {
45
+ fg: loopColors.attentionBrand,
46
+ emphasis: loopColors.attentionBrand,
47
+ muted: loopColors.attentionAccent,
48
+ subtle: loopColors.attentionTint,
49
+ },
50
+ danger: {
51
+ fg: loopColors.dangerBrand,
52
+ emphasis: loopColors.dangerBrand,
53
+ muted: loopColors.dangerAccent,
54
+ subtle: loopColors.dangerTint,
55
+ },
56
+ severe: {
57
+ fg: loopColors.severeBrand,
58
+ emphasis: loopColors.severeBrand,
59
+ muted: loopColors.severeAccent,
60
+ subtle: loopColors.severeTint,
61
+ },
62
+ done: {
63
+ fg: loopColors.doneBrand,
64
+ emphasis: loopColors.doneBrand,
65
+ muted: loopColors.doneAccent,
66
+ subtle: loopColors.doneTint,
67
+ },
68
+ border: {
69
+ // Hairlines: 9% of the ink, as solid colours on white.
70
+ default: '#E9E9E7',
71
+ muted: '#F0F0EE',
72
+ },
73
+ btn: {
74
+ text: loopColors.ink,
75
+ bg: loopColors.subtle,
76
+ border: 'transparent',
77
+ hoverBg: '#ECECE9',
78
+ hoverBorder: 'transparent',
79
+ activeBg: '#E4E4E1',
80
+ activeBorder: 'transparent',
81
+ selectedBg: '#E4E4E1',
82
+ counterBg: 'rgba(17, 17, 17, 0.08)',
83
+ // The one filled button of a screen: ink on paper, not a colour.
84
+ primary: {
85
+ text: '#FFFFFF',
86
+ bg: loopColors.ink,
87
+ border: loopColors.ink,
88
+ hoverBg: '#2B2B2B',
89
+ hoverBorder: '#2B2B2B',
90
+ selectedBg: '#2B2B2B',
91
+ disabledText: 'rgba(255, 255, 255, 0.8)',
92
+ disabledBg: '#B9B9B5',
93
+ disabledBorder: '#B9B9B5',
94
+ icon: '#FFFFFF',
95
+ counterBg: 'rgba(255, 255, 255, 0.2)',
96
+ },
97
+ outline: {
98
+ text: loopColors.loopText,
99
+ hoverText: '#FFFFFF',
100
+ hoverBg: loopColors.loopText,
101
+ hoverBorder: loopColors.loopText,
102
+ hoverCounterBg: 'rgba(255, 255, 255, 0.2)',
103
+ selectedText: '#FFFFFF',
104
+ selectedBg: loopColors.loopHover,
105
+ selectedBorder: loopColors.loopHover,
106
+ disabledText: loopColors.gray,
107
+ disabledBg: loopColors.subtle,
108
+ disabledCounterBg: 'rgba(0, 0, 0, 0.05)',
109
+ counterBg: 'rgba(0, 0, 0, 0.05)',
110
+ counterFg: loopColors.loopText,
111
+ hoverCounterFg: '#FFFFFF',
112
+ disabledCounterFg: loopColors.gray,
113
+ },
114
+ danger: {
115
+ text: loopColors.dangerBrand,
116
+ hoverText: '#FFFFFF',
117
+ hoverBg: loopColors.dangerBrand,
118
+ hoverBorder: loopColors.dangerBrand,
119
+ hoverCounterBg: 'rgba(255, 255, 255, 0.2)',
120
+ selectedText: '#FFFFFF',
121
+ selectedBg: '#9C302A',
122
+ selectedBorder: '#9C302A',
123
+ disabledText: 'rgba(191, 63, 56, 0.5)',
124
+ disabledBg: loopColors.subtle,
125
+ disabledCounterBg: 'rgba(191, 63, 56, 0.05)',
126
+ counterBg: 'rgba(191, 63, 56, 0.1)',
127
+ counterFg: loopColors.dangerBrand,
128
+ hoverCounterFg: '#FFFFFF',
129
+ disabledCounterFg: 'rgba(191, 63, 56, 0.5)',
130
+ icon: loopColors.dangerBrand,
131
+ },
132
+ },
133
+ };
134
+ /* ── Dark-mode colour definitions ────────────────────────────────────── */
135
+ const loopDark = {
136
+ canvas: {
137
+ default: loopColors.black,
138
+ subtle: loopColors.subtleDark,
139
+ },
140
+ fg: {
141
+ default: loopColors.inkDark,
142
+ muted: loopColors.grayDark,
143
+ onEmphasis: '#FFFFFF',
144
+ },
145
+ accent: {
146
+ fg: loopColors.loopBright,
147
+ emphasis: loopColors.loopText,
148
+ muted: loopColors.loopBrand,
149
+ subtle: loopColors.loopTintDark,
150
+ },
151
+ success: {
152
+ fg: loopColors.successAccent,
153
+ emphasis: loopColors.successBrand,
154
+ muted: loopColors.successAccent,
155
+ subtle: '#12241B',
156
+ },
157
+ attention: {
158
+ fg: loopColors.attentionAccent,
159
+ emphasis: '#8A5710',
160
+ muted: loopColors.attentionAccent,
161
+ subtle: '#2A2010',
162
+ },
163
+ danger: {
164
+ fg: loopColors.dangerAccent,
165
+ emphasis: loopColors.dangerBrand,
166
+ muted: loopColors.dangerAccent,
167
+ subtle: '#2C1615',
168
+ },
169
+ severe: {
170
+ fg: loopColors.severeAccent,
171
+ emphasis: loopColors.severeBrand,
172
+ muted: loopColors.severeAccent,
173
+ subtle: '#2B1B10',
174
+ },
175
+ done: {
176
+ fg: loopColors.doneAccent,
177
+ emphasis: loopColors.doneBrand,
178
+ muted: loopColors.doneAccent,
179
+ subtle: '#1C1A27',
180
+ },
181
+ border: {
182
+ // Hairlines: 11% of the ink, as solid colours on near-black.
183
+ default: '#2C2C2D',
184
+ muted: '#232324',
185
+ },
186
+ btn: {
187
+ text: loopColors.inkDark,
188
+ bg: loopColors.subtleDark,
189
+ border: 'transparent',
190
+ hoverBg: '#28282B',
191
+ hoverBorder: 'transparent',
192
+ activeBg: '#303033',
193
+ activeBorder: 'transparent',
194
+ selectedBg: '#303033',
195
+ counterBg: 'rgba(243, 243, 241, 0.12)',
196
+ // The one filled button of a screen: paper on ink.
197
+ primary: {
198
+ text: loopColors.ink,
199
+ bg: loopColors.inkDark,
200
+ border: loopColors.inkDark,
201
+ hoverBg: '#DCDCD9',
202
+ hoverBorder: '#DCDCD9',
203
+ selectedBg: '#DCDCD9',
204
+ disabledText: 'rgba(17, 17, 17, 0.5)',
205
+ disabledBg: 'rgba(243, 243, 241, 0.35)',
206
+ disabledBorder: 'rgba(243, 243, 241, 0.2)',
207
+ icon: loopColors.ink,
208
+ counterBg: 'rgba(0, 0, 0, 0.2)',
209
+ },
210
+ outline: {
211
+ text: loopColors.loopBright,
212
+ hoverText: loopColors.loopOn,
213
+ hoverBg: loopColors.loopBright,
214
+ hoverBorder: loopColors.loopBright,
215
+ hoverCounterBg: 'rgba(0, 0, 0, 0.2)',
216
+ selectedText: loopColors.loopOn,
217
+ selectedBg: loopColors.loopBrand,
218
+ selectedBorder: loopColors.loopBrand,
219
+ disabledText: 'rgba(143, 229, 198, 0.5)',
220
+ disabledBg: 'rgba(143, 229, 198, 0.1)',
221
+ disabledCounterBg: 'rgba(143, 229, 198, 0.05)',
222
+ counterBg: 'rgba(143, 229, 198, 0.1)',
223
+ counterFg: loopColors.loopBright,
224
+ hoverCounterFg: loopColors.loopOn,
225
+ disabledCounterFg: 'rgba(143, 229, 198, 0.5)',
226
+ },
227
+ danger: {
228
+ text: loopColors.dangerAccent,
229
+ hoverText: '#FFFFFF',
230
+ hoverBg: loopColors.dangerBrand,
231
+ hoverBorder: loopColors.dangerAccent,
232
+ hoverCounterBg: 'rgba(255, 255, 255, 0.2)',
233
+ selectedText: '#FFFFFF',
234
+ selectedBg: '#9C302A',
235
+ selectedBorder: loopColors.dangerAccent,
236
+ disabledText: 'rgba(240, 138, 131, 0.5)',
237
+ disabledBg: 'rgba(240, 138, 131, 0.1)',
238
+ disabledCounterBg: 'rgba(240, 138, 131, 0.05)',
239
+ counterBg: 'rgba(240, 138, 131, 0.1)',
240
+ counterFg: loopColors.dangerAccent,
241
+ hoverCounterFg: '#FFFFFF',
242
+ disabledCounterFg: 'rgba(240, 138, 131, 0.5)',
243
+ icon: loopColors.dangerAccent,
244
+ },
245
+ },
246
+ };
247
+ /* ── Shape, type and motion ──────────────────────────────────────────── */
248
+ /**
249
+ * What the Loop theme sets beside colour, the same in both modes.
250
+ *
251
+ * Primer's own radii are made rounder; the `--loop-*` properties are what
252
+ * an application is drawn with. A face is an emoji at one of three sizes;
253
+ * motion has three durations and one easing.
254
+ */
255
+ export const loopShapeVars = {
256
+ '--borderRadius-small': '8px',
257
+ '--borderRadius-medium': '12px',
258
+ '--borderRadius-large': '16px',
259
+ '--borderRadius-default': '12px',
260
+ '--loop-radius-control': '999px',
261
+ '--loop-radius-card': '16px',
262
+ '--loop-radius-bubble': '20px',
263
+ '--loop-radius-frame': '24px',
264
+ '--loop-shadow-frame': '0 1px 2px rgba(0, 0, 0, 0.04), 0 12px 32px rgba(0, 0, 0, 0.07)',
265
+ '--loop-face-large': '72px',
266
+ '--loop-face-medium': '40px',
267
+ '--loop-face-small': '20px',
268
+ '--loop-motion-fast': '120ms',
269
+ '--loop-motion-medium': '200ms',
270
+ '--loop-motion-slow': '320ms',
271
+ '--loop-motion-easing': 'cubic-bezier(0.2, 0.8, 0.2, 1)',
272
+ };
273
+ /** The hairline between two surfaces, per mode. */
274
+ const loopHairline = {
275
+ light: 'rgba(17, 17, 17, 0.09)',
276
+ dark: 'rgba(255, 255, 255, 0.11)',
277
+ };
278
+ /* ── Exports ─────────────────────────────────────────────────────────── */
279
+ /**
280
+ * The Primer theme object.
281
+ *
282
+ * Since theming is done entirely via CSS custom properties
283
+ * (see `loopThemeStyles`), this is just the unmodified default Primer
284
+ * theme kept for backward compatibility.
285
+ */
286
+ export const loopTheme = primerTheme;
287
+ /**
288
+ * Inter, then the system's own sans-serif. One face, two weights (400
289
+ * and 600). The page is expected to load Inter; without it the system
290
+ * face is used, and nothing shifts but the letterforms.
291
+ */
292
+ export const loopFontFamily = 'Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';
293
+ /** Comprehensive Primer CSS-variable overrides for light & dark mode. */
294
+ export const loopThemeStyles = buildThemeStyles(loopLight, loopDark, {
295
+ fontFamily: loopFontFamily,
296
+ variables: {
297
+ light: {
298
+ ...loopShapeVars,
299
+ ...loopAccentVars('green', 'light'),
300
+ '--loop-hairline': loopHairline.light,
301
+ },
302
+ dark: {
303
+ ...loopShapeVars,
304
+ ...loopAccentVars('green', 'dark'),
305
+ '--loop-hairline': loopHairline.dark,
306
+ },
307
+ },
308
+ });
309
+ export default loopTheme;
@@ -119,7 +119,9 @@ export const setupPrimerPortals = (colormode) => {
119
119
  * `setupPrimerPortals` creates it; before that call there is none, and this
120
120
  * answers `null` rather than inventing one.
121
121
  */
122
- export const getPrimerPortalRoot = () => document.getElementById(PRIMER_PORTAL_ROOT_ID);
122
+ export const getPrimerPortalRoot = () => typeof document === 'undefined'
123
+ ? null
124
+ : document.getElementById(PRIMER_PORTAL_ROOT_ID);
123
125
  /* ─── camelCase → kebab-case ─────────────────────────────────────────── */
124
126
  const camelToKebab = (s) => s.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
125
127
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datalayer/primer-addons",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
4
4
  "license": "BSD-3-Clause",
5
5
  "scripts": {
6
6
  "build": "npm run build:lib",
@@ -33,17 +33,23 @@
33
33
  "homepage": "https://primer-addons.datalayer.tech",
34
34
  "dependencies": {
35
35
  "@datalayer/icons-react": "^1.0.0",
36
- "@datalayer/reactor": "^1.0.0",
36
+ "@datalayer/reactor": "^1.0.4",
37
37
  "@primer/octicons-react": "^19.35.0",
38
38
  "@primer/primitives": "^10.7.0",
39
39
  "@primer/react": "^37.31.0",
40
- "react": "19.2.8",
41
- "react-dom": "19.2.8",
40
+ "@primer/react-brand": "^0.58.2",
42
41
  "react-loading-skeleton": "^3.5.0",
43
42
  "styled-components": "^5.3.10",
44
43
  "zustand": "^5.0.0"
45
44
  },
45
+ "peerDependencies": {
46
+ "react": "^18.3.1 || ^19.0.0",
47
+ "react-dom": "^18.3.1 || ^19.0.0"
48
+ },
46
49
  "devDependencies": {
50
+ "react": "19.2.8",
51
+ "react-dom": "19.2.8",
52
+ "rimraf": "^6.0.1",
47
53
  "@storybook/addon-docs": "^9.0.15",
48
54
  "@storybook/addon-essentials": "9.0.0-alpha.12",
49
55
  "@storybook/addon-interactions": "^9.0.0-alpha.10",