@datalayer/primer-addons 1.0.35 → 1.0.38

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 (61) hide show
  1. package/README.md +20 -2
  2. package/lib/components/appearance/AppearanceControls.js +5 -0
  3. package/lib/reactor/index.d.ts +1 -1
  4. package/lib/reactor/index.js +1 -1
  5. package/lib/reactor/page-layout/PageLayout.d.ts +6 -0
  6. package/lib/reactor/page-layout/PageLayout.js +26 -0
  7. package/lib/theme/DatalayerThemeProvider.js +5 -2
  8. package/lib/theme/colors/loopColors.js +2 -0
  9. package/lib/theme/css/createThemeCSSVars.d.ts +5 -0
  10. package/lib/theme/css/createThemeCSSVars.js +2 -0
  11. package/lib/theme/index.d.ts +1 -0
  12. package/lib/theme/index.js +1 -0
  13. package/lib/theme/loopEyes.d.ts +84 -0
  14. package/lib/theme/loopEyes.js +82 -0
  15. package/lib/theme/portable.d.ts +16 -0
  16. package/lib/theme/portable.js +20 -0
  17. package/lib/theme/portableTheme.d.ts +1 -1
  18. package/lib/theme/portableTheme.js +2 -2
  19. package/lib/theme/themeRegistry.d.ts +3 -75
  20. package/lib/theme/themeRegistry.js +38 -509
  21. package/lib/theme/themeTokens.d.ts +101 -0
  22. package/lib/theme/themeTokens.js +494 -0
  23. package/lib/theme/themes/datalayerTheme.d.ts +2 -9
  24. package/lib/theme/themes/datalayerTheme.js +8 -236
  25. package/lib/theme/themes/datalayerThemeStyles.d.ts +2 -0
  26. package/lib/theme/themes/datalayerThemeStyles.js +234 -0
  27. package/lib/theme/themes/earthTheme.d.ts +2 -9
  28. package/lib/theme/themes/earthTheme.js +8 -235
  29. package/lib/theme/themes/earthThemeStyles.d.ts +2 -0
  30. package/lib/theme/themes/earthThemeStyles.js +233 -0
  31. package/lib/theme/themes/ivoryTheme.d.ts +2 -9
  32. package/lib/theme/themes/ivoryTheme.js +8 -249
  33. package/lib/theme/themes/ivoryThemeStyles.d.ts +2 -0
  34. package/lib/theme/themes/ivoryThemeStyles.js +247 -0
  35. package/lib/theme/themes/loopTheme.d.ts +13 -144
  36. package/lib/theme/themes/loopTheme.js +20 -513
  37. package/lib/theme/themes/loopThemeStyles.d.ts +135 -0
  38. package/lib/theme/themes/loopThemeStyles.js +521 -0
  39. package/lib/theme/themes/lovelyTheme.d.ts +2 -9
  40. package/lib/theme/themes/lovelyTheme.js +8 -231
  41. package/lib/theme/themes/lovelyThemeStyles.d.ts +2 -0
  42. package/lib/theme/themes/lovelyThemeStyles.js +229 -0
  43. package/lib/theme/themes/matrixTheme.d.ts +2 -9
  44. package/lib/theme/themes/matrixTheme.js +8 -237
  45. package/lib/theme/themes/matrixThemeStyles.d.ts +2 -0
  46. package/lib/theme/themes/matrixThemeStyles.js +235 -0
  47. package/lib/theme/themes/sandTheme.d.ts +2 -9
  48. package/lib/theme/themes/sandTheme.js +8 -248
  49. package/lib/theme/themes/sandThemeStyles.d.ts +2 -0
  50. package/lib/theme/themes/sandThemeStyles.js +246 -0
  51. package/lib/theme/themes/spatialTheme.d.ts +2 -9
  52. package/lib/theme/themes/spatialTheme.js +8 -231
  53. package/lib/theme/themes/spatialThemeStyles.d.ts +2 -0
  54. package/lib/theme/themes/spatialThemeStyles.js +229 -0
  55. package/lib/theme/themes/sunTheme.d.ts +2 -9
  56. package/lib/theme/themes/sunTheme.js +8 -249
  57. package/lib/theme/themes/sunThemeStyles.d.ts +2 -0
  58. package/lib/theme/themes/sunThemeStyles.js +247 -0
  59. package/lib/utils/Portals.d.ts +7 -0
  60. package/lib/utils/Portals.js +7 -0
  61. package/package.json +1 -1
package/README.md CHANGED
@@ -81,11 +81,11 @@ import { loopAccentVars } from '@datalayer/primer-addons';
81
81
  baseStyles={loopAccentVars(app.interface.accent, mode)}>
