@datalayer/primer-addons 1.0.38 → 1.0.40

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 (64) hide show
  1. package/README.md +52 -20
  2. package/lib/components/appearance/AppearanceControls.d.ts +6 -1
  3. package/lib/components/appearance/AppearanceControls.js +7 -3
  4. package/lib/components/appearance/AppearanceControlsWithStore.d.ts +4 -0
  5. package/lib/components/appearance/AppearanceControlsWithStore.js +4 -4
  6. package/lib/components/appearance/CollaboratorPalette.js +7 -20
  7. package/lib/components/box/Box.d.ts +103 -16
  8. package/lib/components/box/Box.js +157 -2
  9. package/lib/components/box/boxCss.d.ts +805 -0
  10. package/lib/components/box/boxCss.js +508 -0
  11. package/lib/components/box/boxTokens.d.ts +130 -0
  12. package/lib/components/box/boxTokens.js +125 -0
  13. package/lib/components/calendar-picker/CalendarPicker.js +2 -1
  14. package/lib/components/card/Card.d.ts +119 -5
  15. package/lib/components/card/Card.js +64 -41
  16. package/lib/components/card/Card.stories.d.ts +6 -0
  17. package/lib/components/card/Card.stories.js +26 -0
  18. package/lib/components/color/ColorSwatch.js +2 -1
  19. package/lib/components/color-picker/ColorPicker.js +8 -4
  20. package/lib/components/date-picker/DatePicker.d.ts +12 -3
  21. package/lib/components/date-picker/DatePicker.js +24 -8
  22. package/lib/components/entity-avatar/EntityAvatar.d.ts +73 -0
  23. package/lib/components/entity-avatar/EntityAvatar.js +63 -0
  24. package/lib/components/entity-avatar/index.d.ts +1 -0
  25. package/lib/components/entity-avatar/index.js +5 -0
  26. package/lib/components/hover-card/HoverCard.d.ts +63 -0
  27. package/lib/components/hover-card/HoverCard.js +55 -0
  28. package/lib/components/hover-card/HoverCardAnchor.d.ts +33 -0
  29. package/lib/components/hover-card/HoverCardAnchor.js +26 -0
  30. package/lib/components/hover-card/HoverCardDetails.d.ts +36 -0
  31. package/lib/components/hover-card/HoverCardDetails.js +65 -0
  32. package/lib/components/hover-card/HoverCardLayer.d.ts +34 -0
  33. package/lib/components/hover-card/HoverCardLayer.js +57 -0
  34. package/lib/components/hover-card/index.d.ts +12 -0
  35. package/lib/components/hover-card/index.js +16 -0
  36. package/lib/components/hover-card/useHoverCard.d.ts +57 -0
  37. package/lib/components/hover-card/useHoverCard.js +200 -0
  38. package/lib/components/hover-card/usePrefersReducedMotion.d.ts +10 -0
  39. package/lib/components/hover-card/usePrefersReducedMotion.js +28 -0
  40. package/lib/components/index.d.ts +3 -0
  41. package/lib/components/index.js +3 -0
  42. package/lib/components/sheet/Sheet.d.ts +15 -0
  43. package/lib/components/sheet/Sheet.js +21 -0
  44. package/lib/reactor/page-layout/PageLayout.js +4 -6
  45. package/lib/story-helpers.d.ts +2 -2
  46. package/lib/theme/DatalayerThemeProvider.d.ts +21 -0
  47. package/lib/theme/DatalayerThemeProvider.js +8 -2
  48. package/lib/theme/colors/index.d.ts +2 -1
  49. package/lib/theme/colors/index.js +2 -1
  50. package/lib/theme/colors/loopColors.d.ts +2 -48
  51. package/lib/theme/colors/loopColors.js +2 -98
  52. package/lib/theme/colors/themeAccents.d.ts +81 -0
  53. package/lib/theme/colors/themeAccents.js +139 -0
  54. package/lib/theme/css/createThemeCSSVars.d.ts +18 -1
  55. package/lib/theme/css/createThemeCSSVars.js +20 -1
  56. package/lib/theme/css/primerBaseVars.d.ts +1 -0
  57. package/lib/theme/css/primerBaseVars.js +72 -0
  58. package/lib/theme/css/primerComponentsCss.d.ts +47 -0
  59. package/lib/theme/css/primerComponentsCss.js +72 -0
  60. package/lib/theme/index.d.ts +2 -0
  61. package/lib/theme/index.js +2 -0
  62. package/lib/theme/themes/loopThemeStyles.d.ts +4 -37
  63. package/lib/theme/themes/loopThemeStyles.js +39 -56
  64. package/package.json +1 -1
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Theme accents – the colour an application names, over any theme.
3
+ *
4
+ * Six soft accents, each with the dark text that sits on it (the lowest
5
+ * contrast of the six is 8.8 to 1), the tint of the stage behind an
6
+ * application, a quiet tint, and the accent as text. They were drawn for
7
+ * the `loop` theme — green, mint, is `loop`'s own — and, since 2026-10-07
8
+ * (decided by the user), they colour every theme: `themeAccentVars` sets
9
+ * Primer's own accent and primary properties, so the filled button, links,
10
+ * the accent tokens and a selected tab take the accent whatever theme an
11
+ * application wears.
12
+ */
13
+ import type { ThemeColorDefs } from '../css/createThemeCSSVars';
14
+ /** The accents an application may take, by name. */
15
+ export type ThemeAccentName = 'green' | 'rose' | 'sky' | 'lime' | 'sun' | 'violet';
16
+ /** An accent: its values, in light and in dark. */
17
+ export interface ThemeAccent {
18
+ /** The accent itself: a bubble, a send button. The same in both modes. */
19
+ accent: string;
20
+ /** The text that sits on the accent. */
21
+ on: string;
22
+ /** The stage behind an application. */
23
+ stage: {
24
+ light: string;
25
+ dark: string;
26
+ };
27
+ /** A quiet tint: a draft, something waiting. */
28
+ quiet: {
29
+ light: string;
30
+ dark: string;
31
+ };
32
+ /**
33
+ * The accent as text: a link, a starter, an accent's word — deep enough on
34
+ * white (4.5 to 1), and the pastel itself on dark.
35
+ */
36
+ text: {
37
+ light: string;
38
+ dark: string;
39
+ };
40
+ }
41
+ /** The six accents. One per application; everything else is the theme's. Green — mint — is `loop`'s own. */
42
+ export declare const themeAccents: Record<ThemeAccentName, ThemeAccent>;
43
+ /** The names of the accents, in the order a picker shows them. */
44
+ export declare const themeAccentNames: ThemeAccentName[];
45
+ /**
46
+ * The stage, lit: a soft fall from the stage tint at the top to the quiet
47
+ * tint at the bottom, for the page an application sits on. Written with the
48
+ * colours themselves, not with `var(--theme-stage)`: a custom property is
49
+ * resolved where it is set, so a gradient inherited from the theme's root
50
+ * would keep the theme's tints under an application's own.
51
+ */
52
+ export declare function themeStageGradient(stage: string, quiet: string): string;
53
+ /**
54
+ * The accent's own custom properties, which every theme sets (its default
55
+ * from its colours, `themeTintVars`) and an application's accent replaces:
56
+ * the accent, the text on it, the stage, the quiet tint and the stage lit.
57
+ */
58
+ export declare function themeAccentTints(accent: Pick<ThemeAccent, 'accent' | 'on'> & {
59
+ stage: string;
60
+ quiet: string;
61
+ }): Record<string, string>;
62
+ /**
63
+ * A theme's default accent properties, from its own colours: its accent
64
+ * fill and the text of its filled button, the accent's subtle tint as the
65
+ * stage, the subtle canvas as the quiet tint.
66
+ */
67
+ export declare function themeTintVars(defs: ThemeColorDefs): Record<string, string>;
68
+ /**
69
+ * An application's accent as everything it colours, over any theme (LOOP
70
+ * T-05, T-30): the accent's own properties (`--theme-accent`,
71
+ * `--theme-accent-on`, `--theme-stage`, `--theme-quiet`,
72
+ * `--theme-stage-gradient`), and Primer's — the accent fill, text, links,
73
+ * muted border and tint, the filled button, a checked switch, a selected
74
+ * tab — so that nothing on its page keeps the theme's default accent beside
75
+ * its own (T-18). The theme's focus ring is kept: it is drawn to show around
76
+ * every accent (T-15). Set on an application's root, it wears its own
77
+ * colour; the page around keeps the theme's.
78
+ *
79
+ * An unknown name is refused.
80
+ */
81
+ export declare function themeAccentVars(name: ThemeAccentName, mode?: 'light' | 'dark'): Record<string, string>;
@@ -0,0 +1,139 @@
1
+ /*
2
+ * Copyright (c) 2023-2026 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ /** The six accents. One per application; everything else is the theme's. Green — mint — is `loop`'s own. */
6
+ export const themeAccents = {
7
+ green: {
8
+ accent: '#7ADBB8',
9
+ on: '#06281E',
10
+ stage: { light: '#DDF5EC', dark: '#10261F' },
11
+ quiet: { light: '#F0FAF6', dark: '#17211D' },
12
+ text: { light: '#248462', dark: '#8FE5C6' },
13
+ },
14
+ rose: {
15
+ accent: '#F6A5C1',
16
+ on: '#3A0A1C',
17
+ stage: { light: '#FCE3EC', dark: '#2B141C' },
18
+ quiet: { light: '#FDF2F6', dark: '#22181C' },
19
+ text: { light: '#B83A6B', dark: '#F6A5C1' },
20
+ },
21
+ sky: {
22
+ accent: '#8CCBF9',
23
+ on: '#06243B',
24
+ stage: { light: '#DFF0FD', dark: '#0F2333' },
25
+ quiet: { light: '#F0F8FE', dark: '#161E25' },
26
+ text: { light: '#1F6FB0', dark: '#8CCBF9' },
27
+ },
28
+ lime: {
29
+ accent: '#BEDC55',
30
+ on: '#1F2A00',
31
+ stage: { light: '#EEF6CC', dark: '#1E2609' },
32
+ quiet: { light: '#F7FBE6', dark: '#1C2014' },
33
+ text: { light: '#5F7A00', dark: '#BEDC55' },
34
+ },
35
+ sun: {
36
+ accent: '#F8D469',
37
+ on: '#2E2200',
38
+ stage: { light: '#FDF3CD', dark: '#2A2209' },
39
+ quiet: { light: '#FEF9E7', dark: '#221F14' },
40
+ text: { light: '#8A6A00', dark: '#F8D469' },
41
+ },
42
+ violet: {
43
+ accent: '#C0AEF6',
44
+ on: '#1C0F47',
45
+ stage: { light: '#ECE7FD', dark: '#1B1533' },
46
+ quiet: { light: '#F6F3FE', dark: '#1C1A27' },
47
+ text: { light: '#6B53C9', dark: '#C0AEF6' },
48
+ },
49
+ };
50
+ /** The names of the accents, in the order a picker shows them. */
51
+ export const themeAccentNames = ['green', 'rose', 'sky', 'lime', 'sun', 'violet'];
52
+ /**
53
+ * The stage, lit: a soft fall from the stage tint at the top to the quiet
54
+ * tint at the bottom, for the page an application sits on. Written with the
55
+ * colours themselves, not with `var(--theme-stage)`: a custom property is
56
+ * resolved where it is set, so a gradient inherited from the theme's root
57
+ * would keep the theme's tints under an application's own.
58
+ */
59
+ export function themeStageGradient(stage, quiet) {
60
+ return `radial-gradient(140% 100% at 50% 0%, ${stage} 0%, ${quiet} 100%)`;
61
+ }
62
+ /**
63
+ * The accent's own custom properties, which every theme sets (its default
64
+ * from its colours, `themeTintVars`) and an application's accent replaces:
65
+ * the accent, the text on it, the stage, the quiet tint and the stage lit.
66
+ */
67
+ export function themeAccentTints(accent) {
68
+ return {
69
+ '--theme-accent': accent.accent,
70
+ '--theme-accent-on': accent.on,
71
+ '--theme-stage': accent.stage,
72
+ '--theme-quiet': accent.quiet,
73
+ '--theme-stage-gradient': themeStageGradient(accent.stage, accent.quiet),
74
+ };
75
+ }
76
+ /**
77
+ * A theme's default accent properties, from its own colours: its accent
78
+ * fill and the text of its filled button, the accent's subtle tint as the
79
+ * stage, the subtle canvas as the quiet tint.
80
+ */
81
+ export function themeTintVars(defs) {
82
+ return themeAccentTints({
83
+ accent: defs.accent.emphasis,
84
+ on: defs.btn.primary.text,
85
+ stage: defs.accent.subtle ?? defs.canvas.subtle ?? defs.canvas.default,
86
+ quiet: defs.canvas.subtle ?? defs.canvas.default,
87
+ });
88
+ }
89
+ /**
90
+ * An application's accent as everything it colours, over any theme (LOOP
91
+ * T-05, T-30): the accent's own properties (`--theme-accent`,
92
+ * `--theme-accent-on`, `--theme-stage`, `--theme-quiet`,
93
+ * `--theme-stage-gradient`), and Primer's — the accent fill, text, links,
94
+ * muted border and tint, the filled button, a checked switch, a selected
95
+ * tab — so that nothing on its page keeps the theme's default accent beside
96
+ * its own (T-18). The theme's focus ring is kept: it is drawn to show around
97
+ * every accent (T-15). Set on an application's root, it wears its own
98
+ * colour; the page around keeps the theme's.
99
+ *
100
+ * An unknown name is refused.
101
+ */
102
+ export function themeAccentVars(name, mode = 'light') {
103
+ const accent = themeAccents[name];
104
+ if (!accent) {
105
+ throw new Error(`There is no accent "${name}"; the accents are ${themeAccentNames.join(', ')}.`);
106
+ }
107
+ return {
108
+ ...themeAccentTints({
109
+ accent: accent.accent,
110
+ on: accent.on,
111
+ stage: accent.stage[mode],
112
+ quiet: accent.quiet[mode],
113
+ }),
114
+ '--bgColor-accent-emphasis': accent.accent,
115
+ '--borderColor-accent-emphasis': accent.accent,
116
+ '--fgColor-accent': accent.text[mode],
117
+ '--fgColor-link': accent.text[mode],
118
+ '--borderColor-accent-muted': accent.accent,
119
+ '--bgColor-accent-muted': accent.quiet[mode],
120
+ '--underlineNav-borderColor-active': accent.accent,
121
+ '--button-primary-bgColor-rest': accent.accent,
122
+ '--button-primary-borderColor-rest': accent.accent,
123
+ '--button-primary-bgColor-hover': accent.accent,
124
+ '--button-primary-borderColor-hover': accent.accent,
125
+ '--button-primary-bgColor-active': accent.accent,
126
+ '--button-primary-borderColor-active': accent.accent,
127
+ '--button-primary-fgColor-rest': accent.on,
128
+ '--button-primary-iconColor-rest': accent.on,
129
+ '--buttonCounter-primary-fgColor-rest': accent.on,
130
+ '--color-btn-primary-bg': accent.accent,
131
+ '--color-btn-primary-hover-bg': accent.accent,
132
+ '--control-checked-bgColor-rest': accent.accent,
133
+ '--control-checked-bgColor-hover': accent.accent,
134
+ '--control-checked-bgColor-active': accent.accent,
135
+ '--control-checked-fgColor-rest': accent.on,
136
+ '--controlKnob-borderColor-checked': accent.accent,
137
+ '--datalayer-icon-fg': accent.text[mode],
138
+ };
139
+ }
@@ -195,6 +195,14 @@ export interface ThemeStyles {
195
195
  * And how a link reads in a message (LOOP T-06): in the accent, as today, or
196
196
  * — `currentColor` — plain, the colour of the words around it, underlined in
197
197
  * every theme.
198
+ *
199
+ * And the corner of a panel floating over the page — a menu, a header's
200
+ * mega-menu (`--theme-radius-overlay`, `borderRadius="overlay"` on a Box).
201
+ *
202
+ * And Primer's own components, as the theme draws them: a data table's
203
+ * corner, header band, header text and hairline. Primer's values unless the
204
+ * theme says otherwise; what a theme says about a control or a table is
205
+ * drawn by the stylesheet `primerComponentsCss` makes of it.
198
206
  */
199
207
  export interface ThemeShape {
200
208
  radiusControl: string;
@@ -208,6 +216,11 @@ export interface ThemeShape {
208
216
  motionPane: string;
209
217
  motionEasing: string;
210
218
  messageLink: string;
219
+ radiusTable: string;
220
+ radiusOverlay: string;
221
+ tableHeaderBg: string;
222
+ tableHeaderFg: string;
223
+ tableBorder: string;
211
224
  }
212
225
  /** Today's shape, which every theme has unless it says otherwise. */
213
226
  export declare const DEFAULT_THEME_SHAPE: ThemeShape;
@@ -225,6 +238,10 @@ export declare function buildThemeStyles(light: ThemeColorDefs, dark: ThemeColor
225
238
  light?: Record<string, string>;
226
239
  dark?: Record<string, string>;
227
240
  };
228
- /** A stylesheet of the theme's own, relative to `:scope`; see `ThemeStyles.css`. */
241
+ /**
242
+ * A stylesheet of the theme's own, relative to `:scope`; see
243
+ * `ThemeStyles.css`. It follows what `primerComponentsCss` makes of the
244
+ * shape.
245
+ */
229
246
  css?: string;
230
247
  }): ThemeStyles;
