@datalayer/primer-addons 1.0.24 → 1.0.26

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,36 @@ 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
+ * And its motion (LOOP T-10): three durations — a status changing, a message
178
+ * arriving, a pane opening — and one easing. Today's is no motion at all, so
179
+ * a component that moves by them moves only in a theme that says so.
180
+ */
181
+ export interface ThemeShape {
182
+ radiusControl: string;
183
+ radiusCard: string;
184
+ radiusBubble: string;
185
+ radiusFrame: string;
186
+ hairline: string;
187
+ shadow: string;
188
+ motionStatus: string;
189
+ motionMessage: string;
190
+ motionPane: string;
191
+ motionEasing: string;
192
+ }
193
+ /** Today's shape, which every theme has unless it says otherwise. */
194
+ export declare const DEFAULT_THEME_SHAPE: ThemeShape;
195
+ /** A shape as custom properties. */
196
+ export declare function shapeVars(shape?: Partial<ThemeShape>): Record<string, string>;
171
197
  export declare function buildThemeStyles(light: ThemeColorDefs, dark: ThemeColorDefs, options?: {
172
198
  fontFamily?: string;
199
+ /** Its shape (T-03); today's, for what it does not say. */
200
+ shape?: Partial<ThemeShape>;
173
201
  /**
174
202
  * More custom properties, per mode, set after everything else: what a
175
203
  * theme sets beside colour and font — its radii, its own tokens.
@@ -246,18 +246,35 @@ 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
+ motionStatus: '0ms',
258
+ motionMessage: '0ms',
259
+ motionPane: '0ms',
260
+ motionEasing: 'ease',
261
+ };
262
+ /** A shape as custom properties. */
263
+ export function shapeVars(shape = {}) {
264
+ const full = { ...DEFAULT_THEME_SHAPE, ...shape };
265
+ return {
266
+ '--theme-radius-control': full.radiusControl,
267
+ '--theme-radius-card': full.radiusCard,
268
+ '--theme-radius-bubble': full.radiusBubble,
269
+ '--theme-radius-frame': full.radiusFrame,
270
+ '--theme-hairline': full.hairline,
271
+ '--theme-shadow': full.shadow,
272
+ '--theme-motion-status': full.motionStatus,
273
+ '--theme-motion-message': full.motionMessage,
274
+ '--theme-motion-pane': full.motionPane,
275
+ '--theme-motion-easing': full.motionEasing,
276
+ };
277
+ }
261
278
  export function buildThemeStyles(light, dark, options) {
262
279
  const fontVars = {};
263
280
  if (options?.fontFamily) {
@@ -290,6 +307,7 @@ export function buildThemeStyles(light, dark, options) {
290
307
  ...(options?.fontFamily ? { fontFamily: options.fontFamily } : {}),
291
308
  ...colorDefsToCSS(light, 'light'),
292
309
  ...fontVars,
310
+ ...shapeVars(options?.shape),
293
311
  ...(options?.variables?.light ?? {}),
294
312
  },
295
313
  dark: {
@@ -299,6 +317,7 @@ export function buildThemeStyles(light, dark, options) {
299
317
  ...(options?.fontFamily ? { fontFamily: options.fontFamily } : {}),
300
318
  ...colorDefsToCSS(dark, 'dark'),
301
319
  ...fontVars,
320
+ ...shapeVars(options?.shape),
302
321
  ...(options?.variables?.dark ?? {}),
303
322
  },
304
323
  };
@@ -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,54 @@ 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
+ motionStatus: loopMotionVars['--loop-motion-status'],
323
+ motionMessage: loopMotionVars['--loop-motion-message'],
324
+ motionPane: loopMotionVars['--loop-motion-pane'],
325
+ motionEasing: loopMotionVars['--loop-motion-easing'],
326
+ },
296
327
  variables: {
297
328
  light: {
298
329
  ...loopShapeVars,
299
330
  ...loopAccentVars('green', 'light'),
331
+ ...loopMotionVars,
300
332
  '--loop-hairline': loopHairline.light,
333
+ '--focus-outlineColor': loopFocusRing.light,
301
334
  },
302
335
  dark: {
303
336
  ...loopShapeVars,
304
337
  ...loopAccentVars('green', 'dark'),
338
+ ...loopMotionVars,
305
339
  '--loop-hairline': loopHairline.dark,
340
+ '--focus-outlineColor': loopFocusRing.dark,
306
341
  },
307
342
  },
308
343
  });
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.26",
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",