@datalayer/primer-addons 1.0.43 → 1.0.45
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.d.ts +9 -3
- package/lib/components/appearance/AppearanceControls.js +101 -87
- package/lib/components/appearance/AppearanceControls.stories.d.ts +7 -0
- package/lib/components/appearance/AppearanceControls.stories.js +3 -0
- package/lib/components/appearance/AppearanceMenu.d.ts +5 -2
- package/lib/components/appearance/AppearanceMenu.js +2 -2
- package/lib/components/appearance/AppearanceMenu.stories.d.ts +7 -0
- package/lib/components/appearance/AppearanceMenu.stories.js +4 -1
- package/lib/components/appearance/ColorModeCircle.d.ts +2 -1
- package/lib/components/appearance/ColorModeCircle.js +6 -4
- package/lib/components/appearance/ColorModeCircle.stories.js +1 -1
- package/lib/theme/themeRegistry.js +8 -2
- package/lib/theme/themeTokens.js +2 -2
- package/lib/theme/themes/vscodeTheme.d.ts +8 -0
- package/lib/theme/themes/vscodeTheme.js +9 -0
- package/lib/theme/themes/vscodeThemeStyles.d.ts +6 -4
- package/lib/theme/themes/vscodeThemeStyles.js +11 -9
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type ReactElement } from
|
|
2
|
-
import { type ColorMode, type ThemeVariant } from
|
|
1
|
+
import { type ReactElement } from "react";
|
|
2
|
+
import { type ColorMode, type ThemeVariant } from "../../theme";
|
|
3
3
|
export interface AppearanceControlsProps {
|
|
4
4
|
colorMode: ColorMode;
|
|
5
5
|
themeVariant: ThemeVariant;
|
|
@@ -11,6 +11,12 @@ export interface AppearanceControlsProps {
|
|
|
11
11
|
showThemeChooser?: boolean;
|
|
12
12
|
/** With the chooser, the chosen theme's name, description and preview under its swatches. Default: swatches only. */
|
|
13
13
|
showThemePreviews?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* The most theme swatches on one line; every line is centred, so a shorter
|
|
16
|
+
* last line sits in the middle under the full ones. Undefined, they wrap
|
|
17
|
+
* freely to the width given, as before.
|
|
18
|
+
*/
|
|
19
|
+
themesPerLine?: number;
|
|
14
20
|
}
|
|
15
|
-
export declare function AppearanceControls({ colorMode, themeVariant, onColorModeChange, onThemeChange, showColorMode, showThemeChooser, showThemePreviews, }: AppearanceControlsProps): ReactElement;
|
|
21
|
+
export declare function AppearanceControls({ colorMode, themeVariant, onColorModeChange, onThemeChange, showColorMode, showThemeChooser, showThemePreviews, themesPerLine, }: AppearanceControlsProps): ReactElement;
|
|
16
22
|
export default AppearanceControls;
|
|
@@ -3,117 +3,131 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
3
3
|
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
4
4
|
* Distributed under the terms of the Modified BSD License.
|
|
5
5
|
*/
|
|
6
|
-
import { useState } from
|
|
7
|
-
import { SegmentedControl, Tooltip } from
|
|
8
|
-
import { MoonIcon, SunIcon, DeviceDesktopIcon
|
|
9
|
-
import { Box } from
|
|
10
|
-
import { themeVariants, themeConfigs, } from
|
|
11
|
-
import { ThemePreviewCard } from
|
|
12
|
-
export function AppearanceControls({ colorMode, themeVariant, onColorModeChange, onThemeChange, showColorMode = true, showThemeChooser = true, showThemePreviews = false, }) {
|
|
6
|
+
import { useState } from "react";
|
|
7
|
+
import { SegmentedControl, Tooltip } from "@primer/react";
|
|
8
|
+
import { MoonIcon, SunIcon, DeviceDesktopIcon } from "@primer/octicons-react";
|
|
9
|
+
import { Box } from "../box/Box";
|
|
10
|
+
import { themeVariants, themeConfigs, } from "../../theme";
|
|
11
|
+
import { ThemePreviewCard } from "./ThemePreviewCard";
|
|
12
|
+
export function AppearanceControls({ colorMode, themeVariant, onColorModeChange, onThemeChange, showColorMode = true, showThemeChooser = true, showThemePreviews = false, themesPerLine, }) {
|
|
13
|
+
// At most `themesPerLine` swatches on a line when given, each line centred,
|
|
14
|
+
// so a shorter last line sits in the middle under the full ones; one line
|
|
15
|
+
// wrapping freely otherwise. Explicit lines rather than a width: the
|
|
16
|
+
// tooltips' hidden siblings take gaps of their own.
|
|
17
|
+
const swatchLines = themesPerLine !== undefined && themesPerLine > 0
|
|
18
|
+
? Array.from({ length: Math.ceil(themeVariants.length / themesPerLine) }, (_, line) => themeVariants.slice(line * themesPerLine, (line + 1) * themesPerLine))
|
|
19
|
+
: [[...themeVariants]];
|
|
20
|
+
const swatchRow = { display: "grid", rowGap: 2 };
|
|
21
|
+
const swatchLine = {
|
|
22
|
+
display: "flex",
|
|
23
|
+
justifyContent: "center",
|
|
24
|
+
flexWrap: "wrap",
|
|
25
|
+
gap: 2,
|
|
26
|
+
};
|
|
13
27
|
const [isPreviewOpen, setIsPreviewOpen] = useState(false);
|
|
14
28
|
const selectedTheme = themeConfigs[themeVariant];
|
|
15
|
-
return (_jsxs(_Fragment, { children: [showColorMode ? (_jsx(Box, { sx: { px: 2, py: 2, display:
|
|
16
|
-
const modes = [
|
|
29
|
+
return (_jsxs(_Fragment, { children: [showColorMode ? (_jsx(Box, { sx: { px: 2, py: 2, display: "flex", justifyContent: "center" }, children: _jsxs(SegmentedControl, { "aria-label": "Color mode", size: "small", onChange: (index) => {
|
|
30
|
+
const modes = ["light", "dark", "auto"];
|
|
17
31
|
onColorModeChange(modes[index]);
|
|
18
|
-
}, children: [_jsx(SegmentedControl.IconButton, { selected: colorMode ===
|
|
32
|
+
}, children: [_jsx(SegmentedControl.IconButton, { selected: colorMode === "light", icon: SunIcon, "aria-label": "Light" }), _jsx(SegmentedControl.IconButton, { selected: colorMode === "dark", icon: MoonIcon, "aria-label": "Dark" }), _jsx(SegmentedControl.IconButton, { selected: colorMode === "auto", icon: DeviceDesktopIcon, "aria-label": "Auto" })] }) })) : null, !showThemeChooser ? null : showThemePreviews ? (_jsxs(Box, { sx: {
|
|
19
33
|
px: 2,
|
|
20
34
|
// First in the controls when the colour mode is hidden.
|
|
21
35
|
pt: showColorMode ? 0 : 2,
|
|
22
36
|
pb: 2,
|
|
23
|
-
display:
|
|
37
|
+
display: "grid",
|
|
24
38
|
gap: 2,
|
|
25
39
|
}, children: [_jsx(Box, { sx: {
|
|
26
|
-
|
|
27
|
-
justifyContent: 'center',
|
|
40
|
+
...swatchRow,
|
|
28
41
|
gap: 2,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
42
|
+
}, children: swatchLines.map((line) => (_jsx(Box, { sx: swatchLine, children: line.map((variant) => {
|
|
43
|
+
const cfg = themeConfigs[variant];
|
|
44
|
+
const isSelected = themeVariant === variant;
|
|
45
|
+
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: {
|
|
46
|
+
width: 24,
|
|
47
|
+
height: 24,
|
|
48
|
+
flexShrink: 0,
|
|
49
|
+
borderRadius: "50%",
|
|
50
|
+
backgroundColor: cfg.brandColor,
|
|
51
|
+
border: "2px solid",
|
|
52
|
+
borderColor: isSelected
|
|
53
|
+
? "accent.fg"
|
|
54
|
+
: "border.default",
|
|
55
|
+
cursor: "pointer",
|
|
56
|
+
padding: 0,
|
|
57
|
+
outline: "none",
|
|
58
|
+
transition: "border-color 0.15s ease",
|
|
59
|
+
boxShadow: isSelected
|
|
60
|
+
? "0 0 0 2px var(--bgColor-accent-muted, rgba(9,105,218,0.3))"
|
|
61
|
+
: "none",
|
|
62
|
+
"&:hover": {
|
|
63
|
+
borderColor: "accent.fg",
|
|
64
|
+
},
|
|
65
|
+
"&:focus-visible": {
|
|
66
|
+
boxShadow: "0 0 0 2px var(--bgColor-accent-muted, rgba(9,105,218,0.3))",
|
|
67
|
+
},
|
|
68
|
+
} }) }, variant));
|
|
69
|
+
}) }, line.join()))) }), _jsxs(Box, { sx: {
|
|
56
70
|
px: 1,
|
|
57
|
-
display:
|
|
71
|
+
display: "grid",
|
|
58
72
|
gap: 1,
|
|
59
|
-
}, children: [_jsx(Box, { sx: { fontSize: 1, fontWeight:
|
|
73
|
+
}, children: [_jsx(Box, { sx: { fontSize: 1, fontWeight: "semibold", color: "fg.default" }, children: selectedTheme.label }), _jsx(Box, { sx: { fontSize: 0, color: "fg.muted", lineHeight: 1.5 }, children: selectedTheme.description }), _jsx(Box, { as: "button", type: "button", onClick: () => setIsPreviewOpen((open) => !open), "aria-expanded": isPreviewOpen, sx: {
|
|
60
74
|
mt: 1,
|
|
61
|
-
width:
|
|
75
|
+
width: "fit-content",
|
|
62
76
|
px: 2,
|
|
63
|
-
py:
|
|
77
|
+
py: "4px",
|
|
64
78
|
borderRadius: 2,
|
|
65
|
-
border:
|
|
66
|
-
borderColor:
|
|
67
|
-
bg:
|
|
68
|
-
color:
|
|
79
|
+
border: "1px solid",
|
|
80
|
+
borderColor: "border.default",
|
|
81
|
+
bg: "canvas.default",
|
|
82
|
+
color: "fg.default",
|
|
69
83
|
fontSize: 0,
|
|
70
|
-
fontWeight:
|
|
71
|
-
cursor:
|
|
72
|
-
|
|
73
|
-
borderColor:
|
|
74
|
-
color:
|
|
84
|
+
fontWeight: "semibold",
|
|
85
|
+
cursor: "pointer",
|
|
86
|
+
"&:hover": {
|
|
87
|
+
borderColor: "accent.fg",
|
|
88
|
+
color: "accent.fg",
|
|
75
89
|
},
|
|
76
|
-
|
|
77
|
-
outline:
|
|
78
|
-
outlineColor:
|
|
90
|
+
"&:focus-visible": {
|
|
91
|
+
outline: "2px solid",
|
|
92
|
+
outlineColor: "accent.fg",
|
|
79
93
|
outlineOffset: 1,
|
|
80
94
|
},
|
|
81
|
-
}, children: isPreviewOpen ?
|
|
95
|
+
}, children: isPreviewOpen ? "Hide preview" : "Show preview" })] }), isPreviewOpen ? (_jsx(ThemePreviewCard, { variant: themeVariant, colorMode: colorMode, selected: true, compact: true, showDescription: true })) : null] })) : (_jsx(Box, { sx: {
|
|
82
96
|
px: 2,
|
|
83
97
|
// First in the controls when the colour mode is hidden.
|
|
84
98
|
pt: showColorMode ? 0 : 2,
|
|
85
99
|
pb: 2,
|
|
86
|
-
display: 'flex',
|
|
87
|
-
justifyContent: 'center',
|
|
88
100
|
// Narrow, the swatches go on a second line rather than shrink.
|
|
89
|
-
|
|
101
|
+
...swatchRow,
|
|
90
102
|
gap: 2,
|
|
91
|
-
}, children:
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
:
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
103
|
+
}, children: swatchLines.map((line) => (_jsx(Box, { sx: swatchLine, children: line.map((variant) => {
|
|
104
|
+
const cfg = themeConfigs[variant];
|
|
105
|
+
const isSelected = themeVariant === variant;
|
|
106
|
+
return (_jsx(Tooltip, { text: cfg.label, direction: "s", children: _jsx(Box, { as: "button", "aria-label": cfg.label, "aria-pressed": isSelected, onClick: () => onThemeChange(variant), sx: {
|
|
107
|
+
width: 24,
|
|
108
|
+
height: 24,
|
|
109
|
+
// A circle at any width: never squeezed into an oval.
|
|
110
|
+
flexShrink: 0,
|
|
111
|
+
borderRadius: "50%",
|
|
112
|
+
backgroundColor: cfg.brandColor,
|
|
113
|
+
border: "2px solid",
|
|
114
|
+
borderColor: isSelected
|
|
115
|
+
? "accent.fg"
|
|
116
|
+
: "border.default",
|
|
117
|
+
cursor: "pointer",
|
|
118
|
+
padding: 0,
|
|
119
|
+
outline: "none",
|
|
120
|
+
transition: "border-color 0.15s ease",
|
|
121
|
+
boxShadow: isSelected
|
|
122
|
+
? "0 0 0 2px var(--bgColor-accent-muted, rgba(9,105,218,0.3))"
|
|
123
|
+
: "none",
|
|
124
|
+
"&:hover": {
|
|
125
|
+
borderColor: "accent.fg",
|
|
126
|
+
},
|
|
127
|
+
"&:focus-visible": {
|
|
128
|
+
boxShadow: "0 0 0 2px var(--bgColor-accent-muted, rgba(9,105,218,0.3))",
|
|
129
|
+
},
|
|
130
|
+
} }) }, variant));
|
|
131
|
+
}) }, line.join()))) }))] }));
|
|
118
132
|
}
|
|
119
133
|
export default AppearanceControls;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ReactElement } from 'react';
|
|
2
|
+
import { type HoverOverlayPlacement } from './ColorModeCircle';
|
|
2
3
|
import type { ColorMode, ThemeVariant } from '../../theme';
|
|
3
4
|
export interface AppearanceMenuProps {
|
|
4
5
|
/** Current color mode. */
|
|
@@ -14,9 +15,11 @@ export interface AppearanceMenuProps {
|
|
|
14
15
|
/** Visual shape of the trigger control. */
|
|
15
16
|
shape?: 'square' | 'circle';
|
|
16
17
|
/** Overlay placement relative to the circle. */
|
|
17
|
-
hoverOverlayPlacement?:
|
|
18
|
+
hoverOverlayPlacement?: HoverOverlayPlacement;
|
|
18
19
|
/** Whether the overlay shows the live theme previews. */
|
|
19
20
|
showThemePreviews?: boolean;
|
|
21
|
+
/** The most theme swatches on one line in the overlay; undefined, they wrap freely. */
|
|
22
|
+
themesPerLine?: number;
|
|
20
23
|
}
|
|
21
24
|
/**
|
|
22
25
|
* A single color-mode circle that reveals, on hover, an appearance overlay
|
|
@@ -26,5 +29,5 @@ export interface AppearanceMenuProps {
|
|
|
26
29
|
* {@link AppearanceControls} overlay so the whole appearance menu can be
|
|
27
30
|
* dropped into any header with a single component.
|
|
28
31
|
*/
|
|
29
|
-
export declare function AppearanceMenu({ colorMode, themeVariant, onColorModeChange, onThemeChange, size, shape, hoverOverlayPlacement, showThemePreviews, }: AppearanceMenuProps): ReactElement;
|
|
32
|
+
export declare function AppearanceMenu({ colorMode, themeVariant, onColorModeChange, onThemeChange, size, shape, hoverOverlayPlacement, showThemePreviews, themesPerLine, }: AppearanceMenuProps): ReactElement;
|
|
30
33
|
export default AppearanceMenu;
|
|
@@ -9,7 +9,7 @@ import { AppearanceControls } from './AppearanceControls';
|
|
|
9
9
|
* {@link AppearanceControls} overlay so the whole appearance menu can be
|
|
10
10
|
* dropped into any header with a single component.
|
|
11
11
|
*/
|
|
12
|
-
export function AppearanceMenu({ colorMode, themeVariant, onColorModeChange, onThemeChange, size = 26, shape = 'square', hoverOverlayPlacement = 'bottom-end', showThemePreviews = true, }) {
|
|
13
|
-
return (_jsx(ColorModeCircle, { colorMode: colorMode, onColorModeChange: onColorModeChange, cycleOnClick: false, themeVariant: themeVariant, hoverOverlayPlacement: hoverOverlayPlacement, shape: shape, size: size, hoverOverlay: _jsx(AppearanceControls, { colorMode: colorMode, themeVariant: themeVariant, onColorModeChange: onColorModeChange, onThemeChange: onThemeChange, showThemePreviews: showThemePreviews }) }));
|
|
12
|
+
export function AppearanceMenu({ colorMode, themeVariant, onColorModeChange, onThemeChange, size = 26, shape = 'square', hoverOverlayPlacement = 'bottom-end', showThemePreviews = true, themesPerLine, }) {
|
|
13
|
+
return (_jsx(ColorModeCircle, { colorMode: colorMode, onColorModeChange: onColorModeChange, cycleOnClick: false, themeVariant: themeVariant, hoverOverlayPlacement: hoverOverlayPlacement, shape: shape, size: size, hoverOverlay: _jsx(AppearanceControls, { colorMode: colorMode, themeVariant: themeVariant, onColorModeChange: onColorModeChange, onThemeChange: onThemeChange, showThemePreviews: showThemePreviews, themesPerLine: themesPerLine }) }));
|
|
14
14
|
}
|
|
15
15
|
export default AppearanceMenu;
|
|
@@ -14,6 +14,9 @@ const meta = {
|
|
|
14
14
|
layout: "fullscreen",
|
|
15
15
|
},
|
|
16
16
|
argTypes: {
|
|
17
|
+
themesPerLine: {
|
|
18
|
+
control: { type: "number", min: 1, max: 12 },
|
|
19
|
+
},
|
|
17
20
|
colorMode: {
|
|
18
21
|
options: ["light", "dark", "auto"],
|
|
19
22
|
control: "radio",
|
|
@@ -27,7 +30,7 @@ const meta = {
|
|
|
27
30
|
control: "radio",
|
|
28
31
|
},
|
|
29
32
|
hoverOverlayPlacement: {
|
|
30
|
-
options: ["bottom-start", "bottom-end"],
|
|
33
|
+
options: ["bottom-start", "bottom-end", "right-start"],
|
|
31
34
|
control: "radio",
|
|
32
35
|
},
|
|
33
36
|
},
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ReactElement, type ReactNode } from 'react';
|
|
2
2
|
import { type ColorMode, type ThemeVariant } from '../../theme';
|
|
3
|
-
|
|
3
|
+
/** Where the hover overlay opens: under the circle (aligned at its start or end), or to its right, aligned at its top. */
|
|
4
|
+
export type HoverOverlayPlacement = 'bottom-start' | 'bottom-end' | 'right-start';
|
|
4
5
|
type ColorModeCircleShape = 'square' | 'circle';
|
|
5
6
|
export interface ColorModeCircleProps {
|
|
6
7
|
/** Current color mode. */
|
|
@@ -39,6 +39,7 @@ export function ColorModeCircle({ colorMode, onColorModeChange, size = 28, hover
|
|
|
39
39
|
const [isHoverOpen, setIsHoverOpen] = useState(false);
|
|
40
40
|
const closeTimerRef = useRef(null);
|
|
41
41
|
const isBottomStart = hoverOverlayPlacement === 'bottom-start';
|
|
42
|
+
const isRight = hoverOverlayPlacement === 'right-start';
|
|
42
43
|
const themeConfig = themeVariant ? themeConfigs[themeVariant] : undefined;
|
|
43
44
|
const themeBorderColor = themeConfig?.brandColor;
|
|
44
45
|
const hasThemeColor = Boolean(themeBorderColor);
|
|
@@ -113,9 +114,10 @@ export function ColorModeCircle({ colorMode, onColorModeChange, size = 28, hover
|
|
|
113
114
|
}
|
|
114
115
|
return (_jsxs(Box, { sx: { position: 'relative', display: 'inline-flex', alignItems: 'center' }, onMouseEnter: openHoverOverlay, onMouseLeave: scheduleCloseHoverOverlay, children: [circle, _jsx(Box, { sx: {
|
|
115
116
|
position: 'absolute',
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
// To the right: beside the circle, its top level with the circle's.
|
|
118
|
+
top: isRight ? 0 : `calc(100% + 8px)`,
|
|
119
|
+
left: isRight ? `calc(100% + 8px)` : isBottomStart ? 0 : 'auto',
|
|
120
|
+
right: isRight || isBottomStart ? 'auto' : 0,
|
|
119
121
|
zIndex: 220,
|
|
120
122
|
minWidth: 340,
|
|
121
123
|
bg: 'canvas.overlay',
|
|
@@ -124,7 +126,7 @@ export function ColorModeCircle({ colorMode, onColorModeChange, size = 28, hover
|
|
|
124
126
|
borderRadius: 2,
|
|
125
127
|
boxShadow: 'shadow.large',
|
|
126
128
|
opacity: isHoverOpen ? 1 : 0,
|
|
127
|
-
transform: isHoverOpen ? '
|
|
129
|
+
transform: isHoverOpen ? 'none' : isRight ? 'translateX(-6px)' : 'translateY(-6px)',
|
|
128
130
|
pointerEvents: isHoverOpen ? 'auto' : 'none',
|
|
129
131
|
transition: 'opacity 0.16s ease, transform 0.16s ease',
|
|
130
132
|
}, children: hoverOverlay })] }));
|
|
@@ -17,7 +17,7 @@ import { sandTheme } from './themes/sandTheme';
|
|
|
17
17
|
import { ivoryTheme } from './themes/ivoryTheme';
|
|
18
18
|
import { sunTheme } from './themes/sunTheme';
|
|
19
19
|
import { loopTheme } from './themes/loopTheme';
|
|
20
|
-
import { vscodeTheme } from './themes/vscodeTheme';
|
|
20
|
+
import { vscodeTheme, vscodeThemeStyles } from './themes/vscodeTheme';
|
|
21
21
|
import { avatarColorsOf, brightPaletteOf, themeTokens, } from './themeTokens';
|
|
22
22
|
export { avatarColorsOf, brightPaletteOf, getCardGradient, getThemeTokens, themeTokens, themeVariants, } from './themeTokens';
|
|
23
23
|
const primerThemes = {
|
|
@@ -34,7 +34,13 @@ const primerThemes = {
|
|
|
34
34
|
};
|
|
35
35
|
export const themeConfigs = Object.fromEntries(Object.keys(themeTokens).map(variant => [
|
|
36
36
|
variant,
|
|
37
|
-
{
|
|
37
|
+
{
|
|
38
|
+
...themeTokens[variant],
|
|
39
|
+
// The web's vscode styles carry the editors' face, which the portable
|
|
40
|
+
// tokens leave out (see vscodeThemeStyles.ts).
|
|
41
|
+
...(variant === 'vscode' ? { themeStyles: vscodeThemeStyles } : {}),
|
|
42
|
+
primerTheme: primerThemes[variant],
|
|
43
|
+
},
|
|
38
44
|
]));
|
|
39
45
|
/** Look up a theme config by variant name. */
|
|
40
46
|
export function getThemeConfig(variant) {
|
package/lib/theme/themeTokens.js
CHANGED
|
@@ -11,7 +11,7 @@ import { sandThemeStyles } from './themes/sandThemeStyles';
|
|
|
11
11
|
import { ivoryThemeStyles } from './themes/ivoryThemeStyles';
|
|
12
12
|
import { sunThemeStyles } from './themes/sunThemeStyles';
|
|
13
13
|
import { loopThemeStyles } from './themes/loopThemeStyles';
|
|
14
|
-
import {
|
|
14
|
+
import { vscodePortableThemeStyles } from './themes/vscodeThemeStyles';
|
|
15
15
|
import { datalayerColors } from './colors/datalayerColors';
|
|
16
16
|
import { spatialColors } from './colors/spatialColors';
|
|
17
17
|
import { lovelyColors } from './colors/lovelyColors';
|
|
@@ -309,7 +309,7 @@ export const themeTokens = {
|
|
|
309
309
|
description: 'The editor’s own colours: in a Visual Studio Code webview it follows the colour theme in use, and changes with it; elsewhere, Dark Modern and Light Modern.',
|
|
310
310
|
brandColor: vscodeColors.vscodeBrand,
|
|
311
311
|
defaultColorMode: 'auto',
|
|
312
|
-
themeStyles:
|
|
312
|
+
themeStyles: vscodePortableThemeStyles,
|
|
313
313
|
cardGradient: {
|
|
314
314
|
light: { from: vscodeColors.vscodeText, to: vscodeColors.brightLightSurge }, // #005FB8 → #0451A5
|
|
315
315
|
dark: { from: vscodeColors.vscodeAccent, to: vscodeColors.vscodeBrand }, // #4DAAFC → #0078D4
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
export * from './vscodeThemeStyles';
|
|
2
2
|
export * from './vscodeEditorsCss';
|
|
3
|
+
/** Comprehensive Primer CSS-variable overrides for light & dark mode, with the editors' face. */
|
|
4
|
+
export declare const vscodeThemeStyles: {
|
|
5
|
+
css: string;
|
|
6
|
+
light: import("react").CSSProperties;
|
|
7
|
+
dark: import("react").CSSProperties;
|
|
8
|
+
};
|
|
9
|
+
/** The theme's whole stylesheet (`ThemeStyles.css`). */
|
|
10
|
+
export declare const vscodeControlsCss: string;
|
|
3
11
|
/** The Primer theme object: Primer's default. */
|
|
4
12
|
export declare const vscodeTheme: {
|
|
5
13
|
animation: {
|
|
@@ -10,8 +10,17 @@
|
|
|
10
10
|
* without Primer React (a native app) imports the styles module instead.
|
|
11
11
|
*/
|
|
12
12
|
import { theme as primerTheme } from '@primer/react';
|
|
13
|
+
import { vscodeEditorsCss } from './vscodeEditorsCss';
|
|
14
|
+
import { vscodePortableThemeStyles } from './vscodeThemeStyles';
|
|
13
15
|
export * from './vscodeThemeStyles';
|
|
14
16
|
export * from './vscodeEditorsCss';
|
|
17
|
+
/** Comprehensive Primer CSS-variable overrides for light & dark mode, with the editors' face. */
|
|
18
|
+
export const vscodeThemeStyles = {
|
|
19
|
+
...vscodePortableThemeStyles,
|
|
20
|
+
css: `${vscodePortableThemeStyles.css ?? ''}\n${vscodeEditorsCss}`,
|
|
21
|
+
};
|
|
22
|
+
/** The theme's whole stylesheet (`ThemeStyles.css`). */
|
|
23
|
+
export const vscodeControlsCss = vscodeThemeStyles.css;
|
|
15
24
|
/** The Primer theme object: Primer's default. */
|
|
16
25
|
export const vscodeTheme = primerTheme;
|
|
17
26
|
export default vscodeTheme;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { type ThemeColorDefs } from '../css/createThemeCSSVars';
|
|
2
2
|
export declare const vscodeLight: ThemeColorDefs;
|
|
3
3
|
export declare const vscodeDark: ThemeColorDefs;
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
/**
|
|
5
|
+
* The theme's tokens, shapes and focus ring, without the editors' face: what
|
|
6
|
+
* the portable theme tokens carry. The web's `vscodeThemeStyles`
|
|
7
|
+
* (`vscodeTheme.ts`) adds the editors' face to it.
|
|
8
|
+
*/
|
|
9
|
+
export declare const vscodePortableThemeStyles: import("../css/createThemeCSSVars").ThemeStyles;
|
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
import { vscodeFontFamily, vscodeFontSize, vscodeMonoFontFamily, vscodeTint, vscodeVar, } from '../colors/vscodeColors';
|
|
21
21
|
import { buildThemeStyles } from '../css/createThemeCSSVars';
|
|
22
22
|
import { primerComponentSelectors } from '../css/primerComponentsCss';
|
|
23
|
-
import { vscodeEditorsCss } from './vscodeEditorsCss';
|
|
24
23
|
/* ── Colour definitions, one per mode ────────────────────────────────── */
|
|
25
24
|
/**
|
|
26
25
|
* The colour definitions for a mode: the same editor variables in both,
|
|
@@ -205,8 +204,10 @@ function vscodeVariables(mode) {
|
|
|
205
204
|
const sel = primerComponentSelectors;
|
|
206
205
|
/**
|
|
207
206
|
* What no token says: the editor's focus ring is one pixel, drawn inside
|
|
208
|
-
* the control, in the focus colour.
|
|
209
|
-
*
|
|
207
|
+
* the control, in the focus colour. The editors' face (`vscodeEditorsCss`:
|
|
208
|
+
* JupyterLab's variables, CodeMirror, Excalidraw) is web-only and joins it
|
|
209
|
+
* in `vscodeTheme.ts`, so the portable entry (`theme/portable`, read by
|
|
210
|
+
* Datalayer Mobile's Hermes bundle) never reaches it.
|
|
210
211
|
*/
|
|
211
212
|
const vscodeOwnCss = `
|
|
212
213
|
:scope ${sel.button}:focus-visible,
|
|
@@ -215,11 +216,14 @@ const vscodeOwnCss = `
|
|
|
215
216
|
outline: 1px solid var(--focus-outlineColor);
|
|
216
217
|
outline-offset: -1px;
|
|
217
218
|
box-shadow: none;
|
|
218
|
-
}
|
|
219
|
-
${vscodeEditorsCss}`;
|
|
219
|
+
}`;
|
|
220
220
|
/* ── Exports ─────────────────────────────────────────────────────────── */
|
|
221
|
-
/**
|
|
222
|
-
|
|
221
|
+
/**
|
|
222
|
+
* The theme's tokens, shapes and focus ring, without the editors' face: what
|
|
223
|
+
* the portable theme tokens carry. The web's `vscodeThemeStyles`
|
|
224
|
+
* (`vscodeTheme.ts`) adds the editors' face to it.
|
|
225
|
+
*/
|
|
226
|
+
export const vscodePortableThemeStyles = buildThemeStyles(vscodeLight, vscodeDark, {
|
|
223
227
|
fontFamily: vscodeFontFamily,
|
|
224
228
|
css: vscodeOwnCss,
|
|
225
229
|
// The editor's shape: tight corners, flat surfaces, no motion.
|
|
@@ -242,5 +246,3 @@ export const vscodeThemeStyles = buildThemeStyles(vscodeLight, vscodeDark, {
|
|
|
242
246
|
dark: vscodeVariables('dark'),
|
|
243
247
|
},
|
|
244
248
|
});
|
|
245
|
-
/** The theme's whole stylesheet (`ThemeStyles.css`). */
|
|
246
|
-
export const vscodeControlsCss = vscodeThemeStyles.css ?? '';
|