@@ -2,6 +2,8 @@
2
2
  * Copyright (c) 2023-2025 Datalayer, Inc.
3
3
  * Distributed under the terms of the Modified BSD License.
4
4
  */
5
+ import { themeTintVars } from '../colors/themeAccents';
6
+ import { primerComponentsCss } from './primerComponentsCss';
5
7
  /* ─── Helper ──────────────────────────────────────────────────────────── */
6
8
  /**
7
9
  * Convert a structured `ThemeColorDefs` object into a flat
@@ -259,6 +261,14 @@ export const DEFAULT_THEME_SHAPE = {
259
261
  motionPane: '0ms',
260
262
  motionEasing: 'ease',
261
263
  messageLink: 'var(--fgColor-accent, #0969da)',
264
+ // Primer's own DataTable: its corner, its header band and text, its hairline.
265
+ radiusTable: '0.375rem',
266
+ // A panel that floats over the page — a menu, a header's mega-menu: Primer's
267
+ // overlay corner unless the theme says otherwise.
268
+ radiusOverlay: 'var(--borderRadius-large, 12px)',
269
+ tableHeaderBg: 'var(--bgColor-muted)',
270
+ tableHeaderFg: 'var(--fgColor-muted)',
271
+ tableBorder: 'var(--borderColor-default)',
262
272
  };
263
273
  /** A shape as custom properties. */
