@datalayer/primer-addons 1.0.39 → 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 (36) hide show
  1. package/lib/components/box/boxCss.js +17 -1
  2. package/lib/components/box/boxTokens.d.ts +2 -1
  3. package/lib/components/box/boxTokens.js +2 -1
  4. package/lib/components/card/Card.d.ts +119 -5
  5. package/lib/components/card/Card.js +60 -46
  6. package/lib/components/card/Card.stories.d.ts +6 -0
  7. package/lib/components/card/Card.stories.js +26 -0
  8. package/lib/components/entity-avatar/EntityAvatar.d.ts +73 -0
  9. package/lib/components/entity-avatar/EntityAvatar.js +63 -0
  10. package/lib/components/entity-avatar/index.d.ts +1 -0
  11. package/lib/components/entity-avatar/index.js +5 -0
  12. package/lib/components/hover-card/HoverCard.d.ts +63 -0
  13. package/lib/components/hover-card/HoverCard.js +55 -0
  14. package/lib/components/hover-card/HoverCardAnchor.d.ts +33 -0
  15. package/lib/components/hover-card/HoverCardAnchor.js +26 -0
  16. package/lib/components/hover-card/HoverCardDetails.d.ts +36 -0
  17. package/lib/components/hover-card/HoverCardDetails.js +65 -0
  18. package/lib/components/hover-card/HoverCardLayer.d.ts +34 -0
  19. package/lib/components/hover-card/HoverCardLayer.js +57 -0
  20. package/lib/components/hover-card/index.d.ts +12 -0
  21. package/lib/components/hover-card/index.js +16 -0
  22. package/lib/components/hover-card/useHoverCard.d.ts +57 -0
  23. package/lib/components/hover-card/useHoverCard.js +200 -0
  24. package/lib/components/hover-card/usePrefersReducedMotion.d.ts +10 -0
  25. package/lib/components/hover-card/usePrefersReducedMotion.js +28 -0
  26. package/lib/components/index.d.ts +2 -0
  27. package/lib/components/index.js +2 -0
  28. package/lib/theme/css/createThemeCSSVars.d.ts +18 -1
  29. package/lib/theme/css/createThemeCSSVars.js +17 -1
  30. package/lib/theme/css/primerComponentsCss.d.ts +47 -0
  31. package/lib/theme/css/primerComponentsCss.js +72 -0
  32. package/lib/theme/index.d.ts +1 -0
  33. package/lib/theme/index.js +1 -0
  34. package/lib/theme/themes/loopThemeStyles.d.ts +4 -31
  35. package/lib/theme/themes/loopThemeStyles.js +17 -44
  36. package/package.json +1 -1
@@ -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;
@@ -3,6 +3,7 @@
3
3
  * Distributed under the terms of the Modified BSD License.
4
4
  */
5
5
  import { themeTintVars } from '../colors/themeAccents';
6
+ import { primerComponentsCss } from './primerComponentsCss';
6
7
  /* ─── Helper ──────────────────────────────────────────────────────────── */
7
8
  /**
8
9
  * Convert a structured `ThemeColorDefs` object into a flat
@@ -260,6 +261,14 @@ export const DEFAULT_THEME_SHAPE = {
260
261
  motionPane: '0ms',
261
262
  motionEasing: 'ease',
262
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)',
263
272
  };
264
273
  /** A shape as custom properties. */
265
274
  export function shapeVars(shape = {}) {
@@ -276,9 +285,16 @@ export function shapeVars(shape = {}) {
276
285
  '--theme-motion-pane': full.motionPane,
277
286
  '--theme-motion-easing': full.motionEasing,
278
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,
279
293
  };
280
294
  }
281
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 ?? '');
282
298
  const fontVars = {};
283
299
  if (options?.fontFamily) {
284
300
  const f = options.fontFamily;
@@ -325,6 +341,6 @@ export function buildThemeStyles(light, dark, options) {
325
341
  ...themeTintVars(dark),
326
342
  ...(options?.variables?.dark ?? {}),
327
343
  },
328
- ...(options?.css ? { css: options.css } : {}),
344
+ ...(css ? { css } : {}),
329
345
  };
330
346
  }
@@ -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,7 @@
1
1
  export * from './colors';
2
2
  export * from './indicators';
