@datalayer/primer-addons 1.0.47 → 1.0.49
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/lib/components/appearance/AppearanceControls.js +2 -1
- package/lib/components/appearance/ColorModeCircle.js +2 -1
- package/lib/components/appearance/ThemeAccents.d.ts +44 -0
- package/lib/components/appearance/ThemeAccents.js +117 -0
- package/lib/components/appearance/ThemePalettePreview.d.ts +14 -0
- package/lib/components/appearance/ThemePalettePreview.js +24 -0
- package/lib/components/appearance/ThemePaletteSwatches.d.ts +33 -0
- package/lib/components/appearance/ThemePaletteSwatches.js +28 -0
- package/lib/components/appearance/index.d.ts +3 -0
- package/lib/components/appearance/index.js +3 -0
- package/lib/components/card/Card.d.ts +14 -0
- package/lib/components/card/Card.js +29 -3
- package/lib/components/card/Card.stories.d.ts +2 -0
- package/lib/components/card/Card.stories.js +3 -0
- package/lib/components/logo/DatalayerLogo.js +17 -1
- package/lib/reactor/AppearancePlugin.d.ts +2 -0
- package/lib/reactor/AppearancePlugin.js +2 -0
- package/lib/theme/colors/index.d.ts +1 -0
- package/lib/theme/colors/index.js +3 -0
- package/lib/theme/colors/metalColors.d.ts +78 -0
- package/lib/theme/colors/metalColors.js +71 -0
- package/lib/theme/index.d.ts +1 -0
- package/lib/theme/index.js +1 -0
- package/lib/theme/palettes/ColorPalette.js +41 -1
- package/lib/theme/themeRegistry.js +2 -0
- package/lib/theme/themeTokens.d.ts +1 -1
- package/lib/theme/themeTokens.js +50 -0
- package/lib/theme/themes/metalTheme.d.ts +1083 -0
- package/lib/theme/themes/metalTheme.js +21 -0
- package/lib/theme/themes/metalThemeStyles.d.ts +25 -0
- package/lib/theme/themes/metalThemeStyles.js +343 -0
- package/package.json +2 -2
- package/style/fonts/GEIST-LICENSE +93 -0
- package/style/fonts/geist-latin-ext-wght-normal.woff2 +0 -0
- package/style/fonts/geist-latin-wght-normal.woff2 +0 -0
- package/style/fonts/geist-mono-latin-wght-normal.woff2 +0 -0
- package/style/metal-face.css +42 -0
|
@@ -9,6 +9,7 @@ import { MoonIcon, SunIcon, DeviceDesktopIcon } from "@primer/octicons-react";
|
|
|
9
9
|
import { Box } from "../box/Box";
|
|
10
10
|
import { themeVariants, themeConfigs, } from "../../theme";
|
|
11
11
|
import { ThemePreviewCard } from "./ThemePreviewCard";
|
|
12
|
+
import { ThemePalettePreview } from "./ThemePalettePreview";
|
|
12
13
|
export function AppearanceControls({ colorMode, themeVariant, onColorModeChange, onThemeChange, showColorMode = true, showThemeChooser = true, showThemePreviews = false, themesPerLine, }) {
|
|
13
14
|
// At most `themesPerLine` swatches on a line when given, each line centred,
|
|
14
15
|
// so a shorter last line sits in the middle under the full ones; one line
|
|
@@ -92,7 +93,7 @@ export function AppearanceControls({ colorMode, themeVariant, onColorModeChange,
|
|
|
92
93
|
outlineColor: "accent.fg",
|
|
93
94
|
outlineOffset: 1,
|
|
94
95
|
},
|
|
95
|
-
}, children: isPreviewOpen ? "Hide preview" : "Show preview" })] }), isPreviewOpen ? (_jsx(ThemePreviewCard, { variant: themeVariant, colorMode: colorMode,
|
|
96
|
+
}, children: isPreviewOpen ? "Hide preview" : "Show preview" })] }), isPreviewOpen ? (_jsxs(_Fragment, { children: [_jsx(ThemePreviewCard, { variant: themeVariant, colorMode: colorMode, compact: true, showDescription: true }), _jsx(ThemePalettePreview, { variant: themeVariant, colorMode: colorMode })] })) : null] })) : (_jsx(Box, { sx: {
|
|
96
97
|
px: 2,
|
|
97
98
|
// First in the controls when the colour mode is hidden.
|
|
98
99
|
pt: showColorMode ? 0 : 2,
|
|
@@ -87,7 +87,8 @@ export function ColorModeCircle({ colorMode, onColorModeChange, size = 28, hover
|
|
|
87
87
|
minWidth: size,
|
|
88
88
|
width: size,
|
|
89
89
|
height: size,
|
|
90
|
-
|
|
90
|
+
// A control like the theme's others: round on Loop, square on VS Code.
|
|
91
|
+
borderRadius: shape === 'circle' ? '50%' : 'var(--theme-radius-control, 6px)',
|
|
91
92
|
display: 'inline-flex',
|
|
92
93
|
alignItems: 'center',
|
|
93
94
|
justifyContent: 'center',
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The accents an application may name, over the theme it wears: the theme's
|
|
3
|
+
* own accent and the six of `themeAccentNames`, each laid over the theme
|
|
4
|
+
* with `themeAccentVars`.
|
|
5
|
+
*
|
|
6
|
+
* - `ThemeAccentPanel`: one accent at full size, its stage, two bubbles, a
|
|
7
|
+
* link and the controls (the gallery's "Theme Accents" page).
|
|
8
|
+
* - `ThemeAccentSwatch` / `ThemeAccentSwatches`: one box per accent, its
|
|
9
|
+
* name and its values (the appearance picker's preview).
|
|
10
|
+
*
|
|
11
|
+
* They read the theme from the nearest theme provider, so inside a
|
|
12
|
+
* `DatalayerThemeProvider` for another theme they show that theme's.
|
|
13
|
+
*/
|
|
14
|
+
import { type ReactElement } from 'react';
|
|
15
|
+
import { type ThemeAccentName } from '../../theme/colors/themeAccents';
|
|
16
|
+
/** The theme's own accent, or one of the six. */
|
|
17
|
+
export type ThemeAccentChoice = ThemeAccentName | 'theme';
|
|
18
|
+
/** The theme's own accent first, then the six. */
|
|
19
|
+
export declare const themeAccentChoices: ThemeAccentChoice[];
|
|
20
|
+
export interface ThemeAccentPanelProps {
|
|
21
|
+
choice: ThemeAccentChoice;
|
|
22
|
+
mode: 'light' | 'dark';
|
|
23
|
+
}
|
|
24
|
+
/** One accent over the theme: the stage, two bubbles, a link and the controls. */
|
|
25
|
+
export declare function ThemeAccentPanel({ choice, mode }: ThemeAccentPanelProps): ReactElement;
|
|
26
|
+
export interface ThemeAccentSwatchProps {
|
|
27
|
+
choice: ThemeAccentChoice;
|
|
28
|
+
mode: 'light' | 'dark';
|
|
29
|
+
/** Height of the stage block. Default: 40. */
|
|
30
|
+
height?: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* One accent as a swatch: its stage with the accent's fill on it, then its
|
|
34
|
+
* name, the accent's value and the value of its text. The theme's own values
|
|
35
|
+
* are read back from the page, the six from `themeAccents`.
|
|
36
|
+
*/
|
|
37
|
+
export declare function ThemeAccentSwatch({ choice, mode, height }: ThemeAccentSwatchProps): ReactElement;
|
|
38
|
+
export interface ThemeAccentSwatchesProps {
|
|
39
|
+
mode: 'light' | 'dark';
|
|
40
|
+
/** The narrowest a swatch gets before the grid wraps to fewer columns. Default: 104px. */
|
|
41
|
+
minSwatchWidth?: number;
|
|
42
|
+
}
|
|
43
|
+
/** The theme's own accent and the six, one swatch each, in a wrapping grid. */
|
|
44
|
+
export declare function ThemeAccentSwatches({ mode, minSwatchWidth }: ThemeAccentSwatchesProps): ReactElement;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2021-2026 Datalayer, Inc.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* The accents an application may name, over the theme it wears: the theme's
|
|
8
|
+
* own accent and the six of `themeAccentNames`, each laid over the theme
|
|
9
|
+
* with `themeAccentVars`.
|
|
10
|
+
*
|
|
11
|
+
* - `ThemeAccentPanel`: one accent at full size, its stage, two bubbles, a
|
|
12
|
+
* link and the controls (the gallery's "Theme Accents" page).
|
|
13
|
+
* - `ThemeAccentSwatch` / `ThemeAccentSwatches`: one box per accent, its
|
|
14
|
+
* name and its values (the appearance picker's preview).
|
|
15
|
+
*
|
|
16
|
+
* They read the theme from the nearest theme provider, so inside a
|
|
17
|
+
* `DatalayerThemeProvider` for another theme they show that theme's.
|
|
18
|
+
*/
|
|
19
|
+
import { useLayoutEffect, useRef, useState } from 'react';
|
|
20
|
+
import { Button, Link, Text, ToggleSwitch } from '@primer/react';
|
|
21
|
+
import { Box } from '../box/Box';
|
|
22
|
+
import { themeAccentNames, themeAccents, themeAccentVars, } from '../../theme/colors/themeAccents';
|
|
23
|
+
/** The theme's own accent first, then the six. */
|
|
24
|
+
export const themeAccentChoices = ['theme', ...themeAccentNames];
|
|
25
|
+
/** The custom properties that lay an accent over the theme; none for the theme's own. */
|
|
26
|
+
const accentStyle = (choice, mode) => choice === 'theme' ? undefined : themeAccentVars(choice, mode);
|
|
27
|
+
const accentLabel = (choice) => choice === 'theme' ? "the theme's own" : choice;
|
|
28
|
+
/** One accent over the theme: the stage, two bubbles, a link and the controls. */
|
|
29
|
+
export function ThemeAccentPanel({ choice, mode }) {
|
|
30
|
+
return (_jsxs(Box, { style: accentStyle(choice, mode), sx: {
|
|
31
|
+
background: 'var(--theme-stage-gradient)',
|
|
32
|
+
borderRadius: 'var(--theme-radius-frame)',
|
|
33
|
+
p: 3,
|
|
34
|
+
display: 'grid',
|
|
35
|
+
gap: 2,
|
|
36
|
+
}, children: [_jsx(Text, { sx: { fontWeight: 600, fontFamily: 'mono', fontSize: 1 }, children: accentLabel(choice) }), _jsxs(Box, { sx: {
|
|
37
|
+
bg: 'canvas.default',
|
|
38
|
+
borderRadius: 'var(--theme-radius-card)',
|
|
39
|
+
boxShadow: 'var(--theme-shadow)',
|
|
40
|
+
p: 3,
|
|
41
|
+
display: 'grid',
|
|
42
|
+
gap: 2,
|
|
43
|
+
}, children: [_jsx(Box, { sx: {
|
|
44
|
+
justifySelf: 'start',
|
|
45
|
+
bg: 'var(--theme-quiet)',
|
|
46
|
+
color: 'fg.default',
|
|
47
|
+
borderRadius: 'var(--theme-radius-bubble)',
|
|
48
|
+
px: 3,
|
|
49
|
+
py: 2,
|
|
50
|
+
}, children: "The agent's words, on the quiet tint." }), _jsx(Box, { sx: {
|
|
51
|
+
justifySelf: 'end',
|
|
52
|
+
bg: 'var(--theme-accent)',
|
|
53
|
+
color: 'var(--theme-accent-on)',
|
|
54
|
+
borderRadius: 'var(--theme-radius-bubble)',
|
|
55
|
+
px: 3,
|
|
56
|
+
py: 2,
|
|
57
|
+
}, children: "The person's, on the accent." }), _jsxs(Text, { children: ["A ", _jsx(Link, { href: "#theme-accents", children: "link" }), " in the accent's text."] }), _jsxs(Box, { sx: { display: 'flex', gap: 2, alignItems: 'center', flexWrap: 'wrap' }, children: [_jsx(Button, { variant: "primary", children: "Send" }), _jsx(Button, { children: "Later" }), _jsx(Text, { id: `theme-accents-ask-first-${choice}-${mode}`, sx: { fontSize: 1 }, children: "Ask first" }), _jsx(ToggleSwitch, { "aria-labelledby": `theme-accents-ask-first-${choice}-${mode}`, size: "small", defaultChecked: true })] })] })] }));
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* One accent as a swatch: its stage with the accent's fill on it, then its
|
|
61
|
+
* name, the accent's value and the value of its text. The theme's own values
|
|
62
|
+
* are read back from the page, the six from `themeAccents`.
|
|
63
|
+
*/
|
|
64
|
+
export function ThemeAccentSwatch({ choice, mode, height = 40 }) {
|
|
65
|
+
const ref = useRef(null);
|
|
66
|
+
const [read, setRead] = useState(null);
|
|
67
|
+
useLayoutEffect(() => {
|
|
68
|
+
if (choice !== 'theme') {
|
|
69
|
+
setRead(null);
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
// Once the theme's properties are on the page.
|
|
73
|
+
const frame = requestAnimationFrame(() => {
|
|
74
|
+
if (!ref.current) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const style = getComputedStyle(ref.current);
|
|
78
|
+
setRead({
|
|
79
|
+
accent: style.getPropertyValue('--theme-accent').trim(),
|
|
80
|
+
text: style.getPropertyValue('--fgColor-accent').trim(),
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
return () => cancelAnimationFrame(frame);
|
|
84
|
+
// A theme of its own is a provider above: key the swatch by it to read again.
|
|
85
|
+
}, [choice, mode]);
|
|
86
|
+
const values = choice === 'theme' ? read : { accent: themeAccents[choice].accent, text: themeAccents[choice].text[mode] };
|
|
87
|
+
return (_jsxs(Box, { ref: ref, style: accentStyle(choice, mode), "data-accent": choice, sx: {
|
|
88
|
+
display: 'grid',
|
|
89
|
+
gridTemplateRows: `${height}px auto`,
|
|
90
|
+
border: '1px solid',
|
|
91
|
+
borderColor: 'border.default',
|
|
92
|
+
borderRadius: 'var(--theme-radius-card)',
|
|
93
|
+
overflow: 'hidden',
|
|
94
|
+
minWidth: 0,
|
|
95
|
+
}, children: [_jsx(Box, { sx: {
|
|
96
|
+
background: 'var(--theme-stage-gradient)',
|
|
97
|
+
display: 'flex',
|
|
98
|
+
alignItems: 'center',
|
|
99
|
+
justifyContent: 'center',
|
|
100
|
+
}, children: _jsx(Box, { sx: {
|
|
101
|
+
bg: 'var(--theme-accent)',
|
|
102
|
+
color: 'var(--theme-accent-on)',
|
|
103
|
+
borderRadius: 'var(--theme-radius-bubble)',
|
|
104
|
+
px: 2,
|
|
105
|
+
fontSize: 0,
|
|
106
|
+
lineHeight: '20px',
|
|
107
|
+
fontWeight: 600,
|
|
108
|
+
}, children: "Aa" }) }), _jsxs(Box, { sx: { p: 2, display: 'grid', gap: 1, bg: 'canvas.default' }, children: [_jsx(Text, { sx: { fontSize: 0, color: 'fg.default', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }, title: accentLabel(choice), children: accentLabel(choice) }), values?.accent ? (_jsx(Text, { sx: { fontSize: 0, color: 'fg.muted', fontFamily: 'mono' }, children: values.accent })) : null, values?.text ? (_jsxs(Text, { sx: { fontSize: 0, color: 'var(--fgColor-accent)', fontFamily: 'mono' }, children: ["text ", values.text] })) : null] })] }));
|
|
109
|
+
}
|
|
110
|
+
/** The theme's own accent and the six, one swatch each, in a wrapping grid. */
|
|
111
|
+
export function ThemeAccentSwatches({ mode, minSwatchWidth = 104 }) {
|
|
112
|
+
return (_jsx(Box, { "data-testid": "theme-accent-swatches", sx: {
|
|
113
|
+
display: 'grid',
|
|
114
|
+
gridTemplateColumns: `repeat(auto-fill, minmax(${minSwatchWidth}px, 1fr))`,
|
|
115
|
+
gap: 2,
|
|
116
|
+
}, children: themeAccentChoices.map(choice => (_jsx(ThemeAccentSwatch, { choice: choice, mode: mode }, choice))) }));
|
|
117
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A theme's colours, as the appearance picker's preview shows them under
|
|
3
|
+
* its preview card: the colour palette (roles and hues) and the accents, in
|
|
4
|
+
* the theme and the colour mode previewed, whatever the page around wears.
|
|
5
|
+
*/
|
|
6
|
+
import type { ReactElement } from 'react';
|
|
7
|
+
import type { ColorMode } from '../../theme/DatalayerBrandThemeProvider';
|
|
8
|
+
import type { ThemeVariant } from '../../theme/themeTokens';
|
|
9
|
+
export interface ThemePalettePreviewProps {
|
|
10
|
+
variant: ThemeVariant;
|
|
11
|
+
colorMode: ColorMode;
|
|
12
|
+
}
|
|
13
|
+
export declare function ThemePalettePreview({ variant, colorMode }: ThemePalettePreviewProps): ReactElement;
|
|
14
|
+
export default ThemePalettePreview;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Text } from '@primer/react';
|
|
3
|
+
import { Box } from '../box/Box';
|
|
4
|
+
import { DatalayerThemeProvider } from '../../theme/DatalayerThemeProvider';
|
|
5
|
+
import { themeConfigs } from '../../theme/themeRegistry';
|
|
6
|
+
import { useSystemColorMode } from '../../theme/useSystemColorMode';
|
|
7
|
+
import { ThemePaletteSwatches } from './ThemePaletteSwatches';
|
|
8
|
+
import { ThemeAccentSwatches } from './ThemeAccents';
|
|
9
|
+
export function ThemePalettePreview({ variant, colorMode }) {
|
|
10
|
+
const cfg = themeConfigs[variant];
|
|
11
|
+
const systemMode = useSystemColorMode();
|
|
12
|
+
const mode = colorMode === 'auto' ? systemMode : colorMode === 'dark' ? 'dark' : 'light';
|
|
13
|
+
const heading = { m: 0, fontSize: 1, fontWeight: 600, color: 'fg.default' };
|
|
14
|
+
return (_jsx(DatalayerThemeProvider, { colorMode: mode, theme: cfg.primerTheme, themeStyles: cfg.themeStyles, children: _jsxs(Box, { "data-testid": "theme-palette-preview", "data-theme-variant": variant, "data-theme-mode": mode, sx: {
|
|
15
|
+
display: 'grid',
|
|
16
|
+
gap: 3,
|
|
17
|
+
p: 2,
|
|
18
|
+
bg: 'canvas.default',
|
|
19
|
+
border: '1px solid',
|
|
20
|
+
borderColor: 'border.default',
|
|
21
|
+
borderRadius: 'var(--theme-radius-card)',
|
|
22
|
+
}, children: [_jsxs(Box, { as: "section", sx: { display: 'grid', gap: 2 }, children: [_jsx(Text, { as: "h3", sx: heading, children: "Color palette" }), _jsx(ThemePaletteSwatches, { variant: variant, colorMode: mode, compact: true })] }), _jsxs(Box, { as: "section", sx: { display: 'grid', gap: 2 }, children: [_jsx(Text, { as: "h3", sx: heading, children: "Theme accents" }), _jsx(ThemeAccentSwatches, { mode: mode })] })] }, `${variant}-${mode}`) }));
|
|
23
|
+
}
|
|
24
|
+
export default ThemePalettePreview;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The colour palette of a theme as swatches: its roles (what the theme's own
|
|
3
|
+
* design uses) and its hues (the named colours a spec or a person picks),
|
|
4
|
+
* each swatch with its name and value. The gallery's "Color Palette" page
|
|
5
|
+
* draws its grids with these, and the appearance picker's preview shows them
|
|
6
|
+
* for the theme and mode it previews.
|
|
7
|
+
*/
|
|
8
|
+
import type { ReactElement } from 'react';
|
|
9
|
+
import { type ColorPalette, type PaletteColorName } from '../../theme/palettes';
|
|
10
|
+
import type { ThemeVariant } from '../../theme/themeTokens';
|
|
11
|
+
export interface PaletteSwatchGridProps {
|
|
12
|
+
/** The palette the values come from. */
|
|
13
|
+
palette: ColorPalette;
|
|
14
|
+
/** The names of the palette to draw, in order. */
|
|
15
|
+
names: readonly PaletteColorName[];
|
|
16
|
+
/** Height of each swatch's colour block. Default: the swatch's own. */
|
|
17
|
+
swatchHeight?: number;
|
|
18
|
+
/** The narrowest a swatch gets before the grid wraps to fewer columns. Default: 120px. */
|
|
19
|
+
minSwatchWidth?: number;
|
|
20
|
+
}
|
|
21
|
+
/** A wrapping grid of swatches, one per name of the palette. */
|
|
22
|
+
export declare function PaletteSwatchGrid({ palette, names, swatchHeight, minSwatchWidth, }: PaletteSwatchGridProps): ReactElement;
|
|
23
|
+
export interface ThemePaletteSwatchesProps {
|
|
24
|
+
/** The theme to draw. Default: the theme store's. */
|
|
25
|
+
variant?: ThemeVariant;
|
|
26
|
+
/** The colour mode to draw. Default: the theme store's. */
|
|
27
|
+
colorMode?: 'light' | 'dark' | 'auto';
|
|
28
|
+
/** Smaller swatches, for a settings page or a menu. */
|
|
29
|
+
compact?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** A theme's palette: a heading and a grid for its roles, then for its hues. */
|
|
32
|
+
export declare function ThemePaletteSwatches({ variant, colorMode, compact, }: ThemePaletteSwatchesProps): ReactElement;
|
|
33
|
+
export default ThemePaletteSwatches;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Text } from '@primer/react';
|
|
3
|
+
import { Box } from '../box/Box';
|
|
4
|
+
import { ColorSwatch } from '../color/ColorSwatch';
|
|
5
|
+
import { getColorPalette, paletteRoleNames, } from '../../theme/palettes';
|
|
6
|
+
import { hueNames } from '../../theme/colors/hueColors';
|
|
7
|
+
import { useThemeStore } from '../../theme/useThemeStore';
|
|
8
|
+
/** A wrapping grid of swatches, one per name of the palette. */
|
|
9
|
+
export function PaletteSwatchGrid({ palette, names, swatchHeight, minSwatchWidth = 120, }) {
|
|
10
|
+
return (_jsx(Box, { sx: {
|
|
11
|
+
display: 'grid',
|
|
12
|
+
gridTemplateColumns: `repeat(auto-fill, minmax(${minSwatchWidth}px, 1fr))`,
|
|
13
|
+
gap: 2,
|
|
14
|
+
}, children: names.map(name => (_jsx(ColorSwatch, { color: palette[name], label: name, height: swatchHeight }, name))) }));
|
|
15
|
+
}
|
|
16
|
+
/** A theme's palette: a heading and a grid for its roles, then for its hues. */
|
|
17
|
+
export function ThemePaletteSwatches({ variant, colorMode, compact = false, }) {
|
|
18
|
+
const store = useThemeStore();
|
|
19
|
+
const palette = getColorPalette(variant ?? store.theme, colorMode ?? store.colorMode);
|
|
20
|
+
const swatchHeight = compact ? 32 : undefined;
|
|
21
|
+
const minSwatchWidth = compact ? 104 : 120;
|
|
22
|
+
const groups = [
|
|
23
|
+
{ title: 'Roles', names: paletteRoleNames },
|
|
24
|
+
{ title: 'Hues', names: hueNames },
|
|
25
|
+
];
|
|
26
|
+
return (_jsx(Box, { sx: { display: 'grid', gap: compact ? 2 : 3 }, "data-testid": "theme-palette-swatches", children: groups.map(group => (_jsxs(Box, { sx: { display: 'grid', gap: compact ? 1 : 2 }, children: [_jsx(Text, { as: "h4", sx: { m: 0, fontSize: compact ? 0 : 1, fontWeight: 600 }, children: group.title }), _jsx(PaletteSwatchGrid, { palette: palette, names: group.names, swatchHeight: swatchHeight, minSwatchWidth: minSwatchWidth })] }, group.title))) }));
|
|
27
|
+
}
|
|
28
|
+
export default ThemePaletteSwatches;
|
|
@@ -5,4 +5,7 @@ export * from './AppearanceMenuWithStore';
|
|
|
5
5
|
export * from './CollaboratorPalette';
|
|
6
6
|
export * from './ColorModeCircle';
|
|
7
7
|
export * from './ThemePreviewCard';
|
|
8
|
+
export * from './ThemePalettePreview';
|
|
9
|
+
export * from './ThemePaletteSwatches';
|
|
10
|
+
export * from './ThemeAccents';
|
|
8
11
|
export * from './ThemeCircle';
|
|
@@ -9,4 +9,7 @@ export * from './AppearanceMenuWithStore';
|
|
|
9
9
|
export * from './CollaboratorPalette';
|
|
10
10
|
export * from './ColorModeCircle';
|
|
11
11
|
export * from './ThemePreviewCard';
|
|
12
|
+
export * from './ThemePalettePreview';
|
|
13
|
+
export * from './ThemePaletteSwatches';
|
|
14
|
+
export * from './ThemeAccents';
|
|
12
15
|
export * from './ThemeCircle';
|
|
@@ -39,6 +39,11 @@
|
|
|
39
39
|
* the light still change.
|
|
40
40
|
* - `Card.Icon` — a glyph in a tinted, rounded square: the icon the lift
|
|
41
41
|
* moves.
|
|
42
|
+
* - `surface` — the card is a gradient with white text on it, its slots
|
|
43
|
+
* included: `sage`, `steel`, `mauve` or `clay`. The `metal` theme sets the
|
|
44
|
+
* four; another theme draws them from its success, accent, done and severe
|
|
45
|
+
* colours, deepened, so they differ there too. `Card.Glass` is a frosted
|
|
46
|
+
* panel for such a card.
|
|
42
47
|
*/
|
|
43
48
|
import React from "react";
|
|
44
49
|
import { type BoxColorToken, type BoxProps, type BoxPseudoProps, type BoxRadiusToken, type BoxStyleProps } from "../box/Box";
|
|
@@ -67,6 +72,8 @@ type CardBoxProps = Omit<BoxStyleProps, 'border'> & BoxPseudoProps & Omit<React.
|
|
|
67
72
|
* tone's wash with the tone's muted hairline.
|
|
68
73
|
*/
|
|
69
74
|
export type CardVariant = 'default' | 'subtle' | 'inset' | 'accent' | 'success' | 'attention' | 'danger';
|
|
75
|
+
/** The gradient a card is made of; see {@link CardProps.surface}. */
|
|
76
|
+
export type CardSurface = 'sage' | 'steel' | 'mauve' | 'clay';
|
|
70
77
|
export type CardProps = CardBoxProps & {
|
|
71
78
|
/**
|
|
72
79
|
* The corner: a radius by name — Primer's (`small`, `medium`, `large`,
|
|
@@ -77,6 +84,11 @@ export type CardProps = CardBoxProps & {
|
|
|
77
84
|
rounded?: BoxRadiusToken | number;
|
|
78
85
|
/** The card's flavour, `default` by default; see {@link CardVariant}. */
|
|
79
86
|
variant?: CardVariant;
|
|
87
|
+
/**
|
|
88
|
+
* The card as a gradient, with white text on it and no hairline; it lies
|
|
89
|
+
* flat unless `shadow` says otherwise. Over `variant`. See {@link CardSurface}.
|
|
90
|
+
*/
|
|
91
|
+
surface?: CardSurface;
|
|
80
92
|
/** A hairline around the card, `border.default`. */
|
|
81
93
|
border?: boolean;
|
|
82
94
|
/** Primer's shadows by name; `none` for a card that lies flat. `small` by default. */
|
|
@@ -168,6 +180,7 @@ export type CardCoverProps = CardBoxProps & {
|
|
|
168
180
|
/** A glyph centred on the cover, drawn in `fg.onEmphasis`. */
|
|
169
181
|
children?: React.ReactNode;
|
|
170
182
|
};
|
|
183
|
+
export type CardGlassProps = CardBoxProps;
|
|
171
184
|
export type CardActionsProps = {
|
|
172
185
|
children: React.ReactNode;
|
|
173
186
|
};
|
|
@@ -186,5 +199,6 @@ export declare const Card: React.FC<CardProps> & {
|
|
|
186
199
|
Footer: React.FC<CardFooterProps>;
|
|
187
200
|
Actions: React.FC<CardActionsProps>;
|
|
188
201
|
Icon: React.FC<CardIconProps>;
|
|
202
|
+
Glass: React.FC<CardGlassProps>;
|
|
189
203
|
};
|
|
190
204
|
export {};
|
|
@@ -10,6 +10,25 @@ const VARIANTS = {
|
|
|
10
10
|
attention: { bg: 'attention.subtle', borderColor: 'attention.muted' },
|
|
11
11
|
danger: { bg: 'danger.subtle', borderColor: 'danger.muted' },
|
|
12
12
|
};
|
|
13
|
+
/** Where a theme with no gradients of its own takes each surface's colour: every theme sets these. */
|
|
14
|
+
const SURFACE_FALLBACKS = {
|
|
15
|
+
sage: '--bgColor-success-emphasis',
|
|
16
|
+
steel: '--bgColor-accent-emphasis',
|
|
17
|
+
mauve: '--bgColor-done-emphasis',
|
|
18
|
+
clay: '--bgColor-severe-emphasis',
|
|
19
|
+
};
|
|
20
|
+
/** The colour, deepened: white text has to read on it, a pastel accent included. */
|
|
21
|
+
const fallbackGradient = (surface) => {
|
|
22
|
+
const color = `var(${SURFACE_FALLBACKS[surface]})`;
|
|
23
|
+
return `linear-gradient(160deg, color-mix(in srgb, ${color} 82%, black), color-mix(in srgb, ${color} 58%, black))`;
|
|
24
|
+
};
|
|
25
|
+
const surfaceStyle = (surface) => ({
|
|
26
|
+
backgroundImage: `var(--metal-gradient-${surface}, ${fallbackGradient(surface)})`,
|
|
27
|
+
color: '#FFFFFF',
|
|
28
|
+
// What the slots read: their text is white on the gradient in either mode.
|
|
29
|
+
'--fgColor-default': '#FFFFFF',
|
|
30
|
+
'--fgColor-muted': 'rgba(255, 255, 255, 0.85)',
|
|
31
|
+
});
|
|
13
32
|
/**
|
|
14
33
|
* The corners, read from the theme: each theme sets Primer's radii (loop's
|
|
15
34
|
* are rounder), and a card left unsaid takes the theme's card corner.
|
|
@@ -88,7 +107,7 @@ const DISABLED = {
|
|
|
88
107
|
hover: {},
|
|
89
108
|
};
|
|
90
109
|
export const Card = (props) => {
|
|
91
|
-
const { rounded, border, shadow
|
|
110
|
+
const { rounded, border, shadow, variant = 'default', surface, interactive, selected, dashed, disabled, accent, hoverEffect, sx, style, children, ...otherProps } = props;
|
|
92
111
|
const lift = hoverEffect === 'lift' && !disabled;
|
|
93
112
|
const outlined = border || interactive || selected || dashed || lift;
|
|
94
113
|
const flavour = VARIANTS[variant];
|
|
@@ -101,10 +120,10 @@ export const Card = (props) => {
|
|
|
101
120
|
, {
|
|
102
121
|
// A column, so the actions stand at the bottom however long the text
|
|
103
122
|
// above them: cards side by side end on one line.
|
|
104
|
-
display: "flex", flexDirection: "column", bg: selected ? 'accent.subtle' : flavour.bg, color: "fg.default", borderRadius: rounded ?? CARD_RADIUS, boxShadow: SHADOWS[shadow], ...(outlined ? {
|
|
123
|
+
display: "flex", flexDirection: "column", ...(surface ? undefined : { bg: selected ? 'accent.subtle' : flavour.bg }), color: "fg.default", borderRadius: rounded ?? CARD_RADIUS, boxShadow: SHADOWS[shadow ?? (surface ? 'none' : 'small')], ...(outlined ? {
|
|
105
124
|
border: '1px solid',
|
|
106
125
|
borderColor: selected ? 'accent.emphasis' : flavour.borderColor,
|
|
107
|
-
} : undefined), ...(dashed ? { borderStyle: 'dashed' } : undefined), ...(accent ? { borderTop: '3px solid', borderTopColor: accent } : undefined), ...(interactive ? INTERACTIVE : undefined), ...(disabled ? DISABLED : undefined), ...(interactive && disabled ? { 'aria-disabled': true } : undefined), ...(lift ? { position: 'relative', overflow: 'hidden' } : undefined), ...otherProps, sx: mergedSx, children: children }));
|
|
126
|
+
} : undefined), ...(dashed ? { borderStyle: 'dashed' } : undefined), ...(accent ? { borderTop: '3px solid', borderTopColor: accent } : undefined), ...(interactive ? INTERACTIVE : undefined), ...(disabled ? DISABLED : undefined), ...(interactive && disabled ? { 'aria-disabled': true } : undefined), ...(lift ? { position: 'relative', overflow: 'hidden' } : undefined), ...otherProps, style: surface ? { ...surfaceStyle(surface), ...style } : style, sx: mergedSx, children: children }));
|
|
108
127
|
};
|
|
109
128
|
Card.Header = (props) => {
|
|
110
129
|
const { title, description, leadingVisual, action } = props;
|
|
@@ -127,6 +146,13 @@ Card.Footer = ({ children, ...rest }) => {
|
|
|
127
146
|
Card.Icon = ({ icon: Icon, color = 'accent.fg', bg = 'accent.subtle', size = 46, ...rest }) => {
|
|
128
147
|
return (_jsx(Box, { [CARD_ICON_ATTRIBUTE]: '', display: "inline-flex", alignItems: "center", justifyContent: "center", flexShrink: 0, width: size, height: size, borderRadius: `${Math.round(size * 13 / 46)}px`, color: color, bg: bg, mb: 3, boxShadow: "inset 0 0 0 1px currentColor", transition: `transform 320ms ${CARD_EASE}`, ...rest, children: _jsx(Icon, { size: Math.round(size * 22 / 46), fill: "currentColor" }) }));
|
|
129
148
|
};
|
|
149
|
+
Card.Glass = ({ children, style, ...rest }) => {
|
|
150
|
+
return (_jsx(Box, { p: 3, border: "1px solid", borderRadius: "bubble", ...rest, style: {
|
|
151
|
+
background: 'var(--metal-glass-bg, rgba(255, 255, 255, 0.16))',
|
|
152
|
+
borderColor: 'var(--metal-glass-border, rgba(255, 255, 255, 0.28))',
|
|
153
|
+
...style,
|
|
154
|
+
}, children: children }));
|
|
155
|
+
};
|
|
130
156
|
Card.Actions = ({ children }) => {
|
|
131
157
|
return _jsx(Box, { display: "block", p: 3, mt: "auto", children: children });
|
|
132
158
|
};
|
|
@@ -10,6 +10,7 @@ declare const meta: {
|
|
|
10
10
|
Footer: React.FC<import("./Card").CardFooterProps>;
|
|
11
11
|
Actions: React.FC<import("./Card").CardActionsProps>;
|
|
12
12
|
Icon: React.FC<import("./Card").CardIconProps>;
|
|
13
|
+
Glass: React.FC<import("./Card").CardGlassProps>;
|
|
13
14
|
};
|
|
14
15
|
tags: string[];
|
|
15
16
|
parameters: {
|
|
@@ -32,3 +33,4 @@ export declare const CardSelected: Story;
|
|
|
32
33
|
* `prefers-reduced-motion: reduce`.
|
|
33
34
|
*/
|
|
34
35
|
export declare const CardLift: Story;
|
|
36
|
+
export declare const CardSurfaces: Story;
|
|
@@ -91,3 +91,6 @@ export const CardLift = {
|
|
|
91
91
|
},
|
|
92
92
|
render: (args) => _jsxs(ThemedCard, { ...args, children: [_jsx(Card.Icon, { icon: GlobeIcon, color: "done.fg", bg: "done.subtle" }), _jsx(Text, { display: "block", fontWeight: "bold", children: "Satellite sources" }), _jsx(Text, { color: "fg.muted", children: "Sentinel, Landsat and commercial constellations, read where they are." })] })
|
|
93
93
|
};
|
|
94
|
+
export const CardSurfaces = {
|
|
95
|
+
render: () => (_jsx("div", { style: { display: 'grid', gap: 16, gridTemplateColumns: 'repeat(2, 240px)' }, children: ['sage', 'steel', 'mauve', 'clay'].map(surface => (_jsxs(Card, { surface: surface, p: 3, gap: 3, children: [surface, _jsx(Card.Glass, { children: "Glass on the gradient." })] }, surface))) })),
|
|
96
|
+
};
|
|
@@ -4,7 +4,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
4
4
|
* Distributed under the terms of the Modified BSD License.
|
|
5
5
|
*/
|
|
6
6
|
import { forwardRef, useId } from 'react';
|
|
7
|
-
import { datalayerColors, spatialColors, lovelyColors, matrixColors, earthColors, sandColors, ivoryColors, sunColors, loopColors, vscodeColors, } from '../../theme';
|
|
7
|
+
import { datalayerColors, spatialColors, lovelyColors, matrixColors, earthColors, sandColors, ivoryColors, sunColors, loopColors, metalColors, vscodeColors, } from '../../theme';
|
|
8
8
|
/**
|
|
9
9
|
* Gradient pattern derived from the original brand logo SVG:
|
|
10
10
|
* - Left bars: accent → brand (bright → mid)
|
|
@@ -158,6 +158,22 @@ export const THEME_LOGO_COLORS = {
|
|
|
158
158
|
secondaryGradient: [loopColors.inkDark, loopColors.inkDark],
|
|
159
159
|
},
|
|
160
160
|
},
|
|
161
|
+
metal: {
|
|
162
|
+
light: {
|
|
163
|
+
primary: metalColors.steelFrom,
|
|
164
|
+
secondary: metalColors.ink,
|
|
165
|
+
textColor: metalColors.gray,
|
|
166
|
+
primaryGradient: [metalColors.steelFrom, metalColors.steelTo],
|
|
167
|
+
secondaryGradient: [metalColors.ink, metalColors.ink],
|
|
168
|
+
},
|
|
169
|
+
dark: {
|
|
170
|
+
primary: metalColors.metalBright,
|
|
171
|
+
secondary: metalColors.inkDark,
|
|
172
|
+
textColor: metalColors.grayDark,
|
|
173
|
+
primaryGradient: [metalColors.metalBright, metalColors.brightPop],
|
|
174
|
+
secondaryGradient: [metalColors.inkDark, metalColors.inkDark],
|
|
175
|
+
},
|
|
176
|
+
},
|
|
161
177
|
vscode: {
|
|
162
178
|
// The editor's blue, flat: VS Code draws no gradient.
|
|
163
179
|
light: {
|
|
@@ -26,6 +26,8 @@ export type AppearancePluginConfig = {
|
|
|
26
26
|
* as in the public header: a person who chose dark keeps dark.
|
|
27
27
|
*/
|
|
28
28
|
applyThemeColorMode: boolean;
|
|
29
|
+
/** The most theme swatches on one line of the overlay. */
|
|
30
|
+
themesPerLine: number;
|
|
29
31
|
};
|
|
30
32
|
export declare const AppearancePlugin: import("@datalayer/reactor").ReactorPlugin<AppearancePluginConfig, unknown, ReactorReactOutput>;
|
|
31
33
|
export default AppearancePlugin;
|
|
@@ -42,6 +42,7 @@ export const AppearancePlugin = definePlugin({
|
|
|
42
42
|
placement: "bottom-end",
|
|
43
43
|
showThemePreviews: true,
|
|
44
44
|
applyThemeColorMode: false,
|
|
45
|
+
themesPerLine: 6,
|
|
45
46
|
},
|
|
46
47
|
build: ({ config }) => ({
|
|
47
48
|
components: [
|
|
@@ -55,6 +56,7 @@ export const AppearancePlugin = definePlugin({
|
|
|
55
56
|
hoverOverlayPlacement: config.placement,
|
|
56
57
|
showThemePreviews: config.showThemePreviews,
|
|
57
58
|
applyThemeColorMode: config.applyThemeColorMode,
|
|
59
|
+
themesPerLine: config.themesPerLine,
|
|
58
60
|
}),
|
|
59
61
|
},
|
|
60
62
|
],
|
|
@@ -7,6 +7,7 @@ export { sandColors } from './sandColors';
|
|
|
7
7
|
export { ivoryColors } from './ivoryColors';
|
|
8
8
|
export { sunColors } from './sunColors';
|
|
9
9
|
export { loopColors } from './loopColors';
|
|
10
|
+
export { metalColors } from './metalColors';
|
|
10
11
|
export { vscodeColors, vscodeVars, vscodeVar, vscodeTint, vscodeFontFamily, vscodeMonoFontFamily, vscodeFontSize, type VSCodeColor, type VSCodeVarName, } from './vscodeColors';
|
|
11
12
|
export { themeAccents, themeAccentNames, themeAccentVars, themeAccentTints, themeStageGradient, themeTintVars, type ThemeAccent, type ThemeAccentName, } from './themeAccents';
|
|
12
13
|
export { hueNames, baseHueColors, hueColorsOf, type HueName, type HueColor, } from './hueColors';
|
|
@@ -11,6 +11,7 @@ export { sandColors } from './sandColors';
|
|
|
11
11
|
export { ivoryColors } from './ivoryColors';
|
|
12
12
|
export { sunColors } from './sunColors';
|
|
13
13
|
export { loopColors } from './loopColors';
|
|
14
|
+
export { metalColors } from './metalColors';
|
|
14
15
|
export { vscodeColors, vscodeVars, vscodeVar, vscodeTint, vscodeFontFamily, vscodeMonoFontFamily, vscodeFontSize, } from './vscodeColors';
|
|
15
16
|
export { themeAccents, themeAccentNames, themeAccentVars, themeAccentTints, themeStageGradient, themeTintVars, } from './themeAccents';
|
|
16
17
|
export { hueNames, baseHueColors, hueColorsOf, } from './hueColors';
|
|
@@ -23,6 +24,7 @@ import { sandColors } from './sandColors';
|
|
|
23
24
|
import { ivoryColors } from './ivoryColors';
|
|
24
25
|
import { sunColors } from './sunColors';
|
|
25
26
|
import { loopColors } from './loopColors';
|
|
27
|
+
import { metalColors } from './metalColors';
|
|
26
28
|
import { vscodeColors } from './vscodeColors';
|
|
27
29
|
/**
|
|
28
30
|
* Themed color palettes — maps each `ThemeVariant` to its corresponding
|
|
@@ -44,5 +46,6 @@ export const themedColors = {
|
|
|
44
46
|
ivory: ivoryColors,
|
|
45
47
|
sun: sunColors,
|
|
46
48
|
loop: loopColors,
|
|
49
|
+
metal: metalColors,
|
|
47
50
|
vscode: vscodeColors,
|
|
48
51
|
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export declare const metalColors: {
|
|
2
|
+
black: string;
|
|
3
|
+
gray: string;
|
|
4
|
+
ink: string;
|
|
5
|
+
inkDark: string;
|
|
6
|
+
subtle: string;
|
|
7
|
+
subtleDark: string;
|
|
8
|
+
grayDark: string;
|
|
9
|
+
metalBrand: string;
|
|
10
|
+
metalOn: string;
|
|
11
|
+
metalHover: string;
|
|
12
|
+
metalActive: string;
|
|
13
|
+
metalText: string;
|
|
14
|
+
metalRing: string;
|
|
15
|
+
metalTint: string;
|
|
16
|
+
metalStage: string;
|
|
17
|
+
metalTintLine: string;
|
|
18
|
+
metalBright: string;
|
|
19
|
+
metalBrightHover: string;
|
|
20
|
+
metalOnDark: string;
|
|
21
|
+
metalStageDark: string;
|
|
22
|
+
metalTintDark: string;
|
|
23
|
+
line: string;
|
|
24
|
+
lineMuted: string;
|
|
25
|
+
controlLine: string;
|
|
26
|
+
lineDark: string;
|
|
27
|
+
lineMutedDark: string;
|
|
28
|
+
sageFrom: string;
|
|
29
|
+
sageTo: string;
|
|
30
|
+
steelFrom: string;
|
|
31
|
+
steelTo: string;
|
|
32
|
+
mauveFrom: string;
|
|
33
|
+
mauveTo: string;
|
|
34
|
+
clayFrom: string;
|
|
35
|
+
clayTo: string;
|
|
36
|
+
brightGlow: string;
|
|
37
|
+
brightPop: string;
|
|
38
|
+
brightSpark: string;
|
|
39
|
+
brightBlaze: string;
|
|
40
|
+
brightSurge: string;
|
|
41
|
+
brightFlame: string;
|
|
42
|
+
brightGold: string;
|
|
43
|
+
brightLightGlow: string;
|
|
44
|
+
brightLightPop: string;
|
|
45
|
+
brightLightSpark: string;
|
|
46
|
+
brightLightBlaze: string;
|
|
47
|
+
brightLightSurge: string;
|
|
48
|
+
brightLightFlame: string;
|
|
49
|
+
brightLightGold: string;
|
|
50
|
+
white: string;
|
|
51
|
+
loopBrand: string;
|
|
52
|
+
loopOn: string;
|
|
53
|
+
loopAccent: string;
|
|
54
|
+
loopBrandHover: string;
|
|
55
|
+
loopText: string;
|
|
56
|
+
loopRing: string;
|
|
57
|
+
loopTint: string;
|
|
58
|
+
loopStage: string;
|
|
59
|
+
loopBright: string;
|
|
60
|
+
loopHover: string;
|
|
61
|
+
loopStageDark: string;
|
|
62
|
+
loopTintDark: string;
|
|
63
|
+
successBrand: string;
|
|
64
|
+
successAccent: string;
|
|
65
|
+
successTint: string;
|
|
66
|
+
attentionBrand: string;
|
|
67
|
+
attentionAccent: string;
|
|
68
|
+
attentionTint: string;
|
|
69
|
+
dangerBrand: string;
|
|
70
|
+
dangerAccent: string;
|
|
71
|
+
dangerTint: string;
|
|
72
|
+
severeBrand: string;
|
|
73
|
+
severeAccent: string;
|
|
74
|
+
severeTint: string;
|
|
75
|
+
doneBrand: string;
|
|
76
|
+
doneAccent: string;
|
|
77
|
+
doneTint: string;
|
|
78
|
+
};
|