@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
@@ -1,525 +1,32 @@
1
1
  /*
2
- * Copyright (c) 2023-2025 Datalayer, Inc.
2
+ * Copyright (c) 2023-2026 Datalayer, Inc.
3
3
  * Distributed under the terms of the Modified BSD License.
4
4
  */
5
5
  /**
6
- * Loop Theme for Primer React.
7
- *
8
- * Soft and clear, for somebody who is not here for the software: one accent,
9
- * neutral everything else. A white (or near-black) canvas, a deep-grey ink
10
- * rather than black, faint hairlines, surfaces that float on soft shadows
11
- * instead of sitting in boxes, generous rounding, and one filled button in
12
- * the accent — the thing to press, plain to see. Inter, with the system
13
- * sans-serif stack behind it, titles set tight.
14
- * Theming is applied via **CSS custom-property overrides**.
15
- *
16
- * Unlike the other themes it also sets **shape**: rounder corners, and
17
- * its own `--loop-*` properties for what an application is drawn with —
18
- * its accent, the stage behind it, a bubble, a frame, a face.
6
+ * The Loop theme for Primer React: its styles, from `./loopThemeStyles`, and
7
+ * the Primer theme object. Code that needs the tokens without Primer React
8
+ * (a native app) imports the styles module instead.
19
9
  */
20
10
  import { theme as primerTheme } from '@primer/react';
