@datalayer/primer-addons 1.0.36 → 1.0.39
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.
- package/README.md +69 -19
- package/lib/components/appearance/AppearanceControls.d.ts +6 -1
- package/lib/components/appearance/AppearanceControls.js +12 -3
- package/lib/components/appearance/AppearanceControlsWithStore.d.ts +4 -0
- package/lib/components/appearance/AppearanceControlsWithStore.js +4 -4
- package/lib/components/appearance/CollaboratorPalette.js +7 -20
- package/lib/components/box/Box.d.ts +103 -16
- package/lib/components/box/Box.js +157 -2
- package/lib/components/box/boxCss.d.ts +805 -0
- package/lib/components/box/boxCss.js +492 -0
- package/lib/components/box/boxTokens.d.ts +129 -0
- package/lib/components/box/boxTokens.js +124 -0
- package/lib/components/calendar-picker/CalendarPicker.js +2 -1
- package/lib/components/card/Card.js +19 -10
- package/lib/components/color/ColorSwatch.js +2 -1
- package/lib/components/color-picker/ColorPicker.js +8 -4
- package/lib/components/date-picker/DatePicker.d.ts +12 -3
- package/lib/components/date-picker/DatePicker.js +24 -8
- package/lib/components/index.d.ts +1 -0
- package/lib/components/index.js +1 -0
- package/lib/components/sheet/Sheet.d.ts +15 -0
- package/lib/components/sheet/Sheet.js +21 -0
- package/lib/reactor/index.d.ts +1 -1
- package/lib/reactor/index.js +1 -1
- package/lib/reactor/page-layout/PageLayout.d.ts +6 -0
- package/lib/reactor/page-layout/PageLayout.js +30 -6
- package/lib/story-helpers.d.ts +2 -2
- package/lib/theme/DatalayerThemeProvider.d.ts +21 -0
- package/lib/theme/DatalayerThemeProvider.js +13 -4
- package/lib/theme/colors/index.d.ts +2 -1
- package/lib/theme/colors/index.js +2 -1
- package/lib/theme/colors/loopColors.d.ts +2 -48
- package/lib/theme/colors/loopColors.js +2 -98
- package/lib/theme/colors/themeAccents.d.ts +81 -0
- package/lib/theme/colors/themeAccents.js +139 -0
- package/lib/theme/css/createThemeCSSVars.d.ts +5 -0
- package/lib/theme/css/createThemeCSSVars.js +5 -0
- package/lib/theme/css/primerBaseVars.d.ts +1 -0
- package/lib/theme/css/primerBaseVars.js +72 -0
- package/lib/theme/index.d.ts +2 -0
- package/lib/theme/index.js +2 -0
- package/lib/theme/loopEyes.d.ts +84 -0
- package/lib/theme/loopEyes.js +82 -0
- package/lib/theme/portable.d.ts +16 -0
- package/lib/theme/portable.js +20 -0
- package/lib/theme/portableTheme.d.ts +1 -1
- package/lib/theme/portableTheme.js +2 -2
- package/lib/theme/themeRegistry.d.ts +3 -75
- package/lib/theme/themeRegistry.js +38 -509
- package/lib/theme/themeTokens.d.ts +101 -0
- package/lib/theme/themeTokens.js +494 -0
- package/lib/theme/themes/datalayerTheme.d.ts +2 -9
- package/lib/theme/themes/datalayerTheme.js +8 -236
- package/lib/theme/themes/datalayerThemeStyles.d.ts +2 -0
- package/lib/theme/themes/datalayerThemeStyles.js +234 -0
- package/lib/theme/themes/earthTheme.d.ts +2 -9
- package/lib/theme/themes/earthTheme.js +8 -235
- package/lib/theme/themes/earthThemeStyles.d.ts +2 -0
- package/lib/theme/themes/earthThemeStyles.js +233 -0
- package/lib/theme/themes/ivoryTheme.d.ts +2 -9
- package/lib/theme/themes/ivoryTheme.js +8 -249
- package/lib/theme/themes/ivoryThemeStyles.d.ts +2 -0
- package/lib/theme/themes/ivoryThemeStyles.js +247 -0
- package/lib/theme/themes/loopTheme.d.ts +13 -144
- package/lib/theme/themes/loopTheme.js +20 -517
- package/lib/theme/themes/loopThemeStyles.d.ts +129 -0
- package/lib/theme/themes/loopThemeStyles.js +531 -0
- package/lib/theme/themes/lovelyTheme.d.ts +2 -9
- package/lib/theme/themes/lovelyTheme.js +8 -231
- package/lib/theme/themes/lovelyThemeStyles.d.ts +2 -0
- package/lib/theme/themes/lovelyThemeStyles.js +229 -0
- package/lib/theme/themes/matrixTheme.d.ts +2 -9
- package/lib/theme/themes/matrixTheme.js +8 -237
- package/lib/theme/themes/matrixThemeStyles.d.ts +2 -0
- package/lib/theme/themes/matrixThemeStyles.js +235 -0
- package/lib/theme/themes/sandTheme.d.ts +2 -9
- package/lib/theme/themes/sandTheme.js +8 -248
- package/lib/theme/themes/sandThemeStyles.d.ts +2 -0
- package/lib/theme/themes/sandThemeStyles.js +246 -0
- package/lib/theme/themes/spatialTheme.d.ts +2 -9
- package/lib/theme/themes/spatialTheme.js +8 -231
- package/lib/theme/themes/spatialThemeStyles.d.ts +2 -0
- package/lib/theme/themes/spatialThemeStyles.js +229 -0
- package/lib/theme/themes/sunTheme.d.ts +2 -9
- package/lib/theme/themes/sunTheme.js +8 -249
- package/lib/theme/themes/sunThemeStyles.d.ts +2 -0
- package/lib/theme/themes/sunThemeStyles.js +247 -0
- package/lib/utils/Portals.d.ts +7 -0
- package/lib/utils/Portals.js +7 -0
- package/package.json +1 -1
|
@@ -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';
|
|
@@ -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 {
|
|
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 =
|
|
28
|
+
const config = themeTokens[variant];
|
|
29
29
|
return {
|
|
30
30
|
id: variant,
|
|
31
31
|
label: config.label,
|
|
@@ -1,88 +1,16 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
|
|
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
|
*
|