@datalayer/primer-addons 1.0.24 → 1.0.25

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.
@@ -168,8 +168,28 @@ export interface ThemeStyles {
168
168
  * `Blankslate`) picks up the themed font instead of the
169
169
  * hard-coded system-font fallback.
170
170
  */
171
+ /**
172
+ * The shape of a theme (LOOP T-03): the radii of a control, a card, a bubble
173
+ * and a frame; the hairline; at most one level of shadow. As custom
174
+ * properties every theme sets — `--theme-radius-control` and the rest — so
175
+ * that a component reads its shape the way it reads its colour.
176
+ */
177
+ export interface ThemeShape {
178
+ radiusControl: string;
179
+ radiusCard: string;
180
+ radiusBubble: string;
181
+ radiusFrame: string;
182
+ hairline: string;
183
+ shadow: string;
184
+ }
185
+ /** Today's shape, which every theme has unless it says otherwise. */
186
+ export declare const DEFAULT_THEME_SHAPE: ThemeShape;
187
+ /** A shape as custom properties. */
188
+ export declare function shapeVars(shape?: Partial<ThemeShape>): Record<string, string>;
171
189
  export declare function buildThemeStyles(light: ThemeColorDefs, dark: ThemeColorDefs, options?: {
172
190
  fontFamily?: string;
191
+ /** Its shape (T-03); today's, for what it does not say. */
192
+ shape?: Partial<ThemeShape>;
173
193
  /**
174
194
  * More custom properties, per mode, set after everything else: what a
175
195
  * theme sets beside colour and font — its radii, its own tokens.
@@ -246,18 +246,27 @@ export function colorDefsToCSS(defs, mode = 'light') {
246
246
  '--datalayer-icon-fg': defs.accent.fg,
247
247
  };
248
248
  }
249
- /**
250
- * Build a complete `ThemeStyles` object from light / dark
251
- * `ThemeColorDefs`. The result is ready to pass straight to
252
- * `<DatalayerThemeProvider themeStyles={…}>`.
253
- *
254
- * @param options.fontFamily When supplied, the Primer font-stack
255
- * CSS custom properties (`--fontStack-sansSerif`,
256
- * `--fontStack-sansSerifDisplay`) are overridden so that every
257
- * Primer component that uses the CSS `font` shorthand (e.g.
258
- * `Blankslate`) picks up the themed font instead of the
259
- * hard-coded system-font fallback.
260
- */
249
+ /** Today's shape, which every theme has unless it says otherwise. */
250
+ export const DEFAULT_THEME_SHAPE = {
251
+ radiusControl: 'var(--borderRadius-medium, 6px)',
252
+ radiusCard: 'var(--borderRadius-medium, 6px)',
253
+ radiusBubble: 'var(--borderRadius-large, 12px)',
254
+ radiusFrame: 'var(--borderRadius-large, 12px)',
255
+ hairline: 'var(--borderWidth-thin, 1px)',
256
+ shadow: 'var(--shadow-resting-small, none)',
257
+ };
258
+ /** A shape as custom properties. */
259
+ export function shapeVars(shape = {}) {
260
+ const full = { ...DEFAULT_THEME_SHAPE, ...shape };
261
+ return {
262
+ '--theme-radius-control': full.radiusControl,
263
+ '--theme-radius-card': full.radiusCard,
264
+ '--theme-radius-bubble': full.radiusBubble,
265
+ '--theme-radius-frame': full.radiusFrame,
266
+ '--theme-hairline': full.hairline,
267
+ '--theme-shadow': full.shadow,
268
+ };
269
+ }
261
270
  export function buildThemeStyles(light, dark, options) {
262
271
  const fontVars = {};
263
272
  if (options?.fontFamily) {
@@ -290,6 +299,7 @@ export function buildThemeStyles(light, dark, options) {
290
299
  ...(options?.fontFamily ? { fontFamily: options.fontFamily } : {}),
291
300
  ...colorDefsToCSS(light, 'light'),
292
301
  ...fontVars,
302
+ ...shapeVars(options?.shape),
293
303
  ...(options?.variables?.light ?? {}),
294
304
  },
295
305
  dark: {
@@ -299,6 +309,7 @@ export function buildThemeStyles(light, dark, options) {
299
309
  ...(options?.fontFamily ? { fontFamily: options.fontFamily } : {}),
300
310
  ...colorDefsToCSS(dark, 'dark'),
301
311
  ...fontVars,
312
+ ...shapeVars(options?.shape),
302
313
  ...(options?.variables?.dark ?? {}),
303
314
  },
304
315
  };
@@ -1100,6 +1100,23 @@ export declare const loopTheme: {
1100
1100
  * face is used, and nothing shifts but the letterforms.
1101
1101
  */
1102
1102
  export declare const loopFontFamily = "Inter, ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif";
1103
+ /**
1104
+ * Motion (LOOP T-10): three durations and one easing, for three things — a
1105
+ * status changing, a message arriving, a pane opening. Nothing else moves.
1106
+ */
1107
+ export declare const loopMotionVars: Record<string, string>;
1108
+ /**
1109
+ * The focus ring (LOOP T-15): 3 to 1 against the page and around a pill of
1110
+ * any accent, in both modes. In light mode the ink does it. In dark mode no
1111
+ * colour clears 3 to 1 against both the near-black page and the six pastels,
1112
+ * the light ink least of all (under 1.8 to 1 on the pastels): a mid grey
1113
+ * does, at 3.04 to 1 — and 2.77 to 1 on the subtle dark surface, the one
1114
+ * place it falls short.
1115
+ */
1116
+ export declare const loopFocusRing: {
1117
+ readonly light: string;
1118
+ readonly dark: "#636363";
1119
+ };
1103
1120
  /** Comprehensive Primer CSS-variable overrides for light & dark mode. */
1104
1121
  export declare const loopThemeStyles: import("../css/createThemeCSSVars").ThemeStyles;
1105
1122
  export default loopTheme;
@@ -290,19 +290,50 @@ export const loopTheme = primerTheme;
290
290
  * face is used, and nothing shifts but the letterforms.
291
291
  */
292
292
  export const loopFontFamily = 'Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';
293
+ /**
294
+ * Motion (LOOP T-10): three durations and one easing, for three things — a
295
+ * status changing, a message arriving, a pane opening. Nothing else moves.
296
+ */
297
+ export const loopMotionVars = {
298
+ '--loop-motion-status': '120ms',
299
+ '--loop-motion-message': '200ms',
300
+ '--loop-motion-pane': '320ms',
301
+ '--loop-motion-easing': 'cubic-bezier(0.2, 0, 0, 1)',
302
+ };
303
+ /**
304
+ * The focus ring (LOOP T-15): 3 to 1 against the page and around a pill of
305
+ * any accent, in both modes. In light mode the ink does it. In dark mode no
306
+ * colour clears 3 to 1 against both the near-black page and the six pastels,
307
+ * the light ink least of all (under 1.8 to 1 on the pastels): a mid grey
308
+ * does, at 3.04 to 1 — and 2.77 to 1 on the subtle dark surface, the one
309
+ * place it falls short.
310
+ */
311
+ export const loopFocusRing = { light: loopColors.ink, dark: '#636363' };
293
312
  /** Comprehensive Primer CSS-variable overrides for light & dark mode. */
294
313
  export const loopThemeStyles = buildThemeStyles(loopLight, loopDark, {
295
314
  fontFamily: loopFontFamily,
315
+ // Rounder than the others: a pill for a control, soft cards, round bubbles.
316
+ shape: {
317
+ radiusControl: loopShapeVars['--loop-radius-control'],
318
+ radiusCard: loopShapeVars['--loop-radius-card'],
319
+ radiusBubble: loopShapeVars['--loop-radius-bubble'],
320
+ radiusFrame: loopShapeVars['--loop-radius-frame'],
321
+ shadow: loopShapeVars['--loop-shadow-frame'],
322
+ },
296
323
  variables: {
297
324
  light: {
298
325
  ...loopShapeVars,
299
326
  ...loopAccentVars('green', 'light'),
327
+ ...loopMotionVars,
300
328
  '--loop-hairline': loopHairline.light,
329
+ '--focus-outlineColor': loopFocusRing.light,
301
330
  },
302
331
  dark: {
303
332
  ...loopShapeVars,
304
333
  ...loopAccentVars('green', 'dark'),
334
+ ...loopMotionVars,
305
335
  '--loop-hairline': loopHairline.dark,
336
+ '--focus-outlineColor': loopFocusRing.dark,
306
337
  },
307
338
  },
308
339
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datalayer/primer-addons",
3
- "version": "1.0.24",
3
+ "version": "1.0.25",
4
4
  "license": "BSD-3-Clause",
5
5
  "scripts": {
6
6
  "build": "npm run build:lib",
@@ -14,6 +14,7 @@
14
14
  "preview": "npm --prefix examples/gallery run preview",
15
15
  "start": "npm run gallery",
16
16
  "storybook": "storybook dev -p 6006",
17
+ "test": "vitest run src",
17
18
  "watch": "tsc -w",
18
19
  "watch:lib": "tsc -b -w"
19
20
  },
@@ -50,6 +51,7 @@
50
51
  "react": "19.2.8",
51
52
  "react-dom": "19.2.8",
52
53
  "rimraf": "^6.0.1",
54
+ "vitest": "^3.2.7",
53
55
  "@storybook/addon-docs": "^9.0.15",
54
56
  "@storybook/addon-essentials": "9.0.0-alpha.12",
55
57
  "@storybook/addon-interactions": "^9.0.0-alpha.10",