82
82
  ```
83
83
 
84
- `loopAccentVars` sets the four `--loop-*` properties and nothing else: what reads them (the stage, a bubble drawn with them) takes the application's accent, while Primer's own accent tokens — the filled button, `--bgColor-accent-emphasis` — stay the theme's mint. `loopAccentStyles(name, mode)` sets everything the accent colours instead: those four, the accent fill and the filled button with its text, and Primer's accent text, links, muted border and muted tint (`--fgColor-accent`, `--fgColor-link`, `--borderColor-accent-muted`, `--bgColor-accent-muted`) — so that nothing on an application's page keeps mint beside its own accent.
84
+ `loopAccentVars` sets the four `--loop-*` properties and nothing else: what reads them (the stage, a bubble drawn with them) takes the application's accent, while Primer's own accent tokens — the filled button, `--bgColor-accent-emphasis` — stay the theme's mint. `loopAccentStyles(name, mode)` sets everything the accent colours instead: those four, the accent fill and the filled button with its text, and Primer's accent text, links, muted border and muted tint (`--fgColor-accent`, `--fgColor-link`, `--borderColor-accent-muted`, `--bgColor-accent-muted`), and the selected tab's underline (`--underlineNav-borderColor-active`, which the theme itself also sets to its mint in place of Primer's coral) — so that nothing on an application's page keeps mint beside its own accent.
85
85
 
86
86
  ### Shape, shadow, type and motion
87
87
 
88
- **Every theme** sets these, so that a component reads its shape the way it reads its colour (`shapeVars`, `DEFAULT_THEME_SHAPE`). The eight other themes take the defaults — today's corners and no motion at all — and keep every other value they had, which `themeShape.test.ts` holds by a snapshot of each.
88
+ **Every theme** sets these, so that a component reads its shape — and how a link reads in a message — the way it reads its colour (`shapeVars`, `DEFAULT_THEME_SHAPE`). The eight other themes take the defaults — today's corners and no motion at all — and keep every other value they had, which `themeShape.test.ts` holds by a snapshot of each.
89
89
 
90
90
  | Token | Default (every other theme) | `loop` |
91
91
  |---|---|---|
@@ -99,6 +99,7 @@ import { loopAccentVars } from '@datalayer/primer-addons';
99
99
  | `--theme-motion-message` | `0ms` | `200ms` |
100
100
  | `--theme-motion-pane` | `0ms` | `320ms` |
101
101
  | `--theme-motion-easing` | `ease` | `cubic-bezier(0.2, 0, 0, 1)` |
102
+ | `--theme-message-link` | `var(--fgColor-accent, #0969da)` | `currentColor`: a link in a message is plain, the colour of its words, and underlined |
102
103
 
103
104
  **The `loop` theme's own**, beside them (`loopShapeVars`, `loopShadows`, `loopMotionVars`, `loopTypeVars`):
104
105
 
@@ -128,6 +129,23 @@ How `DatalayerThemeProvider` applies it:
128
129
 
129
130
  `themeStylesheet.test.tsx` tests each of these.
130
131
 
132
+ ### The rules of clean
133
+
134
+ The look is kept by eight rules, written here once and applied to every screen in review (LOOP T-17, Q-09) — a screen that breaks one is changed, or the rule is, never let through as an exception:
135
+
136
+ 1. **One accent per application.** Its own (`interface.accent`), on everything the accent colours (`loopAccentStyles`); never a second hue beside it. Success, attention and danger are a verdict's colours, and only a verdict's.
137
+ 2. **No gradient on a surface.** A frame, a card, a bubble, a pill, a button and a menu are flat. The one gradient is the stage behind the frame, lit by the accent's own two tints (`--loop-stage-gradient`), and a stage may as well be flat (`--loop-stage`).
138
+ 3. **No border where space separates.** Air first; where two surfaces meet, one hairline (`--theme-hairline`, `--loop-hairline`), never a gap and a border both, never a box drawn round a group that space already groups.
139
+ 4. **No shadow beyond the one level.** `--loop-shadow-frame` (`--theme-shadow`): a frame, a menu and a dialog float on it; nothing else has a shadow of its own.
140
+ 5. **Two weights.** 400 and 600 (`loopFontWeights`), in the five sizes of `loopTypeScale` — by name in `sx` too, where `loopTheme.fontWeights` makes Primer's `light` and `normal` the 400, `semibold` and `bold` the 600.
141
+ 6. **One filled button per screen.** The action that matters is the filled pill in the accent; every other is quiet — outlined, or invisible until hovered.
142
+ 7. **A control is a line icon.** Octicons, at one weight, in the ink: no colour on a control, no emoji on a button.
143
+ 8. **An identity is an emoji.** An application, an agent and a character are shown by their face (the emoji or the drawing of T-19), never by a line icon.
144
+
145
+ Motion obeys the same spirit: three things move — a message arriving, a status changing, a pane opening — at `--theme-motion-message`, `-status` and `-pane`, and nothing else does.
146
+
147
+ What a test can hold, a test holds: no gradient but the stage's, the one shadow a component asks the theme for, two weights (the tokens and `sx`'s names) and a link plain in a message (`loopClean.test.ts`); the sizes (`loopType.test.ts`); the three durations (`loopContrast.test.ts`); the pills (`themeStylesheet.test.tsx`); in the products that wear the theme, the screens' colours are scanned against these rules too (the landing's `studioVerdictColors.spec.ts`). The rest — space against borders, one filled button — is the reviewer's, against the reference screens (T-16).
148
+
131
149
  ### Contrast, as tested