21
- import { loopAccentVars, loopColors } from '../colors/loopColors';
22
- import { buildThemeStyles } from '../css/createThemeCSSVars';
23
- /* ── Light-mode colour definitions ───────────────────────────────────── */
24
- export const loopLight = {
25
- canvas: {
26
- default: loopColors.white,
27
- subtle: loopColors.subtle,
28
- },
29
- fg: {
30
- default: loopColors.ink,
31
- muted: loopColors.gray,
32
- onEmphasis: '#FFFFFF',
33
- },
34
- accent: {
35
- fg: loopColors.loopText,
36
- // The accent itself, as on dark: the soft mint that dark text sits on —
37
- // the filled button, the person's bubble, the assistant's avatar. The
38
- // chat pairs it with the button's text, so the two stay one colour.
39
- emphasis: loopColors.loopBrand,
40
- muted: loopColors.loopBrand,
41
- subtle: loopColors.loopTint,
42
- },
43
- success: {
44
- fg: loopColors.successBrand,
45
- emphasis: loopColors.successBrand,
46
- muted: loopColors.successAccent,
47
- subtle: loopColors.successTint,
48
- },
49
- attention: {
50
- fg: loopColors.attentionBrand,
51
- emphasis: loopColors.attentionBrand,
52
- muted: loopColors.attentionAccent,
53
- subtle: loopColors.attentionTint,
54
- },
55
- danger: {
56
- fg: loopColors.dangerBrand,
57
- emphasis: loopColors.dangerBrand,
58
- muted: loopColors.dangerAccent,
59
- subtle: loopColors.dangerTint,
60
- },
61
- severe: {
62
- fg: loopColors.severeBrand,
63
- emphasis: loopColors.severeBrand,
64
- muted: loopColors.severeAccent,
65
- subtle: loopColors.severeTint,
66
- },
67
- done: {
68
- fg: loopColors.doneBrand,
69
- emphasis: loopColors.doneBrand,
70
- muted: loopColors.doneAccent,
71
- subtle: loopColors.doneTint,
72
- },
73
- border: {
74
- // Hairlines: 7% of the ink, as solid colours on white — a surface is
75
- // told apart by its shadow more than by a line.
76
- default: '#ECECEE',
77
- muted: '#F2F2F4',
78
- },
79
- btn: {
80
- text: loopColors.ink,
81
- bg: loopColors.subtle,
82
- border: 'transparent',
83
- hoverBg: '#ECECEF',
84
- hoverBorder: 'transparent',
85
- activeBg: '#E3E3E7',
86
- activeBorder: 'transparent',
87
- selectedBg: '#E3E3E7',
88
- counterBg: 'rgba(29, 29, 31, 0.08)',
89
- // The one filled button of a screen, in the accent: the soft mint, with
90
- // its dark text — the same pastel as on dark, never the platform's deep green.
91
- primary: {
92
- text: loopColors.loopOn,
93
- bg: loopColors.loopBrand,
94
- border: loopColors.loopBrand,
95
- hoverBg: loopColors.loopBrandHover,
96
- hoverBorder: loopColors.loopBrandHover,
97
- selectedBg: loopColors.loopAccent,
98
- disabledText: 'rgba(6, 40, 30, 0.5)',
99
- disabledBg: '#CDEFE2',
100
- disabledBorder: '#CDEFE2',
101
- icon: loopColors.loopOn,
102
- counterBg: 'rgba(6, 40, 30, 0.12)',
103
- },
104
- outline: {
105
- text: loopColors.loopText,
106
- hoverText: loopColors.loopOn,
107
- hoverBg: loopColors.loopBrand,
108
- hoverBorder: loopColors.loopBrand,
109
- hoverCounterBg: 'rgba(6, 40, 30, 0.12)',
110
- selectedText: loopColors.loopOn,
111
- selectedBg: loopColors.loopAccent,
112
- selectedBorder: loopColors.loopAccent,
113
- disabledText: loopColors.gray,
114
- disabledBg: loopColors.subtle,
115
- disabledCounterBg: 'rgba(0, 0, 0, 0.05)',
116
- counterBg: 'rgba(0, 0, 0, 0.05)',
117
- counterFg: loopColors.loopText,
118
- hoverCounterFg: loopColors.loopOn,
119
- disabledCounterFg: loopColors.gray,
120
- },
121
- danger: {
122
- text: loopColors.dangerBrand,
123
- hoverText: '#FFFFFF',
124
- hoverBg: loopColors.dangerBrand,
125
- hoverBorder: loopColors.dangerBrand,
126
- hoverCounterBg: 'rgba(255, 255, 255, 0.2)',
127
- selectedText: '#FFFFFF',
128
- selectedBg: '#9C302A',
129
- selectedBorder: '#9C302A',
130
- disabledText: 'rgba(191, 63, 56, 0.5)',
131
- disabledBg: loopColors.subtle,
132
- disabledCounterBg: 'rgba(191, 63, 56, 0.05)',
133
- counterBg: 'rgba(191, 63, 56, 0.1)',
134
- counterFg: loopColors.dangerBrand,
135
- hoverCounterFg: '#FFFFFF',
136
- disabledCounterFg: 'rgba(191, 63, 56, 0.5)',
137
- icon: loopColors.dangerBrand,
138
- },
139
- },
140
- };
141
- /* ── Dark-mode colour definitions ────────────────────────────────────── */
142
- export const loopDark = {
143
- canvas: {
144
- default: loopColors.black,
145
- subtle: loopColors.subtleDark,
146
- },
147
- fg: {
148
- default: loopColors.inkDark,
149
- muted: loopColors.grayDark,
150
- onEmphasis: '#FFFFFF',
151
- },
152
- accent: {
153
- fg: loopColors.loopBright,
154
- // The accent itself, on dark: a pastel that dark text sits on.
155
- emphasis: loopColors.loopBrand,
156
- muted: loopColors.loopBrand,
157
- subtle: loopColors.loopTintDark,
158
- },
159
- success: {
160
- fg: loopColors.successAccent,
161
- emphasis: loopColors.successBrand,
162
- muted: loopColors.successAccent,
163
- subtle: '#12241B',
164
- },
165
- attention: {
166
- fg: loopColors.attentionAccent,
167
- emphasis: '#8A5710',
168
- muted: loopColors.attentionAccent,
169
- subtle: '#2A2010',
170
- },
171
- danger: {
172
- fg: loopColors.dangerAccent,
173
- emphasis: loopColors.dangerBrand,
174
- muted: loopColors.dangerAccent,
175
- subtle: '#2C1615',
176
- },
177
- severe: {
178
- fg: loopColors.severeAccent,
179
- emphasis: loopColors.severeBrand,
180
- muted: loopColors.severeAccent,
181
- subtle: '#2B1B10',
182
- },
183
- done: {
184
- fg: loopColors.doneAccent,
185
- emphasis: loopColors.doneBrand,
186
- muted: loopColors.doneAccent,
187
- subtle: '#1C1A27',
188
- },
189
- border: {
190
- // Hairlines: 10% of the ink, as solid colours on near-black.
191
- default: '#2A2A2C',
192
- muted: '#222224',
193
- },
194
- btn: {
195
- text: loopColors.inkDark,
196
- bg: loopColors.subtleDark,
197
- border: 'transparent',
198
- hoverBg: '#28282B',
199
- hoverBorder: 'transparent',
200
- activeBg: '#303033',
201
- activeBorder: 'transparent',
202
- selectedBg: '#303033',
203
- counterBg: 'rgba(245, 245, 247, 0.12)',
204
- // The one filled button of a screen, in the accent: the pastel, with
205
- // its dark text, the brightest thing on a dark page.
206
- primary: {
207
- text: loopColors.loopOn,
208
- bg: loopColors.loopBrand,
209
- border: loopColors.loopBrand,
210
- hoverBg: loopColors.loopBright,
211
- hoverBorder: loopColors.loopBright,
212
- selectedBg: '#6CCFAA',
213
- disabledText: 'rgba(6, 40, 30, 0.6)',
214
- disabledBg: 'rgba(122, 219, 184, 0.35)',
215
- disabledBorder: 'transparent',
216
- icon: loopColors.loopOn,
217
- counterBg: 'rgba(6, 40, 30, 0.15)',
218
- },
219
- outline: {
220
- text: loopColors.loopBright,
221
- hoverText: loopColors.loopOn,
222
- hoverBg: loopColors.loopBright,
223
- hoverBorder: loopColors.loopBright,
224
- hoverCounterBg: 'rgba(0, 0, 0, 0.2)',
225
- selectedText: loopColors.loopOn,
226
- selectedBg: loopColors.loopBrand,
227
- selectedBorder: loopColors.loopBrand,
228
- disabledText: 'rgba(143, 229, 198, 0.5)',
229
- disabledBg: 'rgba(143, 229, 198, 0.1)',
230
- disabledCounterBg: 'rgba(143, 229, 198, 0.05)',
231
- counterBg: 'rgba(143, 229, 198, 0.1)',
232
- counterFg: loopColors.loopBright,
233
- hoverCounterFg: loopColors.loopOn,
234
- disabledCounterFg: 'rgba(143, 229, 198, 0.5)',
235
- },
236
- danger: {
237
- text: loopColors.dangerAccent,
238
- hoverText: '#FFFFFF',
239
- hoverBg: loopColors.dangerBrand,
240
- hoverBorder: loopColors.dangerAccent,
241
- hoverCounterBg: 'rgba(255, 255, 255, 0.2)',
242
- selectedText: '#FFFFFF',
243
- selectedBg: '#9C302A',
244
- selectedBorder: loopColors.dangerAccent,
245
- disabledText: 'rgba(240, 138, 131, 0.5)',
246
- disabledBg: 'rgba(240, 138, 131, 0.1)',
247
- disabledCounterBg: 'rgba(240, 138, 131, 0.05)',
248
- counterBg: 'rgba(240, 138, 131, 0.1)',
249
- counterFg: loopColors.dangerAccent,
250
- hoverCounterFg: '#FFFFFF',
251
- disabledCounterFg: 'rgba(240, 138, 131, 0.5)',
252
- icon: loopColors.dangerAccent,
253
- },
254
- },
255
- };
256
- /* ── Shape, type and motion ──────────────────────────────────────────── */
257
- /**
258
- * What the Loop theme sets beside colour, the same in both modes.
259
- *
260
- * Primer's own radii are made rounder; the `--loop-*` properties are what
261
- * an application is drawn with. A face is an emoji at one of three sizes;
262
- * motion has three durations and one easing.
263
- */
264
- export const loopShapeVars = {
265
- '--borderRadius-small': '10px',
266
- '--borderRadius-medium': '14px',
267
- '--borderRadius-large': '20px',
268
- '--borderRadius-default': '14px',
269
- '--loop-radius-control': '999px',
270
- '--loop-radius-card': '20px',
271
- '--loop-radius-bubble': '22px',
272
- '--loop-radius-frame': '28px',
273
- // Light mode's; `loopShadows` says dark mode's.
274
- '--loop-shadow-frame': '0 1px 2px rgba(0, 0, 0, 0.03), 0 10px 30px rgba(0, 0, 0, 0.06)',
275
- '--loop-face-large': '72px',
276
- '--loop-face-medium': '40px',
277
- '--loop-face-small': '20px',
278
- '--loop-motion-fast': '120ms',
279
- '--loop-motion-medium': '200ms',
280
- '--loop-motion-slow': '320ms',
281
- '--loop-motion-easing': 'cubic-bezier(0.2, 0.8, 0.2, 1)',
282
- };
283
- /** The hairline between two surfaces, per mode. */
284
- const loopHairline = {
285
- light: 'rgba(29, 29, 31, 0.07)',
286
- dark: 'rgba(255, 255, 255, 0.10)',
287
- };
288
- /**
289
- * Shadows, per mode: how a surface floats. Soft and low in the light —
290
- * a card is told apart by its shadow more than by a line; in the dark a
291
- * shadow shows little, so a surface gets a hairline of light and a
292
- * deeper shadow. Primer's own shadow tokens take the same hand, so a menu
293
- * or a dialog floats the way a frame does.
294
- */
295
- export const loopShadows = {
296
- light: {
297
- '--loop-shadow-frame': '0 1px 2px rgba(0, 0, 0, 0.03), 0 10px 30px rgba(0, 0, 0, 0.06)',
298
- '--theme-shadow': '0 1px 2px rgba(0, 0, 0, 0.03), 0 10px 30px rgba(0, 0, 0, 0.06)',
299
- '--shadow-resting-xsmall': '0 1px 1px rgba(0, 0, 0, 0.03)',
300
- '--shadow-resting-small': '0 1px 2px rgba(0, 0, 0, 0.04)',
301
- '--shadow-resting-medium': '0 2px 8px rgba(0, 0, 0, 0.05)',
302
- '--shadow-floating-small': '0 0 0 1px rgba(29, 29, 31, 0.04), 0 4px 14px rgba(0, 0, 0, 0.08)',
303
- '--shadow-floating-medium': '0 0 0 1px rgba(29, 29, 31, 0.04), 0 8px 24px rgba(0, 0, 0, 0.10)',
304
- '--shadow-floating-large': '0 0 0 1px rgba(29, 29, 31, 0.04), 0 16px 48px rgba(0, 0, 0, 0.14)',
305
- '--shadow-floating-xlarge': '0 0 0 1px rgba(29, 29, 31, 0.04), 0 24px 64px rgba(0, 0, 0, 0.18)',
306
- },
307
- dark: {
308
- '--loop-shadow-frame': '0 0 0 1px rgba(255, 255, 255, 0.06), 0 12px 36px rgba(0, 0, 0, 0.45)',
309
- '--theme-shadow': '0 0 0 1px rgba(255, 255, 255, 0.06), 0 12px 36px rgba(0, 0, 0, 0.45)',
310
- '--shadow-resting-xsmall': '0 0 0 1px rgba(255, 255, 255, 0.05)',
311
- '--shadow-resting-small': '0 0 0 1px rgba(255, 255, 255, 0.06), 0 1px 2px rgba(0, 0, 0, 0.3)',
312
- '--shadow-resting-medium': '0 0 0 1px rgba(255, 255, 255, 0.06), 0 2px 8px rgba(0, 0, 0, 0.35)',
313
- '--shadow-floating-small': '0 0 0 1px rgba(255, 255, 255, 0.08), 0 4px 14px rgba(0, 0, 0, 0.45)',
314
- '--shadow-floating-medium': '0 0 0 1px rgba(255, 255, 255, 0.08), 0 8px 24px rgba(0, 0, 0, 0.5)',
315
- '--shadow-floating-large': '0 0 0 1px rgba(255, 255, 255, 0.08), 0 16px 48px rgba(0, 0, 0, 0.55)',
316
- '--shadow-floating-xlarge': '0 0 0 1px rgba(255, 255, 255, 0.08), 0 24px 64px rgba(0, 0, 0, 0.6)',
317
- },
318
- };
319
- /**
320
- * Type (LOOP T-04): one face, two weights, five sizes, one line-height per
321
- * size — each line a multiple of 4px.
322
- *
323
- * | Size | Line | Tokens |
324
- * |-----------------|---------------|--------------------------------------|
325
- * | 2rem (32px) | 1.25 (40px) | display, title large |
326
- * | 1.25rem (20px) | 1.4 (28px) | title medium, subtitle |
327
- * | 1rem (16px) | 1.5 (24px) | title small, body large |
328
- * | 0.875rem (14px) | 1.4286 (20px) | body medium — the body of the theme |
329
- * | 0.75rem (12px) | 1.3333 (16px) | body small, caption |
330
- *
331
- * The weights are 400 (body, subtitle) and 600 (titles, display, and what
332
- * Primer sets in its medium weight — a button's label); Primer's light weight
333
- * is 400. The titles are set tight and a little closer, as a good display face
334
- * is; the body left alone. The tracking is a token for a component to apply,
335
- * since a CSS font shorthand carries none.
336
- */
337
- export const loopTypeScale = {
338
- display: { size: '2rem', lineHeight: '1.25' },
339
- title: { size: '1.25rem', lineHeight: '1.4' },
340
- heading: { size: '1rem', lineHeight: '1.5' },
341
- body: { size: '0.875rem', lineHeight: '1.4286' },
342
- small: { size: '0.75rem', lineHeight: '1.3333' },
343
- };
344
- /** The two weights of the `loop` theme. */
345
- export const loopFontWeights = { regular: 400, semibold: 600 };
346
- export const loopTypeVars = (font) => {
347
- const { display, title, heading, body, small } = loopTypeScale;
348
- const { regular, semibold } = loopFontWeights;
349
- const shorthand = (weight, step) => `${weight} ${step.size}/${step.lineHeight} ${font}`;
350
- return {
351
- '--base-text-weight-light': String(regular),
352
- '--base-text-weight-normal': String(regular),
353
- '--base-text-weight-medium': String(semibold),
354
- '--base-text-weight-semibold': String(semibold),
355
- '--text-display-size': display.size,
356
- '--text-display-lineHeight': display.lineHeight,
357
- '--text-display-lineBoxHeight': display.lineHeight,
358
- '--text-display-weight': String(semibold),
359
- '--text-title-size-large': display.size,
360
- '--text-title-lineHeight-large': display.lineHeight,
361
- '--text-title-size-medium': title.size,
362
- '--text-title-lineHeight-medium': title.lineHeight,
363
- '--text-subtitle-size': title.size,
364
- '--text-subtitle-lineHeight': title.lineHeight,
365
- '--text-title-size-small': heading.size,
366
- '--text-title-lineHeight-small': heading.lineHeight,
367
- '--text-body-size-large': heading.size,
368
- '--text-body-lineHeight-large': heading.lineHeight,
369
- '--text-body-size-medium': body.size,
370
- '--text-body-lineHeight-medium': body.lineHeight,
371
- '--text-body-size-small': small.size,
372
- '--text-body-lineHeight-small': small.lineHeight,
373
- '--text-caption-size': small.size,
374
- '--text-caption-lineHeight': small.lineHeight,
375
- '--text-display-shorthand': shorthand(semibold, display),
376
- '--text-title-shorthand-large': shorthand(semibold, display),
377
- '--text-title-shorthand-medium': shorthand(semibold, title),
378
- '--text-title-shorthand-small': shorthand(semibold, heading),
379
- '--text-subtitle-shorthand': shorthand(regular, title),
380
- '--text-body-shorthand-large': shorthand(regular, heading),
381
- '--text-body-shorthand-medium': shorthand(regular, body),
382
- '--text-body-shorthand-small': shorthand(regular, small),
383
- '--text-caption-shorthand': shorthand(regular, small),
384
- '--loop-tracking-display': '-0.02em',
385
- '--loop-tracking-title': '-0.012em',
386
- '--loop-tracking-body': '0',
387
- };
388
- };
389
- /**
390
- * The stage, lit: a soft fall from the stage tint at the top to the quiet
391
- * tint at the bottom, for the page an application sits on. Both tints are
392
- * the accent's, so an application's own colour lights its stage.
393
- */
394
- export const loopStageGradient = 'radial-gradient(140% 100% at 50% 0%, var(--loop-stage) 0%, var(--loop-quiet) 100%)';
395
- /* ── Exports ─────────────────────────────────────────────────────────── */
11
+ import { loopFontWeights } from './loopThemeStyles';
12
+ export * from './loopThemeStyles';
396
13
  /**
397
14
  * The Primer theme object.
398
15
  *
399
- * Since theming is done entirely via CSS custom properties
400
- * (see `loopThemeStyles`), this is just the unmodified default Primer
401
- * theme kept for backward compatibility.
16
+ * Theming is done through CSS custom properties (see `loopThemeStyles`), but
17
+ * `sx` reads its weights from this object: Primer's `semibold` is 500 and its
18
+ * `light` 300, so `fontWeight: 'semibold'` drew a third weight beside the
19
+ * theme's two. Here the four names are the two weights (LOOP T-04, T-17):
20
+ * `light` and `normal` the regular, `semibold` and `bold` the semibold.
21
+ * Everything else is Primer's default.
402
22
  */