3
3
  export * from './css/createThemeCSSVars';
4
+ export * from './css/primerComponentsCss';
4
5
  export * from './css/primerBaseVars';
5
6
  export * from './themes/datalayerTheme';
6
7
  export * from './DatalayerThemeProvider';
@@ -5,6 +5,7 @@
5
5
  export * from './colors';
6
6
  export * from './indicators';
7
7
  export * from './css/createThemeCSSVars';
8
+ export * from './css/primerComponentsCss';
8
9
  export * from './css/primerBaseVars';
9
10
  export * from './themes/datalayerTheme';
10
11
  export * from './DatalayerThemeProvider';
@@ -93,37 +93,10 @@ export declare const loopFocusRing: {
93
93
  readonly light: string;
94
94
  readonly dark: "#636363";
95
95
  };
96
+ /** Comprehensive Primer CSS-variable overrides for light & dark mode. */
97
+ export declare const loopThemeStyles: import("../css/createThemeCSSVars").ThemeStyles;
96
98
  /**
97
- * The controls, as one family (LOOP T-09): every single-line control is a
98
- * pill — a button, a text input, a select, a segmented control (outside and
99
- * each segment), a button group's two ends, a toggle switch, an underline
100
- * tab's hover. A multi-line text area keeps `--borderRadius-medium`: a pill
101
- * of many lines is a lozenge. Menus and overlays keep the card's radius,
102
- * `--borderRadius-large`, which the theme already sets.
103
- *
104
- * Primer takes every control's corners from `--borderRadius-medium`, which
105
- * cards and list items take too, so this cannot be a token: it is a
106
- * stylesheet, scoped by the theme provider (`ThemeStyles.css`). Primer's
107
- * class names are CSS-module hashes (`prc-Button-ButtonBase-c50BI`), so the
108
- * selectors match their stable prefix; the toggle switch is a
109
- * styled-component, matched by its display name, which styled-components
110
- * puts in its class (`ToggleSwitch__SwitchButton-sc-e6gszy-0`). A test reads each of them
111
- * back from the installed `@primer/react`.
112
- *
113
- * Where a control draws more than one element from the token — a segmented
114
- * control's track and segments, a button group's ends — the token itself is
115
- * 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.
116
101
  */
117
- export declare const loopControlsSelectors: {
118
- readonly button: "[class*=\"prc-Button-ButtonBase\"]";
119
- readonly textInput: "[class*=\"prc-components-TextInputBaseWrapper\"]";
120
- readonly textArea: "[class*=\"prc-Textarea-TextArea\"]";
121
- readonly segmentedControl: "[class*=\"prc-SegmentedControl-SegmentedControl\"]";
122
- readonly buttonGroup: "[class*=\"prc-ButtonGroup-ButtonGroup\"]";
123
- readonly underlineTab: "[class*=\"prc-components-UnderlineItem\"]";
124
- readonly toggleTrack: "[class*=\"ToggleSwitch__SwitchButton-\"]";
125
- readonly toggleKnob: "[class*=\"ToggleSwitch__ToggleKnob-\"]";
126
- };
127
102
  export declare const loopControlsCss: string;