264
274
  export function shapeVars(shape = {}) {
@@ -275,9 +285,16 @@ export function shapeVars(shape = {}) {
275
285
  '--theme-motion-pane': full.motionPane,
276
286
  '--theme-motion-easing': full.motionEasing,
277
287
  '--theme-message-link': full.messageLink,
288
+ '--theme-radius-table': full.radiusTable,
289
+ '--theme-radius-overlay': full.radiusOverlay,
290
+ '--theme-table-header-bg': full.tableHeaderBg,
291
+ '--theme-table-header-fg': full.tableHeaderFg,
292
+ '--theme-table-border': full.tableBorder,
278
293
  };
279
294
  }
280
295
  export function buildThemeStyles(light, dark, options) {
296
+ // What the shape says about Primer's components, then the theme's own.
297
+ const css = primerComponentsCss(options?.shape) + (options?.css ?? '');
281
298
  const fontVars = {};
282
299
  if (options?.fontFamily) {
283
300
  const f = options.fontFamily;
@@ -310,6 +327,7 @@ export function buildThemeStyles(light, dark, options) {
310
327
  ...colorDefsToCSS(light, 'light'),
311
328
  ...fontVars,
312
329
  ...shapeVars(options?.shape),
330
+ ...themeTintVars(light),
313
331
  ...(options?.variables?.light ?? {}),
314
332
  },
315
333
  dark: {
@@ -320,8 +338,9 @@ export function buildThemeStyles(light, dark, options) {
320
338
  ...colorDefsToCSS(dark, 'dark'),
321
339
  ...fontVars,
322
340
  ...shapeVars(options?.shape),
341
+ ...themeTintVars(dark),
323
342
  ...(options?.variables?.dark ?? {}),
324
343
  },
325
- ...(options?.css ? { css: options.css } : {}),
344
+ ...(css ? { css } : {}),
326
345
  };
327
346
  }
@@ -0,0 +1 @@
1
+ export declare const primerBaseVars: Record<'light' | 'dark', Record<string, string>>;
@@ -0,0 +1,72 @@
1
+ /*
2
+ * Copyright (c) 2023-2026 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ /**
6
+ * Primer's own CSS variables that no theme sets but that a page still reads
7
+ * — the radii, the neutral and sponsor colours, the open and closed states,
8
+ * the four elevation shadows — at Primer's own values (`@primer/primitives`,
9
+ * functional themes light and dark).
10
+ *
11
+ * The apps do not load the primitives' stylesheets, so Primer components
12
+ * draw these through the fallbacks written in their own CSS. `Box` emits
13
+ * the variable alone, with no fallback (see `components/box/Box.tsx`), so
14
+ * the theme provider sets every variable `Box` can emit: these, under the
15
+ * theme's own (`themeStyles`), which win where a theme says otherwise — the
16
+ * `loop` theme's radii and shadows.
17
+ */
18
+ const radii = {
19
+ '--borderRadius-small': '3px',
20
+ '--borderRadius-medium': '6px',
21
+ '--borderRadius-large': '12px',
22
+ '--borderRadius-full': '9999px',
23
+ };
24
+ /** The open and closed states are success and danger, as in Primer. */
25
+ const states = {
26
+ '--fgColor-open': 'var(--fgColor-success)',
27
+ '--bgColor-open-emphasis': 'var(--bgColor-success-emphasis)',
28
+ '--borderColor-open-muted': 'var(--borderColor-success-muted)',
29
+ '--bgColor-open-muted': 'var(--bgColor-success-muted)',
30
+ '--fgColor-closed': 'var(--fgColor-danger)',
31
+ '--bgColor-closed-emphasis': 'var(--bgColor-danger-emphasis)',
32
+ '--borderColor-closed-muted': 'var(--borderColor-danger-muted)',
33
+ '--bgColor-closed-muted': 'var(--bgColor-danger-muted)',
34
+ };
35
+ export const primerBaseVars = {
36
+ light: {
37
+ ...radii,
38
+ ...states,
39
+ '--bgColor-emphasis': '#25292e',
40
+ '--bgColor-neutral-emphasis': '#59636e',
41
+ '--bgColor-neutral-muted': '#818b981f',
42
+ '--fgColor-sponsors': '#bf3989',
43
+ '--bgColor-sponsors-emphasis': '#bf3989',
44
+ '--borderColor-sponsors-muted': '#ff80c866',
45
+ '--bgColor-sponsors-muted': '#ffeff7',
46
+ '--shadow-resting-xsmall': '0px 1px 1px 0px #1f23280f',
47
+ '--shadow-resting-small': '0px 1px 1px 0px #1f23280f, 0px 1px 3px 0px #1f23280f',
48
+ '--shadow-resting-medium': '0px 1px 1px 0px #25292e1a, 0px 3px 6px 0px #25292e1f',
49
+ '--shadow-floating-small': '0px 0px 0px 1px #d1d9e080, 0px 6px 12px -3px #25292e0a, 0px 6px 18px 0px #25292e1f',
50
+ '--shadow-floating-medium': '0px 0px 0px 1px #d1d9e0, 0px 8px 16px -4px #25292e14, 0px 4px 32px -4px #25292e14, 0px 24px 48px -12px #25292e14, 0px 48px 96px -24px #25292e14',
51
+ '--shadow-floating-large': '0px 0px 0px 1px #d1d9e0, 0px 40px 80px 0px #25292e3d',
52
+ '--shadow-floating-xlarge': '0px 0px 0px 1px #d1d9e0, 0px 56px 112px 0px #25292e52',
53
+ },
54
+ dark: {
55
+ ...radii,
56
+ ...states,
57
+ '--bgColor-emphasis': '#3d444d',
58
+ '--bgColor-neutral-emphasis': '#656c76',
59
+ '--bgColor-neutral-muted': '#656c7633',
60
+ '--fgColor-sponsors': '#db61a2',
61
+ '--bgColor-sponsors-emphasis': '#bf4b8a',
62
+ '--borderColor-sponsors-muted': '#db61a266',
63
+ '--bgColor-sponsors-muted': '#db61a21a',
64
+ '--shadow-resting-xsmall': '0px 1px 1px 0px #010409cc',
65
+ '--shadow-resting-small': '0px 1px 1px 0px #01040999, 0px 1px 3px 0px #01040999',
66
+ '--shadow-resting-medium': '0px 1px 1px 0px #01040966, 0px 3px 6px 0px #010409cc',
67
+ '--shadow-floating-small': '0px 0px 0px 1px #3d444d, 0px 6px 12px -3px #01040966, 0px 6px 18px 0px #01040966',
68
+ '--shadow-floating-medium': '0px 0px 0px 1px #3d444d, 0px 8px 16px -4px #01040966, 0px 4px 32px -4px #01040966, 0px 24px 48px -12px #01040966, 0px 48px 96px -24px #01040966',
69
+ '--shadow-floating-large': '0px 0px 0px 1px #3d444d, 0px 24px 48px 0px #010409',
70
+ '--shadow-floating-xlarge': '0px 0px 0px 1px #3d444d, 0px 32px 64px 0px #010409',
71
+ },
72
+ };
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Primer's own components, drawn by the theme's shape.
3
+ *
4
+ * A theme's shape (`ThemeShape`) names a control's corner and a table's
5
+ * corner, header and hairline. Primer takes a control's corners from
6
+ * `--borderRadius-medium`, which cards and list items take too, and a data
7
+ * table's from its own `--table-border-radius`, so none of this can be a
8
+ * token alone: it is a stylesheet, scoped by the theme provider
9
+ * (`ThemeStyles.css`), with one rule per thing the theme says. A theme that
10
+ * says nothing gets no rule and keeps Primer's look, and no stylesheet.
11
+ *
12
+ * Primer's class names are CSS-module hashes (`prc-Button-ButtonBase-c50BI`),
13
+ * so the selectors match their stable prefix; the toggle switch is a
14
+ * styled-component, matched by its display name, which styled-components
15
+ * puts in its class (`ToggleSwitch__SwitchButton-sc-e6gszy-0`). A test reads
16
+ * each of them back from the installed `@primer/react`.
17
+ */
18
+ import type { ThemeShape } from './createThemeCSSVars';
19
+ export declare const primerComponentSelectors: {
20
+ readonly button: "[class*=\"prc-Button-ButtonBase\"]";
21
+ readonly textInput: "[class*=\"prc-components-TextInputBaseWrapper\"]";
22
+ readonly textArea: "[class*=\"prc-Textarea-TextArea\"]";
23
+ readonly segmentedControl: "[class*=\"prc-SegmentedControl-SegmentedControl\"]";
24
+ readonly buttonGroup: "[class*=\"prc-ButtonGroup-ButtonGroup\"]";
25
+ readonly underlineTab: "[class*=\"prc-components-UnderlineItem\"]";
26
+ readonly toggleTrack: "[class*=\"ToggleSwitch__SwitchButton-\"]";
27
+ readonly toggleKnob: "[class*=\"ToggleSwitch__ToggleKnob-\"]";
28
+ readonly table: "[class*=\"prc-DataTable-Table-\"]";
29
+ readonly tableHeader: "[class*=\"prc-DataTable-TableHeader-\"]";
30
+ readonly tableCell: "[class*=\"prc-DataTable-TableCell-\"]";
31
+ };
32
+ /**
33
+ * The stylesheet for what a theme's shape says about Primer's components;
34
+ * empty when it says nothing about them.
35
+ *
36
+ * - `radiusControl` — every single-line control: a button, a text input, a
37
+ * select, a segmented control (outside and each segment), a button
38
+ * group's two ends, a toggle switch, an underline tab's hover. A
39
+ * multi-line text area keeps `--borderRadius-medium`: a pill of many
40
+ * lines is a lozenge. Where a control draws more than one element from the
41
+ * token — a segmented control's track and segments, a button group's ends
42
+ * — the token itself is set on the control, and Primer's rules draw it.
43
+ * - `radiusTable` — a data table's outer corners (`--table-border-radius`).
44
+ * - `tableHeaderBg`, `tableHeaderFg` — its header band and header text.
45
+ * - `tableBorder` — the hairline between and around its cells.
46
+ */
47
+ export declare function primerComponentsCss(shape?: Partial<ThemeShape>): string;
@@ -0,0 +1,72 @@
1
+ /*
2
+ * Copyright (c) 2023-2026 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ export const primerComponentSelectors = {
6
+ button: '[class*="prc-Button-ButtonBase"]',
7
+ textInput: '[class*="prc-components-TextInputBaseWrapper"]',
8
+ textArea: '[class*="prc-Textarea-TextArea"]',
9
+ segmentedControl: '[class*="prc-SegmentedControl-SegmentedControl"]',
10
+ buttonGroup: '[class*="prc-ButtonGroup-ButtonGroup"]',
11
+ underlineTab: '[class*="prc-components-UnderlineItem"]',
12
+ toggleTrack: '[class*="ToggleSwitch__SwitchButton-"]',
13
+ toggleKnob: '[class*="ToggleSwitch__ToggleKnob-"]',
14
+ table: '[class*="prc-DataTable-Table-"]',
15
+ tableHeader: '[class*="prc-DataTable-TableHeader-"]',
16
+ tableCell: '[class*="prc-DataTable-TableCell-"]',
17
+ };
18
+ const sel = primerComponentSelectors;
19
+ /**
20
+ * The stylesheet for what a theme's shape says about Primer's components;
21
+ * empty when it says nothing about them.
22
+ *
23
+ * - `radiusControl` — every single-line control: a button, a text input, a
24
+ * select, a segmented control (outside and each segment), a button
25
+ * group's two ends, a toggle switch, an underline tab's hover. A
26
+ * multi-line text area keeps `--borderRadius-medium`: a pill of many
27
+ * lines is a lozenge. Where a control draws more than one element from the
28
+ * token — a segmented control's track and segments, a button group's ends
29
+ * — the token itself is set on the control, and Primer's rules draw it.
30
+ * - `radiusTable` — a data table's outer corners (`--table-border-radius`).
31
+ * - `tableHeaderBg`, `tableHeaderFg` — its header band and header text.
32
+ * - `tableBorder` — the hairline between and around its cells.
33
+ */
34
+ export function primerComponentsCss(shape = {}) {
35
+ const rules = [];
36
+ if (shape.radiusControl !== undefined) {
37
+ rules.push(`:scope ${sel.button},
38
+ :scope ${sel.textInput}:not(:has(${sel.textArea})),
39
+ :scope ${sel.segmentedControl},
40
+ :scope ${sel.underlineTab},
41
+ :scope ${sel.toggleTrack},
42
+ :scope ${sel.toggleKnob} {
43
+ --borderRadius-medium: var(--theme-radius-control);
44
+ border-radius: var(--theme-radius-control);
45
+ }
46
+ :scope ${sel.buttonGroup} {
47
+ --borderRadius-medium: var(--theme-radius-control);
48
+ }`);
49
+ }
50
+ if (shape.radiusTable !== undefined) {
51
+ rules.push(`:scope ${sel.table} {
52
+ --table-border-radius: var(--theme-radius-table);
53
+ }`);
54
+ }
55
+ const header = [];
56
+ if (shape.tableHeaderBg !== undefined) {
57
+ header.push(' background-color: var(--theme-table-header-bg);');
58
+ }
59
+ if (shape.tableHeaderFg !== undefined) {
60
+ header.push(' color: var(--theme-table-header-fg);');
61
+ }
62
+ if (header.length) {
63
+ rules.push(`:scope ${sel.tableHeader} {\n${header.join('\n')}\n}`);
64
+ }
65
+ if (shape.tableBorder !== undefined) {
66
+ rules.push(`:scope ${sel.tableHeader},
67
+ :scope ${sel.tableCell} {
68
+ border-color: var(--theme-table-border);
69
+ }`);
70
+ }
71
+ return rules.length ? `\n${rules.join('\n')}\n` : '';
72
+ }
@@ -1,6 +1,8 @@
1
1
  export * from './colors';
2
2
  export * from './indicators';
3
3
  export * from './css/createThemeCSSVars';
4
+ export * from './css/primerComponentsCss';
5
+ export * from './css/primerBaseVars';
4
6
  export * from './themes/datalayerTheme';
5
7
  export * from './DatalayerThemeProvider';
6
8
  export * from './DatalayerBrandThemeProvider';
@@ -5,6 +5,8 @@
5
5
  export * from './colors';
6
6
  export * from './indicators';
7
7
  export * from './css/createThemeCSSVars';
8
+ export * from './css/primerComponentsCss';
9
+ export * from './css/primerBaseVars';
8
10
  export * from './themes/datalayerTheme';
9
11
  export * from './DatalayerThemeProvider';
10
12
  export * from './DatalayerBrandThemeProvider';
@@ -63,12 +63,6 @@ export declare const loopFontWeights: {
63
63
  readonly semibold: 600;
64
64
  };
65
65
  export declare const loopTypeVars: (font: string) => Record<string, string>;
66
- /**
67
- * The stage, lit: a soft fall from the stage tint at the top to the quiet
68
- * tint at the bottom, for the page an application sits on. Both tints are
69
- * the accent's, so an application's own colour lights its stage.
70
- */
71
- export declare const loopStageGradient = "radial-gradient(140% 100% at 50% 0%, var(--loop-stage) 0%, var(--loop-quiet) 100%)";
72
66
  /**
73
67
  * Inter, then its metric-matched fallback, then the system's own sans-serif
74
68
  * (LOOP T-04). One face, two weights (400 and 600). The face is served by the
@@ -99,37 +93,10 @@ export declare const loopFocusRing: {
99
93
  readonly light: string;
100
94
  readonly dark: "#636363";
101
95
  };
96
+ /** Comprehensive Primer CSS-variable overrides for light & dark mode. */
97
+ export declare const loopThemeStyles: import("../css/createThemeCSSVars").ThemeStyles;
102
98
  /**
103
- * The controls, as one family (LOOP T-09): every single-line control is a
104
- * pill — a button, a text input, a select, a segmented control (outside and
105
- * each segment), a button group's two ends, a toggle switch, an underline
106
- * tab's hover. A multi-line text area keeps `--borderRadius-medium`: a pill
107
- * of many lines is a lozenge. Menus and overlays keep the card's radius,
108
- * `--borderRadius-large`, which the theme already sets.
109
- *
110
- * Primer takes every control's corners from `--borderRadius-medium`, which
111
- * cards and list items take too, so this cannot be a token: it is a
112
- * stylesheet, scoped by the theme provider (`ThemeStyles.css`). Primer's
113
- * class names are CSS-module hashes (`prc-Button-ButtonBase-c50BI`), so the
114
- * selectors match their stable prefix; the toggle switch is a
115
- * styled-component, matched by its display name, which styled-components
116
- * puts in its class (`ToggleSwitch__SwitchButton-sc-e6gszy-0`). A test reads each of them
117
- * back from the installed `@primer/react`.
118
- *
119
- * Where a control draws more than one element from the token — a segmented
120
- * control's track and segments, a button group's ends — the token itself is
121
- * set on the control, and Primer's own rules draw the pill.
99
+ * The loop theme's whole stylesheet (`ThemeStyles.css`): its controls as
100
+ * pills and its tables rounder, drawn from its shape, then its own rules.
122
101
  */
123
- export declare const loopControlsSelectors: {
124
- readonly button: "[class*=\"prc-Button-ButtonBase\"]";
125
- readonly textInput: "[class*=\"prc-components-TextInputBaseWrapper\"]";
126
- readonly textArea: "[class*=\"prc-Textarea-TextArea\"]";
127
- readonly segmentedControl: "[class*=\"prc-SegmentedControl-SegmentedControl\"]";
128
- readonly buttonGroup: "[class*=\"prc-ButtonGroup-ButtonGroup\"]";
129
- readonly underlineTab: "[class*=\"prc-components-UnderlineItem\"]";
130
- readonly toggleTrack: "[class*=\"ToggleSwitch__SwitchButton-\"]";
131
- readonly toggleKnob: "[class*=\"ToggleSwitch__ToggleKnob-\"]";
132
- };
133
102
  export declare const loopControlsCss: string;
134
- /** Comprehensive Primer CSS-variable overrides for light & dark mode. */
135
- export declare const loopThemeStyles: import("../css/createThemeCSSVars").ThemeStyles;