403
- export const loopTheme = primerTheme;
404
- /**
405
- * Inter, then its metric-matched fallback, then the system's own sans-serif
406
- * (LOOP T-04). One face, two weights (400 and 600). The face is served by the
407
- * page's own build: a page wearing the theme imports
408
- * `@datalayer/primer-addons/style/loop-face.css`, which declares
409
- * `Inter Variable` from `@fontsource-variable/inter` and `Inter Fallback`, a
410
- * local Arial drawn to Inter's measure. The text paints in the fallback first
411
- * and does not move when Inter arrives; a page that has not imported the
412
- * stylesheet shows the system face.
413
- */
414
- export const loopFontFamily = '"Inter Variable", "Inter Fallback", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';
415
- /**
416
- * Motion (LOOP T-10): three durations and one easing, for three things — a
417
- * status changing, a message arriving, a pane opening. Nothing else moves.
418
- */
419
- export const loopMotionVars = {
420
- '--loop-motion-status': '120ms',
421
- '--loop-motion-message': '200ms',
422
- '--loop-motion-pane': '320ms',
423
- '--loop-motion-easing': 'cubic-bezier(0.2, 0, 0, 1)',
424
- };
425
- /**
426
- * The focus ring (LOOP T-15): 3 to 1 against the page and around a pill of
427
- * any accent, in both modes. In light mode the deep mint does it — darker than the text, the one place it is —
428
- * a halo in the theme's colour, as a system's own focus ring is — 6.5 to 1
429
- * on white and 3.28 or more around every pastel. In dark mode no
430
- * colour clears 3 to 1 against both the near-black page and the six
431
- * pastels, the light ink least of all (under 1.8 to 1 on the pastels): a
432
- * mid grey does, at 3.04 to 1 — and 2.77 to 1 on the subtle dark surface,
433
- * the one place it falls short.
434
- */
435
- export const loopFocusRing = { light: loopColors.loopRing, dark: '#636363' };
436
- /**
437
- * The controls, as one family (LOOP T-09): every single-line control is a
438
- * pill — a button, a text input, a select, a segmented control (outside and
439
- * each segment), a button group's two ends, a toggle switch, an underline
440
- * tab's hover. A multi-line text area keeps `--borderRadius-medium`: a pill
441
- * of many lines is a lozenge. Menus and overlays keep the card's radius,
442
- * `--borderRadius-large`, which the theme already sets.
443
- *
444
- * Primer takes every control's corners from `--borderRadius-medium`, which
445
- * cards and list items take too, so this cannot be a token: it is a
446
- * stylesheet, scoped by the theme provider (`ThemeStyles.css`). Primer's
447
- * class names are CSS-module hashes (`prc-Button-ButtonBase-c50BI`), so the
448
- * selectors match their stable prefix; the toggle switch is a
449
- * styled-component, matched by its display name, which styled-components
450
- * puts in its class (`ToggleSwitch__SwitchButton-sc-e6gszy-0`). A test reads each of them
451
- * back from the installed `@primer/react`.
452
- *
453
- * Where a control draws more than one element from the token — a segmented
454
- * control's track and segments, a button group's ends — the token itself is
455
- * set on the control, and Primer's own rules draw the pill.
456
- */
457
- export const loopControlsSelectors = {
458
- button: '[class*="prc-Button-ButtonBase"]',
459
- textInput: '[class*="prc-components-TextInputBaseWrapper"]',
460
- textArea: '[class*="prc-Textarea-TextArea"]',
461
- segmentedControl: '[class*="prc-SegmentedControl-SegmentedControl"]',
462
- buttonGroup: '[class*="prc-ButtonGroup-ButtonGroup"]',
463
- underlineTab: '[class*="prc-components-UnderlineItem"]',
464
- toggleTrack: '[class*="ToggleSwitch__SwitchButton-"]',
465
- toggleKnob: '[class*="ToggleSwitch__ToggleKnob-"]',
466
- };
467
- const sel = loopControlsSelectors;
468
- export const loopControlsCss = `
469
- :scope ${sel.button},
470
- :scope ${sel.textInput}:not(:has(${sel.textArea})),
471
- :scope ${sel.segmentedControl},
472
- :scope ${sel.underlineTab},
473
- :scope ${sel.toggleTrack},
474
- :scope ${sel.toggleKnob} {
475
- --borderRadius-medium: var(--loop-radius-control);
476
- border-radius: var(--loop-radius-control);
477
- }
478
- :scope ${sel.buttonGroup} {
479
- --borderRadius-medium: var(--loop-radius-control);
480
- }
481
- :scope b,
482
- :scope strong {
483
- font-weight: var(--base-text-weight-semibold);
484
- }
485
- `;
486
- /** Comprehensive Primer CSS-variable overrides for light & dark mode. */
487
- export const loopThemeStyles = buildThemeStyles(loopLight, loopDark, {
488
- fontFamily: loopFontFamily,
489
- css: loopControlsCss,
490
- // Rounder than the others: a pill for a control, soft cards, round bubbles.
491
- shape: {
492
- radiusControl: loopShapeVars['--loop-radius-control'],
493
- radiusCard: loopShapeVars['--loop-radius-card'],
494
- radiusBubble: loopShapeVars['--loop-radius-bubble'],
495
- radiusFrame: loopShapeVars['--loop-radius-frame'],
496
- shadow: loopShapeVars['--loop-shadow-frame'],
497
- motionStatus: loopMotionVars['--loop-motion-status'],
498
- motionMessage: loopMotionVars['--loop-motion-message'],
499
- motionPane: loopMotionVars['--loop-motion-pane'],
500
- motionEasing: loopMotionVars['--loop-motion-easing'],
501
- },
502
- variables: {
503
- light: {
504
- ...loopShapeVars,
505
- ...loopAccentVars('green', 'light'),
506
- ...loopMotionVars,
507
- ...loopShadows.light,
508
- ...loopTypeVars(loopFontFamily),
509
- '--loop-stage-gradient': loopStageGradient,
510
- '--loop-hairline': loopHairline.light,
511
- '--focus-outlineColor': loopFocusRing.light,
512
- },
513
- dark: {
514
- ...loopShapeVars,
515
- ...loopAccentVars('green', 'dark'),
516
- ...loopMotionVars,
517
- ...loopShadows.dark,
518
- ...loopTypeVars(loopFontFamily),
519
- '--loop-stage-gradient': loopStageGradient,
520
- '--loop-hairline': loopHairline.dark,
521
- '--focus-outlineColor': loopFocusRing.dark,
522
- },
23
+ export const loopTheme = {
24
+ ...primerTheme,
25
+ fontWeights: {
26
+ light: loopFontWeights.regular,
27
+ normal: loopFontWeights.regular,
28
+ semibold: loopFontWeights.semibold,
29
+ bold: loopFontWeights.semibold,
523
30
  },
524
- });
31
+ };
525
32
  export default loopTheme;
@@ -0,0 +1,135 @@
1
+ import { type ThemeColorDefs } from '../css/createThemeCSSVars';
2
+ export declare const loopLight: ThemeColorDefs;
3
+ export declare const loopDark: ThemeColorDefs;
4
+ /**
5
+ * What the Loop theme sets beside colour, the same in both modes.
6
+ *
7
+ * Primer's own radii are made rounder; the `--loop-*` properties are what
8
+ * an application is drawn with. A face is an emoji at one of three sizes;
9
+ * motion has three durations and one easing.
10
+ */
11
+ export declare const loopShapeVars: Record<string, string>;
12
+ /**
13
+ * Shadows, per mode: how a surface floats. Soft and low in the light —
14
+ * a card is told apart by its shadow more than by a line; in the dark a
15
+ * shadow shows little, so a surface gets a hairline of light and a
16
+ * deeper shadow. Primer's own shadow tokens take the same hand, so a menu
17
+ * or a dialog floats the way a frame does.
18
+ */
19
+ export declare const loopShadows: Record<'light' | 'dark', Record<string, string>>;
20
+ /**
21
+ * Type (LOOP T-04): one face, two weights, five sizes, one line-height per
22
+ * size — each line a multiple of 4px.
23
+ *
24
+ * | Size | Line | Tokens |
25
+ * |-----------------|---------------|--------------------------------------|
26
+ * | 2rem (32px) | 1.25 (40px) | display, title large |
27
+ * | 1.25rem (20px) | 1.4 (28px) | title medium, subtitle |
28
+ * | 1rem (16px) | 1.5 (24px) | title small, body large |
29
+ * | 0.875rem (14px) | 1.4286 (20px) | body medium — the body of the theme |
30
+ * | 0.75rem (12px) | 1.3333 (16px) | body small, caption |
31
+ *
32
+ * The weights are 400 (body, subtitle) and 600 (titles, display, and what
33
+ * Primer sets in its medium weight — a button's label); Primer's light weight
34
+ * is 400. The titles are set tight and a little closer, as a good display face
35
+ * is; the body left alone. The tracking is a token for a component to apply,
36
+ * since a CSS font shorthand carries none.
37
+ */
38
+ export declare const loopTypeScale: {
39
+ readonly display: {
40
+ readonly size: "2rem";
41
+ readonly lineHeight: "1.25";
42
+ };
43
+ readonly title: {
44
+ readonly size: "1.25rem";
45
+ readonly lineHeight: "1.4";
46
+ };
47
+ readonly heading: {
48
+ readonly size: "1rem";
49
+ readonly lineHeight: "1.5";
50
+ };
51
+ readonly body: {
52
+ readonly size: "0.875rem";
53
+ readonly lineHeight: "1.4286";
54
+ };
55
+ readonly small: {
56
+ readonly size: "0.75rem";
57
+ readonly lineHeight: "1.3333";
58
+ };
59
+ };
60
+ /** The two weights of the `loop` theme. */
61
+ export declare const loopFontWeights: {
62
+ readonly regular: 400;
63
+ readonly semibold: 600;
64
+ };
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
+ /**
73
+ * Inter, then its metric-matched fallback, then the system's own sans-serif
74
+ * (LOOP T-04). One face, two weights (400 and 600). The face is served by the
75
+ * page's own build: a page wearing the theme imports
76
+ * `@datalayer/primer-addons/style/loop-face.css`, which declares
77
+ * `Inter Variable` from `@fontsource-variable/inter` and `Inter Fallback`, a
78
+ * local Arial drawn to Inter's measure. The text paints in the fallback first
79
+ * and does not move when Inter arrives; a page that has not imported the
80
+ * stylesheet shows the system face.
81
+ */
82
+ export declare const loopFontFamily = "\"Inter Variable\", \"Inter Fallback\", ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif";
83
+ /**
84
+ * Motion (LOOP T-10): three durations and one easing, for three things — a
85
+ * status changing, a message arriving, a pane opening. Nothing else moves.
86
+ */
87
+ export declare const loopMotionVars: Record<string, string>;
88
+ /**
89
+ * The focus ring (LOOP T-15): 3 to 1 against the page and around a pill of
90
+ * any accent, in both modes. In light mode the deep mint does it — darker than the text, the one place it is —
91
+ * a halo in the theme's colour, as a system's own focus ring is — 6.5 to 1
92
+ * on white and 3.28 or more around every pastel. In dark mode no
93
+ * colour clears 3 to 1 against both the near-black page and the six
94
+ * pastels, the light ink least of all (under 1.8 to 1 on the pastels): a
95
+ * mid grey does, at 3.04 to 1 — and 2.77 to 1 on the subtle dark surface,
96
+ * the one place it falls short.
97
+ */
98
+ export declare const loopFocusRing: {
99
+ readonly light: string;
100
+ readonly dark: "#636363";
101
+ };
102
+ /**
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.
122
+ */
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
+ export declare const loopControlsCss: string;
134
+ /** Comprehensive Primer CSS-variable overrides for light & dark mode. */
135
+ export declare const loopThemeStyles: import("../css/createThemeCSSVars").ThemeStyles;