128
- /** Comprehensive Primer CSS-variable overrides for light & dark mode. */
129
- export declare const loopThemeStyles: import("../css/createThemeCSSVars").ThemeStyles;
@@ -431,50 +431,15 @@ export const loopMotionVars = {
431
431
  */
432
432
  export const loopFocusRing = { light: loopColors.loopRing, dark: '#636363' };
433
433
  /**
434
- * The controls, as one family (LOOP T-09): every single-line control is a
435
- * pill — a button, a text input, a select, a segmented control (outside and
436
- * each segment), a button group's two ends, a toggle switch, an underline
437
- * tab's hover. A multi-line text area keeps `--borderRadius-medium`: a pill
438
- * of many lines is a lozenge. Menus and overlays keep the card's radius,
439
- * `--borderRadius-large`, which the theme already sets.
440
- *
441
- * Primer takes every control's corners from `--borderRadius-medium`, which
442
- * cards and list items take too, so this cannot be a token: it is a
443
- * stylesheet, scoped by the theme provider (`ThemeStyles.css`). Primer's
444
- * class names are CSS-module hashes (`prc-Button-ButtonBase-c50BI`), so the
445
- * selectors match their stable prefix; the toggle switch is a
446
- * styled-component, matched by its display name, which styled-components
447
- * puts in its class (`ToggleSwitch__SwitchButton-sc-e6gszy-0`). A test reads each of them
448
- * back from the installed `@primer/react`.
434
+ * The loop theme's own stylesheet, beside what its shape draws: bold is the
435
+ * theme's semibold, its second and last weight.
449
436
  *
450
- * Where a control draws more than one element from the token — a segmented
451
- * control's track and segments, a button group's ends — the token itself is
452
- * set on the control, and Primer's own rules draw the pill.
437
+ * Its controls are pills and its tables rounder by its shape
438
+ * (`radiusControl`, `radiusTable`), which `primerComponentsCss` draws for
439
+ * any theme that sets them: menus and overlays keep the card's radius,
440
+ * `--borderRadius-large`, which the theme already sets.
453
441
  */
454
- export const loopControlsSelectors = {
455
- button: '[class*="prc-Button-ButtonBase"]',
456
- textInput: '[class*="prc-components-TextInputBaseWrapper"]',
457
- textArea: '[class*="prc-Textarea-TextArea"]',
458
- segmentedControl: '[class*="prc-SegmentedControl-SegmentedControl"]',
459
- buttonGroup: '[class*="prc-ButtonGroup-ButtonGroup"]',
460
- underlineTab: '[class*="prc-components-UnderlineItem"]',
461
- toggleTrack: '[class*="ToggleSwitch__SwitchButton-"]',
462
- toggleKnob: '[class*="ToggleSwitch__ToggleKnob-"]',
463
- };
464
- const sel = loopControlsSelectors;
465
- export const loopControlsCss = `
466
- :scope ${sel.button},
467
- :scope ${sel.textInput}:not(:has(${sel.textArea})),
468
- :scope ${sel.segmentedControl},
469
- :scope ${sel.underlineTab},
470
- :scope ${sel.toggleTrack},
471
- :scope ${sel.toggleKnob} {
472
- --borderRadius-medium: var(--loop-radius-control);
473
- border-radius: var(--loop-radius-control);
474
- }
475
- :scope ${sel.buttonGroup} {
476
- --borderRadius-medium: var(--loop-radius-control);
477
- }
442
+ const loopOwnCss = `
478
443
  :scope b,
479
444
  :scope strong {
480
445
  font-weight: var(--base-text-weight-semibold);
@@ -483,10 +448,13 @@ export const loopControlsCss = `
483
448
  /** Comprehensive Primer CSS-variable overrides for light & dark mode. */
484
449
  export const loopThemeStyles = buildThemeStyles(loopLight, loopDark, {
485
450
  fontFamily: loopFontFamily,
486
- css: loopControlsCss,
487
- // Rounder than the others: a pill for a control, soft cards, round bubbles.
451
+ css: loopOwnCss,
452
+ // Rounder than the others: a pill for a control (LOOP T-09), soft cards,
453
+ // round bubbles, a table with the corners of a list item.
488
454
  shape: {
489
455
  radiusControl: loopShapeVars['--loop-radius-control'],
456
+ radiusTable: loopShapeVars['--borderRadius-medium'],
457
+ radiusOverlay: loopShapeVars['--loop-radius-card'],
490
458
  radiusCard: loopShapeVars['--loop-radius-card'],
491
459
  radiusBubble: loopShapeVars['--loop-radius-bubble'],
492
460
  radiusFrame: loopShapeVars['--loop-radius-frame'],
@@ -529,3 +497,8 @@ export const loopThemeStyles = buildThemeStyles(loopLight, loopDark, {
529
497
  },
530
498
  },
531
499
  });
500
+ /**
501
+ * The loop theme's whole stylesheet (`ThemeStyles.css`): its controls as
502
+ * pills and its tables rounder, drawn from its shape, then its own rules.
503
+ */
504
+ export const loopControlsCss = loopThemeStyles.css ?? '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datalayer/primer-addons",
3
- "version": "1.0.39",
3
+ "version": "1.0.40",
4
4
  "license": "BSD-3-Clause",
5
5
  "scripts": {
6
6
  "build": "npm run build:lib",