132
150
 
133
151
  `src/theme/__tests__/loopContrast.test.ts` fails the build when, for any of the six accents, in either mode:
@@ -31,6 +31,7 @@ export function AppearanceControls({ colorMode, themeVariant, onColorModeChange,
31
31
  return (_jsx(Tooltip, { text: `${cfg.label} — ${cfg.description}`, direction: "s", children: _jsx(Box, { as: "button", "aria-label": cfg.label, "aria-pressed": isSelected, onClick: () => onThemeChange(variant), sx: {
32
32
  width: 24,
33
33
  height: 24,
34
+ flexShrink: 0,
34
35
  borderRadius: '50%',
35
36
  backgroundColor: cfg.brandColor,
36
37
  border: '2px solid',
@@ -80,6 +81,8 @@ export function AppearanceControls({ colorMode, themeVariant, onColorModeChange,
80
81
  pb: 2,
81
82
  display: 'flex',
82
83
  justifyContent: 'center',
84
+ // Narrow, the swatches go on a second line rather than shrink.
85
+ flexWrap: 'wrap',
83
86
  gap: 2,
84
87
  }, children: themeVariants.map((variant) => {
85
88
  const cfg = themeConfigs[variant];
@@ -87,6 +90,8 @@ export function AppearanceControls({ colorMode, themeVariant, onColorModeChange,
87
90
  return (_jsx(Tooltip, { text: cfg.label, direction: "s", children: _jsx(Box, { as: "button", "aria-label": cfg.label, "aria-pressed": isSelected, onClick: () => onThemeChange(variant), sx: {
88
91
  width: 24,
89
92
  height: 24,
93
+ // A circle at any width: never squeezed into an oval.
94
+ flexShrink: 0,
90
95
  borderRadius: '50%',
91
96
  backgroundColor: cfg.brandColor,
92
97
  border: '2px solid',
@@ -24,7 +24,7 @@
24
24
  export { ThemePlugin, THEME_PLUGIN_NAME, TOGGLE_COLOR_MODE_COMMAND, } from "./ThemePlugin";
25
25
  export { AppearancePlugin, APPEARANCE_PLUGIN_NAME, APPEARANCE_MENU_COMPONENT_ID, type AppearancePluginConfig, } from "./AppearancePlugin";
26
26
  export { PageLayoutPlugin, PAGE_LAYOUT_PLUGIN_NAME, PageLayoutSlots, type PageLayoutPluginConfig, } from "./page-layout/PageLayoutPlugin";
27
- export { PageLayout, PAGE_SHEET_WIDTH, PAGE_PANEL_WIDTH, PAGE_SIZE_FORMATS, resolvePageSize, type PageLayoutProps, type PageSize, type PageSizeFormat, } from "./page-layout/PageLayout";
27
+ export { PageLayout, panelOpening, PAGE_SHEET_WIDTH, PAGE_PANEL_WIDTH, PAGE_SIZE_FORMATS, resolvePageSize, type PageLayoutProps, type PageSize, type PageSizeFormat, } from "./page-layout/PageLayout";
28
28
  export { PagePanelToggle, type PagePanelToggleProps, } from "./page-layout/PagePanelToggle";
29
29
  export { SlotPageLayout, SlotPanelToggle, type SlotPageLayoutProps, } from "./page-layout/SlotPageLayout";
30
30
  export { pageLayoutPanelOpen, pageLayoutSheet, pageLayoutActivity, openPagePanel, closePagePanel, togglePagePanel, } from "./page-layout/panelState";
@@ -28,7 +28,7 @@
28
28
  export { ThemePlugin, THEME_PLUGIN_NAME, TOGGLE_COLOR_MODE_COMMAND, } from "./ThemePlugin";
29
29
  export { AppearancePlugin, APPEARANCE_PLUGIN_NAME, APPEARANCE_MENU_COMPONENT_ID, } from "./AppearancePlugin";
30
30
  export { PageLayoutPlugin, PAGE_LAYOUT_PLUGIN_NAME, PageLayoutSlots, } from "./page-layout/PageLayoutPlugin";
31
- export { PageLayout, PAGE_SHEET_WIDTH, PAGE_PANEL_WIDTH, PAGE_SIZE_FORMATS, resolvePageSize, } from "./page-layout/PageLayout";
31
+ export { PageLayout, panelOpening, PAGE_SHEET_WIDTH, PAGE_PANEL_WIDTH, PAGE_SIZE_FORMATS, resolvePageSize, } from "./page-layout/PageLayout";
32
32
  export { PagePanelToggle, } from "./page-layout/PagePanelToggle";
33
33
  export { SlotPageLayout, SlotPanelToggle, } from "./page-layout/SlotPageLayout";
34
34
  export { pageLayoutPanelOpen, pageLayoutSheet, pageLayoutActivity, openPagePanel, closePagePanel, togglePagePanel, } from "./page-layout/panelState";
@@ -79,6 +79,12 @@ export declare function resolvePageSize(size: PageSize | undefined, sheetWidth?:
79
79
  width: number;
80
80
  height?: number;
81
81
  };
82
+ /**
83
+ * A panel opening from its side at the theme's pace: `--theme-motion-pane`
84
+ * and `--theme-motion-easing`, which every theme sets — to no motion at all
85
+ * but in `loop` (LOOP T-10). The animation starts when the panel is shown.
86
+ */
87
+ export declare function panelOpening(side: "left" | "right"): Record<string, unknown>;
82
88
  export type PageLayoutProps = {
83
89
  /** The page: what lies on the sheet. */
84
90
  page?: ReactNode;
@@ -111,6 +111,25 @@ function ActivityLine({ label }) {
111
111
  },
112
112
  } }), _jsx(Text, { children: label })] }));
113
113
  }
114
+ /**
115
+ * A panel opening from its side at the theme's pace: `--theme-motion-pane`
116
+ * and `--theme-motion-easing`, which every theme sets — to no motion at all
117
+ * but in `loop` (LOOP T-10). The animation starts when the panel is shown.
118
+ */
119
+ export function panelOpening(side) {
120
+ const name = side === "left" ? "pagePanelOpenLeft" : "pagePanelOpenRight";
121
+ return {
122
+ animation: `${name} var(--theme-motion-pane, 0ms) var(--theme-motion-easing, ease) both`,
123
+ [`@keyframes ${name}`]: {
124
+ from: {
125
+ opacity: 0,
126
+ transform: `translateX(${side === "left" ? "-12px" : "12px"})`,
127
+ },
128
+ to: { opacity: 1, transform: "none" },
129
+ },
130
+ "@media (prefers-reduced-motion: reduce)": { animation: "none" },
131
+ };
132
+ }
114
133
  export function PageLayout({ page, hasPage = page !== undefined && page !== null, panel, band, chips, picker, transient, activity, bandMode = "docked", panelMode = "docked", panelSide = "right", sheetWidth = PAGE_SHEET_WIDTH, pageSize, panelWidth = PAGE_PANEL_WIDTH, }) {
115
134
  const bandInPanel = bandMode === "panel";
116
135
  const hasBand = band !== undefined && band !== null;
@@ -301,6 +320,13 @@ export function PageLayout({ page, hasPage = page !== undefined && page !== null
301
320
  display: "flex",
302
321
  flexDirection: "column",
303
322
  "& > *": { flex: "1 1 auto", minHeight: 0 },
323
+ // A pane opening, at the theme's pace (LOOP T-10): from its
324
+ // side, by the theme's motion tokens — none in a theme that
325
+ // sets no motion, none when motion is reduced. On the
326
+ // content, not the column: a transform on the column would
327
+ // hold the floating composer, which lives in it, while it
328
+ // runs.
329
+ ...(panelShown ? panelOpening(panelSide) : null),
304
330
  }, children: panel }), hasBand && bandMode !== "docked" ? (_jsxs(Box, { "data-page-panel-band": bandInPanel ? "" : undefined, sx: bandInPanel
305
331
  ? {
306
332
  flex: "0 0 auto",
@@ -8,7 +8,7 @@ import { BaseStyles, ThemeProvider } from "@primer/react";
8
8
  import { useSystemColorMode } from "./useSystemColorMode";
9
9
  import { datalayerTheme, datalayerThemeStyles } from "./themes/datalayerTheme";
10
10
  import { systemFontStack } from "./fontStacks";
11
- import { THEME_SCOPE_ATTRIBUTE, injectThemeStylesheet, setupPrimerPortals, syncPortalThemeStyles, } from "../utils/Portals";
11
+ import { APP_ROOT_ATTRIBUTE, THEME_SCOPE_ATTRIBUTE, injectThemeStylesheet, setupPrimerPortals, syncPortalThemeStyles, } from "../utils/Portals";
12
12
  /**
13
13
  * System sans-serif font stack — shared between `fontFamily` and
14
14
  * the Primer `--fontStack-*` CSS custom properties so that
@@ -117,7 +117,10 @@ export function DatalayerThemeProvider(props) {
117
117
  // The sentinel's parent is this provider's own element; anything themed
118
118
  // above *that* is another provider's.
119
119
  const own = sentinel.current?.parentElement;
120
- const ancestor = own?.parentElement?.closest("[data-color-mode]") ?? null;
120
+ const themed = own?.parentElement?.closest("[data-color-mode]") ?? null;
121
+ // The application's own Primer wrapper, marked so, is not a host page:
122
+ // the provider inside it owns the page (see APP_ROOT_ATTRIBUTE).
123
+ const ancestor = themed?.hasAttribute(APP_ROOT_ATTRIBUTE) ? null : themed;
121
124
  setThemedAncestor(ancestor);
122
125
  if (!ancestor) {
123
126
  setAncestorMode(null);
@@ -158,6 +158,8 @@ export function loopAccentStyles(name, mode = 'light') {
158
158
  '--fgColor-link': accent.text[mode],
159
159
  '--borderColor-accent-muted': accent.accent,
160
160
  '--bgColor-accent-muted': accent.quiet[mode],
161
+ // The selected tab: underlined in the accent (T-14).
162
+ '--underlineNav-borderColor-active': accent.accent,
161
163
  '--button-primary-bgColor-rest': accent.accent,
162
164
  '--button-primary-borderColor-rest': accent.accent,
163
165
  '--button-primary-bgColor-hover': accent.accent,
@@ -191,6 +191,10 @@ export interface ThemeStyles {
191
191
  * And its motion (LOOP T-10): three durations — a status changing, a message
192
192
  * arriving, a pane opening — and one easing. Today's is no motion at all, so
193
193
  * a component that moves by them moves only in a theme that says so.
194
+ *
195
+ * And how a link reads in a message (LOOP T-06): in the accent, as today, or
196
+ * — `currentColor` — plain, the colour of the words around it, underlined in
197
+ * every theme.
194
198
  */
195
199
  export interface ThemeShape {
196
200
  radiusControl: string;
@@ -203,6 +207,7 @@ export interface ThemeShape {
203
207
  motionMessage: string;
204
208
  motionPane: string;
205
209
  motionEasing: string;
210
+ messageLink: string;
206
211
  }
207
212
  /** Today's shape, which every theme has unless it says otherwise. */
208
213
  export declare const DEFAULT_THEME_SHAPE: ThemeShape;
@@ -258,6 +258,7 @@ export const DEFAULT_THEME_SHAPE = {
258
258
  motionMessage: '0ms',
259
259
  motionPane: '0ms',
260
260
  motionEasing: 'ease',
261
+ messageLink: 'var(--fgColor-accent, #0969da)',
261
262
  };
262
263
  /** A shape as custom properties. */
263
264
  export function shapeVars(shape = {}) {
@@ -273,6 +274,7 @@ export function shapeVars(shape = {}) {
273
274
  '--theme-motion-message': full.motionMessage,
274
275
  '--theme-motion-pane': full.motionPane,
275
276
  '--theme-motion-easing': full.motionEasing,
277
+ '--theme-message-link': full.messageLink,
276
278
  };
277
279
  }
278
280
  export function buildThemeStyles(light, dark, options) {
@@ -16,6 +16,7 @@ export * from './themes-brand/spatialBrandTheme';
16
16
  export * from './themeRegistry';
17
17
  export * from './portableTheme';
18
18
  export * from './fontStacks';
19
+ export * from './loopEyes';
19
20
  export * from './palettes';
20
21
  export * from './useSystemColorMode';
21
22
  export * from './useThemeStore';
@@ -20,6 +20,7 @@ export * from './themes-brand/spatialBrandTheme';
20
20
  export * from './themeRegistry';
21
21
  export * from './portableTheme';
22
22
  export * from './fontStacks';
23
+ export * from './loopEyes';
23
24
  export * from './palettes';
24
25
  export * from './useSystemColorMode';
25
26
  export * from './useThemeStore';
@@ -0,0 +1,84 @@
1
+ /**
2
+ * The eyes of L👀P, as geometry (`plans/STUDIO.md`, N-02).
3
+ *
4
+ * The name is displayed with two eyes where its two O's are. They are drawn,
5
+ * not typed: the emoji is a different picture on every platform, is missing
6
+ * on some, and is read aloud as "eyes". Two ovals and two pupils, in the
7
+ * colour of the text around them, look the same everywhere — the web's SVG
8
+ * and the mobile app's native views draw this same geometry.
9
+ *
10
+ * An eye is about as wide and as tall as a capital O of the face beside it,
11
+ * so that the two of them read as the O's they stand for.
12
+ *
13
+ * Pure: nothing here renders.
14
+ */
15
+ /** The box the two eyes are drawn in. */
16
+ export declare const EYES_VIEW: {
17
+ readonly width: 52;
18
+ readonly height: 32;
19
+ };
20
+ /** Where the eyes look: a point from -1 to 1 each way, right and down positive. */
21
+ export type Gaze = {
22
+ x: number;
23
+ y: number;
24
+ };
25
+ /** The ways of looking that have a name. */
26
+ export declare const GAZES: {
27
+ /** As the emoji does: to the left, a little down. What the logotype shows. */
28
+ readonly aside: {
29
+ readonly x: -0.7;
30
+ readonly y: 0.25;
31
+ };
32
+ readonly ahead: {
33
+ readonly x: 0;
34
+ readonly y: 0;
35
+ };
36
+ readonly left: {
37
+ readonly x: -1;
38
+ readonly y: 0;
39
+ };
40
+ readonly right: {
41
+ readonly x: 1;
42
+ readonly y: 0;
43
+ };
44
+ readonly up: {
45
+ readonly x: 0;
46
+ readonly y: -1;
47
+ };
48
+ readonly down: {
49
+ readonly x: 0;
50
+ readonly y: 1;
51
+ };
52
+ };
53
+ export type GazeName = keyof typeof GAZES;
54
+ export type Ellipse = {
55
+ cx: number;
56
+ cy: number;
57
+ rx: number;
58
+ ry: number;
59
+ };
60
+ export type Circle = {
61
+ cx: number;
62
+ cy: number;
63
+ r: number;
64
+ };
65
+ /** The stroke of an eye's outline: about the stem of a bold letter at this size. */
66
+ export declare const EYE_STROKE = 4;
67
+ /** A gaze no longer than 1: a look to a corner does not leave the eye. */
68
+ export declare function boundedGaze(gaze: Gaze): Gaze;
69
+ /** The two eyes and their pupils, looking somewhere. */
70
+ export declare function eyesGeometry(gaze?: Gaze | GazeName): {
71
+ eyes: [Ellipse, Ellipse];
72
+ pupils: [Circle, Circle];
73
+ };
74
+ /**
75
+ * Where the eyes look when something is at a point: the gaze towards it from
76
+ * the middle of the eyes, full when it is `far` away or more.
77
+ */
78
+ export declare function gazeTowards(from: {
79
+ x: number;
80
+ y: number;
81
+ }, to: {
82
+ x: number;
83
+ y: number;
84
+ }, far?: number): Gaze;
@@ -0,0 +1,82 @@
1
+ /*
2
+ * Copyright (c) 2023-2026 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ /**
6
+ * The eyes of L👀P, as geometry (`plans/STUDIO.md`, N-02).
7
+ *
8
+ * The name is displayed with two eyes where its two O's are. They are drawn,
9
+ * not typed: the emoji is a different picture on every platform, is missing
10
+ * on some, and is read aloud as "eyes". Two ovals and two pupils, in the
11
+ * colour of the text around them, look the same everywhere — the web's SVG
12
+ * and the mobile app's native views draw this same geometry.
13
+ *
14
+ * An eye is about as wide and as tall as a capital O of the face beside it,
15
+ * so that the two of them read as the O's they stand for.
16
+ *
17
+ * Pure: nothing here renders.
18
+ */
19
+ /** The box the two eyes are drawn in. */
20
+ export const EYES_VIEW = { width: 52, height: 32 };
21
+ /** The ways of looking that have a name. */
22
+ export const GAZES = {
23
+ /** As the emoji does: to the left, a little down. What the logotype shows. */
24
+ aside: { x: -0.7, y: 0.25 },
25
+ ahead: { x: 0, y: 0 },
26
+ left: { x: -1, y: 0 },
27
+ right: { x: 1, y: 0 },
28
+ up: { x: 0, y: -1 },
29
+ down: { x: 0, y: 1 },
30
+ };
31
+ /** The outline of each eye. */
32
+ const EYE = { rx: 10.2, ry: 13.6 };
33
+ const CENTRES = [13, 39];
34
+ const MIDDLE = EYES_VIEW.height / 2;
35
+ /** The stroke of an eye's outline: about the stem of a bold letter at this size. */
36
+ export const EYE_STROKE = 4;
37
+ const PUPIL_RADIUS = 5.2;
38
+ /** How far a pupil may leave the centre of its eye and stay inside it. */
39
+ const REACH = {
40
+ x: EYE.rx - EYE_STROKE / 2 - PUPIL_RADIUS - 0.5,
41
+ y: EYE.ry - EYE_STROKE / 2 - PUPIL_RADIUS - 0.5,
42
+ };
43
+ const clamp = (value) => Math.max(-1, Math.min(1, Number.isFinite(value) ? value : 0));
44
+ const round = (value) => Math.round(value * 100) / 100;
45
+ /** A gaze no longer than 1: a look to a corner does not leave the eye. */
46
+ export function boundedGaze(gaze) {
47
+ const x = clamp(gaze.x);
48
+ const y = clamp(gaze.y);
49
+ const length = Math.hypot(x, y);
50
+ return length > 1 ? { x: x / length, y: y / length } : { x, y };
51
+ }
52
+ /** The two eyes and their pupils, looking somewhere. */
53
+ export function eyesGeometry(gaze = 'aside') {
54
+ const looking = boundedGaze(typeof gaze === 'string' ? GAZES[gaze] : gaze);
55
+ const eye = (cx) => ({ cx, cy: MIDDLE, ...EYE });
56
+ const pupil = (cx) => ({
57
+ cx: round(cx + looking.x * REACH.x),
58
+ cy: round(MIDDLE + looking.y * REACH.y),
59
+ r: PUPIL_RADIUS,
60
+ });
61
+ return {
62
+ eyes: [eye(CENTRES[0]), eye(CENTRES[1])],
63
+ pupils: [pupil(CENTRES[0]), pupil(CENTRES[1])],
64
+ };
65
+ }
66
+ /**
67
+ * Where the eyes look when something is at a point: the gaze towards it from
68
+ * the middle of the eyes, full when it is `far` away or more.
69
+ */
70
+ export function gazeTowards(from, to, far = 160) {
71
+ const dx = to.x - from.x;
72
+ const dy = to.y - from.y;
73
+ const distance = Math.hypot(dx, dy);
74
+ if (distance === 0 || !Number.isFinite(distance) || far <= 0) {
75
+ return GAZES.ahead;
76
+ }
77
+ const strength = Math.min(1, distance / far);
78
+ return boundedGaze({
79
+ x: (dx / distance) * strength,
80
+ y: (dy / distance) * strength,
81
+ });
82
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The themes without Primer React, the DOM or React: what a native app
3
+ * (Datalayer Mobile) or a build script imports, as
4
+ * `@datalayer/primer-addons/lib/theme/portable`.
5
+ *
6
+ * Everything here is data and pure functions. A test in `__tests__` loads
7
+ * this module in a bare environment and fails if `@primer/react`,
8
+ * `styled-components` or a browser global is reached.
9
+ */
10
+ export * from './colors';
11
+ export * from './indicators';
12
+ export * from './fontStacks';
13
+ export * from './loopEyes';
14
+ export * from './portableTheme';
15
+ export * from './themeTokens';
16
+ export { type ThemeColorDefs, type ThemeStyles, type ThemeShape, DEFAULT_THEME_SHAPE, colorDefsToCSS, shapeVars, buildThemeStyles, } from './css/createThemeCSSVars';
@@ -0,0 +1,20 @@
1
+ /*
2
+ * Copyright (c) 2023-2026 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ /**
6
+ * The themes without Primer React, the DOM or React: what a native app
7
+ * (Datalayer Mobile) or a build script imports, as
8
+ * `@datalayer/primer-addons/lib/theme/portable`.
9
+ *
10
+ * Everything here is data and pure functions. A test in `__tests__` loads
11
+ * this module in a bare environment and fails if `@primer/react`,
12
+ * `styled-components` or a browser global is reached.
13
+ */
14
+ export * from './colors';
15
+ export * from './indicators';
16
+ export * from './fontStacks';
17
+ export * from './loopEyes';
18
+ export * from './portableTheme';
19
+ export * from './themeTokens';
20
+ export { DEFAULT_THEME_SHAPE, colorDefsToCSS, shapeVars, buildThemeStyles, } from './css/createThemeCSSVars';
@@ -1,5 +1,5 @@
1
1
  import { type ColorMode } from './DatalayerBrandThemeProvider';
2
- import { type ThemeVariant } from './themeRegistry';
2
+ import { type ThemeVariant } from './themeTokens';
3
3
  /** A valid CSS custom-property name. */
4
4
  export type CssVariableName = `--${string}`;
5
5
  /**
@@ -3,7 +3,7 @@
3
3
  * Distributed under the terms of the Modified BSD License.
4
4
  */
5
5
  import { systemFontStack } from './fontStacks';
6
- import { themeConfigs } from './themeRegistry';
6
+ import { themeTokens } from './themeTokens';
7
7
  function cssVariables(styles) {
8
8
  const variables = Object.fromEntries(Object.entries(styles)
9
9
  .filter(([name, value]) => name.startsWith('--') && value !== undefined && value !== null)
@@ -25,7 +25,7 @@ function cssVariables(styles) {
25
25
  * instead of translating them into framework-specific color names.
26
26
  */
27
27
  export function exportPortableTheme(variant) {
28
- const config = themeConfigs[variant];
28
+ const config = themeTokens[variant];
29
29
  return {
30
30
  id: variant,
31
31
  label: config.label,
@@ -1,88 +1,16 @@
1
- import { type ColorMode } from './DatalayerBrandThemeProvider';
2
- import { type ThemeStyles } from './css/createThemeCSSVars';
3
- /** Available theme variants. */
4
- export type ThemeVariant = 'datalayer' | 'spatial' | 'lovely' | 'matrix' | 'earth' | 'sand' | 'ivory' | 'sun' | 'loop';
5
- /** A pair of colours for a two-stop gradient. */
6
- export interface GradientPair {
7
- /** Start colour (brighter / brand). */
8
- from: string;
9
- /** End colour (deeper / hover). */
10
- to: string;
11
- }
12
- /**
13
- * Vivid colour triplet for SVG illustrations.
14
- *
15
- * Inspired by OpenAI's blog — ultra-saturated, luminous hues designed
16
- * to glow and pop against both light and dark backgrounds.
17
- */
18
- export interface BrightPalette {
19
- /** Primary vivid accent — the "star" glow colour. */
20
- glow: string;
21
- /** Optimal text colour for content rendered on a `glow` background. */
22
- onGlow: string;
23
- /** Contrasting vivid colour — analogous/complement. */
24
- pop: string;
25
- /** Third vivid colour — sparkle / small highlights. */
26
- spark: string;
27
- /** Vivid red / warm accent — energy, urgency, warmth. */
28
- blaze: string;
29
- /** Vivid blue / cool accent — depth, trust, electricity. */
30
- surge: string;
31
- /** Vivid orange — warm energy, fire, dynamism. */
32
- flame: string;
33
- /** Vivid yellow / gold — highlights, attention, optimism. */
34
- gold: string;
35
- }
1
+ import { type BrightPalette, type ThemeTokens, type ThemeVariant } from './themeTokens';
2
+ export { type BrightPalette, type GradientPair, type ThemeTokens, type ThemeVariant, avatarColorsOf, brightPaletteOf, getCardGradient, getThemeTokens, themeTokens, themeVariants, } from './themeTokens';
36
3
  /**
37
4
  * Complete configuration for a theme, including the Primer theme object,
38
5
  * display metadata, and CSS custom property overrides per color mode.
39
6
  */
40
- export interface ThemeConfig {
41
- /** Human-readable name for UI display. */
42
- label: string;
43
- /** Short description of the theme. */
44
- description: string;
45
- /** Brand color for the theme — used for colored swatch buttons. */
46
- brandColor: string;
47
- /** Recommended default color mode for this theme. */
48
- defaultColorMode: ColorMode;
7
+ export interface ThemeConfig extends ThemeTokens {
49
8
  /** Primer theme object passed to `<ThemeProvider theme={…}>`. */
50
9
  primerTheme: Record<string, any>;
51
- /**
52
- * Per-mode CSS-property overrides for `<DatalayerThemeProvider themeStyles={…}>`,
53
- * and the theme's own scoped stylesheet when it has one (`ThemeStyles.css`).
54
- */
55
- themeStyles: ThemeStyles;
56
- /**
57
- * Per-mode gradient pair for card backgrounds, banners, and other
58
- * decorative surfaces that need a themed two-colour gradient.
59
- */
60
- cardGradient: {
61
- light: GradientPair;
62
- dark: GradientPair;
63
- };
64
- /**
65
- * Vivid colour triplet for SVG illustrations — ultra-saturated,
66
- * luminous hues that glow and pop on dark backgrounds (OpenAI-blog style).
67
- */
68
- brightPalette: BrightPalette;
69
- /**
70
- * Deeper / richer bright palette for light backgrounds.
71
- * Same hue families as `brightPalette` but with higher contrast on
72
- * light surfaces so illustrations don't appear faded.
73
- */
74
- brightPaletteLight: BrightPalette;
75
10
  }
76
11
  export declare const themeConfigs: Record<ThemeVariant, ThemeConfig>;
77
- /** All available theme variants in display order. */
78
- export declare const themeVariants: ThemeVariant[];
79
12
  /** Look up a theme config by variant name. */
80
13
  export declare function getThemeConfig(variant: ThemeVariant): ThemeConfig;
81
- /**
82
- * Resolve the card gradient for a given theme variant and colour mode.
83
- * Falls back to `datalayer` / `light` when values are missing.
84
- */
85
- export declare function getCardGradient(variant?: ThemeVariant, colorMode?: 'light' | 'dark' | 'auto'): GradientPair;
86
14
  /**
87
15
  * Get the bright (vivid / OpenAI-blog-style) palette for a given theme variant.
88
16
  *