@datalayer/primer-addons 1.0.41 → 1.0.43

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 (43) hide show
  1. package/README.md +6 -2
  2. package/lib/components/appearance/AppearanceControls.stories.d.ts +45 -0
  3. package/lib/components/appearance/AppearanceControls.stories.js +91 -0
  4. package/lib/components/appearance/AppearanceMenu.stories.d.ts +49 -0
  5. package/lib/components/appearance/AppearanceMenu.stories.js +80 -0
  6. package/lib/components/appearance/CollaboratorPalette.stories.d.ts +34 -0
  7. package/lib/components/appearance/CollaboratorPalette.stories.js +59 -0
  8. package/lib/components/appearance/ColorModeCircle.stories.d.ts +47 -0
  9. package/lib/components/appearance/ColorModeCircle.stories.js +80 -0
  10. package/lib/components/appearance/ThemeCircle.stories.d.ts +31 -0
  11. package/lib/components/appearance/ThemeCircle.stories.js +54 -0
  12. package/lib/components/appearance/ThemePreviewCard.stories.d.ts +38 -0
  13. package/lib/components/appearance/ThemePreviewCard.stories.js +72 -0
  14. package/lib/components/box/Box.stories.d.ts +61 -0
  15. package/lib/components/box/Box.stories.js +103 -0
  16. package/lib/components/calendar-picker/CalendarPicker.stories.d.ts +53 -0
  17. package/lib/components/calendar-picker/CalendarPicker.stories.js +89 -0
  18. package/lib/components/card/Card.d.ts +40 -0
  19. package/lib/components/card/Card.js +59 -3
  20. package/lib/components/card/Card.stories.d.ts +8 -0
  21. package/lib/components/card/Card.stories.js +17 -1
  22. package/lib/components/color/ColorSwatch.stories.d.ts +26 -0
  23. package/lib/components/color/ColorSwatch.stories.js +54 -0
  24. package/lib/components/color-picker/ColorPicker.stories.d.ts +36 -0
  25. package/lib/components/color-picker/ColorPicker.stories.js +85 -0
  26. package/lib/components/date-picker/DatePicker.stories.d.ts +65 -0
  27. package/lib/components/date-picker/DatePicker.stories.js +110 -0
  28. package/lib/components/entity-avatar/EntityAvatar.stories.d.ts +47 -0
  29. package/lib/components/entity-avatar/EntityAvatar.stories.js +81 -0
  30. package/lib/components/hover-card/HoverCard.js +4 -1
  31. package/lib/components/hover-card/HoverCard.stories.d.ts +48 -0
  32. package/lib/components/hover-card/HoverCard.stories.js +98 -0
  33. package/lib/components/logo/DatalayerLogo.stories.d.ts +37 -0
  34. package/lib/components/logo/DatalayerLogo.stories.js +58 -0
  35. package/lib/components/sheet/Sheet.stories.d.ts +25 -0
  36. package/lib/components/sheet/Sheet.stories.js +32 -0
  37. package/lib/components/toolbar/Toolbar.stories.d.ts +36 -0
  38. package/lib/components/toolbar/Toolbar.stories.js +209 -0
  39. package/lib/story-helpers.d.ts +11 -0
  40. package/lib/story-helpers.js +19 -1
  41. package/lib/utils/Portals.d.ts +0 -13
  42. package/lib/utils/Portals.js +22 -0
  43. package/package.json +1 -1
package/README.md CHANGED
@@ -8,7 +8,10 @@
8
8
 
9
9
  This repository contains additional React.js components for the [@primer/react](https://github.com/primer/react) toolkit. The components are compliant with the Primer theming framework and aims to respect the [Primer design system](https://primer.style).
10
10
 
11
- A Storybook showcasing the components and their options is available on https://primer-addons.datalayer.tech.
11
+ See them live:
12
+
13
+ - **Gallery** — every component on its page, in every theme and colour mode: https://primer-addons.datalayer.tech (`make deploy-gallery` publishes it).
14
+ - **Storybook** — each component's options, story by story: https://primer-addons.datalayer.tech/storybook/ (`make deploy-storybook`).
12
15
 
13
16
  This project has been [shared in a discussion](https://github.com/primer/react/discussions/3297) on the Primer React main repository.
14
17
 
@@ -18,6 +21,7 @@ This project has been [shared in a discussion](https://github.com/primer/react/d
18
21
  - [x] Box
19
22
  - [x] Calendar Picker
20
23
  - [x] Card
24
+ - [x] Circle Icon
21
25
  - [x] Closeable Flash
22
26
  - [x] Color Swatch and Color Picker
23
27
  - [x] Content Loader
@@ -48,7 +52,7 @@ import { AppearancePlugin, PageLayoutPlugin, ThemePlugin } from '@datalayer/prim
48
52
  - `AppearancePlugin` puts the appearance menu — color mode, theme, the theme's description and a preview of it, the control the Datalayer header wears — in a slot, `header` by default, and brings `ThemePlugin` along as a dependency.
49
53
  - `PageLayoutPlugin` arranges a host's slots as a page: what plugins put in `page` lies on a centred sheet over a quiet canvas, `page-band` is docked above it at the sheet's width (or floats over it as a card), `page-chips` sit under the band, and `page-panel` is a side panel opened from a toggle in the header. The layout (`PageLayout`), its toggle and its signals (`pageLayoutPanelOpen`, `openPagePanel()`…) are exported too, for a host that wires the parts itself — the Loop of `@datalayer/agent-runtimes` does, with the notebook as the page and the conversation as the panel.
50
54
 
51
- The [gallery example](examples/gallery) is a Reactor app built on the three: `npm run gallery`.
55
+ The [gallery example](examples/gallery) is a Reactor app built on the three: `npm run gallery` locally, live at https://primer-addons.datalayer.tech.
52
56
 
53
57
  <div align="center" style="text-align: center">
54
58
  <img alt="Primer React Addons" src="https://assets.datalayer.tech/primer-addons-example.png" />
@@ -0,0 +1,45 @@
1
+ import type { StoryObj } from "@storybook/react";
2
+ import { AppearanceControls, type ColorMode, type ThemeVariant } from "../..";
3
+ declare const meta: {
4
+ title: string;
5
+ component: typeof AppearanceControls;
6
+ tags: string[];
7
+ parameters: {
8
+ layout: string;
9
+ };
10
+ argTypes: {
11
+ colorMode: {
12
+ options: string[];
13
+ control: "radio";
14
+ };
15
+ themeVariant: {
16
+ options: ThemeVariant[];
17
+ control: "select";
18
+ };
19
+ };
20
+ args: {
21
+ colorMode: "light";
22
+ themeVariant: "datalayer";
23
+ onColorModeChange: (mode: ColorMode) => void;
24
+ onThemeChange: (variant: ThemeVariant) => void;
25
+ showColorMode: true;
26
+ showThemeChooser: true;
27
+ showThemePreviews: false;
28
+ };
29
+ };
30
+ export default meta;
31
+ type Story = StoryObj<typeof meta>;
32
+ /** Both parts, the theme as one swatch per theme (the default). */
33
+ export declare const Default: Story;
34
+ /** With the chosen theme's name, description and a live preview under the swatches. */
35
+ export declare const WithThemePreviews: Story;
36
+ /** The light / dark / auto switch alone. */
37
+ export declare const ColorModeOnly: Story;
38
+ /** The theme chooser alone. */
39
+ export declare const ThemeChooserOnly: Story;
40
+ /**
41
+ * `AppearanceControlsWithStore`: the same controls reading and writing a
42
+ * theme store (`useThemeStore` here), with the story drawn by
43
+ * `ThemedProvider` from that store.
44
+ */
45
+ export declare const WithStore: Story;
@@ -0,0 +1,91 @@
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
+ import { useEffect, useState } from "react";
7
+ import { Box, Text } from "@primer/react";
8
+ import { AppearanceControls, AppearanceControlsWithStore, DatalayerThemeProvider, ThemedProvider, themeConfigs, themeVariants, useThemeStore, } from "../..";
9
+ const meta = {
10
+ title: "Components/Appearance/AppearanceControls",
11
+ component: AppearanceControls,
12
+ tags: ["autodocs"],
13
+ parameters: {
14
+ layout: "fullscreen",
15
+ },
16
+ argTypes: {
17
+ colorMode: {
18
+ options: ["light", "dark", "auto"],
19
+ control: "radio",
20
+ },
21
+ themeVariant: {
22
+ options: themeVariants,
23
+ control: "select",
24
+ },
25
+ },
26
+ args: {
27
+ colorMode: "light",
28
+ themeVariant: "datalayer",
29
+ onColorModeChange: (mode) => console.log("Color mode:", mode),
30
+ onThemeChange: (variant) => console.log("Theme:", variant),
31
+ showColorMode: true,
32
+ showThemeChooser: true,
33
+ showThemePreviews: false,
34
+ },
35
+ };
36
+ export default meta;
37
+ /**
38
+ * Holds the choice, and draws the frame in it: picking a theme or a mode
39
+ * re-themes the story around the controls.
40
+ */
41
+ const ThemedAppearanceControls = (props) => {
42
+ const [colorMode, setColorMode] = useState(props.colorMode);
43
+ const [themeVariant, setThemeVariant] = useState(props.themeVariant);
44
+ useEffect(() => setColorMode(props.colorMode), [props.colorMode]);
45
+ useEffect(() => setThemeVariant(props.themeVariant), [props.themeVariant]);
46
+ const config = themeConfigs[themeVariant];
47
+ return (_jsx(DatalayerThemeProvider, { colorMode: colorMode, theme: config.primerTheme, themeStyles: config.themeStyles, children: _jsxs(Box, { p: 3, bg: "canvas.default", children: [_jsx(Box, { maxWidth: 360, sx: {
48
+ border: "1px solid",
49
+ borderColor: "border.default",
50
+ borderRadius: 2,
51
+ }, children: _jsx(AppearanceControls, { ...props, colorMode: colorMode, themeVariant: themeVariant, onColorModeChange: (mode) => {
52
+ setColorMode(mode);
53
+ props.onColorModeChange(mode);
54
+ }, onThemeChange: (variant) => {
55
+ setThemeVariant(variant);
56
+ props.onThemeChange(variant);
57
+ } }) }), _jsxs(Text, { as: "p", sx: { mt: 2, fontSize: 0, color: "fg.muted" }, children: [config.label, ", ", colorMode, ": ", config.description] })] }) }));
58
+ };
59
+ /** Both parts, the theme as one swatch per theme (the default). */
60
+ export const Default = {
61
+ render: (args) => _jsx(ThemedAppearanceControls, { ...args }),
62
+ };
63
+ /** With the chosen theme's name, description and a live preview under the swatches. */
64
+ export const WithThemePreviews = {
65
+ args: {
66
+ showThemePreviews: true,
67
+ },
68
+ render: (args) => _jsx(ThemedAppearanceControls, { ...args }),
69
+ };
70
+ /** The light / dark / auto switch alone. */
71
+ export const ColorModeOnly = {
72
+ args: {
73
+ showThemeChooser: false,
74
+ },
75
+ render: (args) => _jsx(ThemedAppearanceControls, { ...args }),
76
+ };
77
+ /** The theme chooser alone. */
78
+ export const ThemeChooserOnly = {
79
+ args: {
80
+ showColorMode: false,
81
+ },
82
+ render: (args) => _jsx(ThemedAppearanceControls, { ...args }),
83
+ };
84
+ /**
85
+ * `AppearanceControlsWithStore`: the same controls reading and writing a
86
+ * theme store (`useThemeStore` here), with the story drawn by
87
+ * `ThemedProvider` from that store.
88
+ */
89
+ export const WithStore = {
90
+ render: (args) => (_jsx(ThemedProvider, { useStore: useThemeStore, children: _jsx(Box, { p: 3, bg: "canvas.default", maxWidth: 400, children: _jsx(AppearanceControlsWithStore, { useStore: useThemeStore, showColorMode: args.showColorMode, showThemeChooser: args.showThemeChooser }) }) })),
91
+ };
@@ -0,0 +1,49 @@
1
+ import type { StoryObj } from "@storybook/react";
2
+ import { AppearanceMenu, type ColorMode, type ThemeVariant } from "../..";
3
+ declare const meta: {
4
+ title: string;
5
+ component: typeof AppearanceMenu;
6
+ tags: string[];
7
+ parameters: {
8
+ layout: string;
9
+ };
10
+ argTypes: {
11
+ colorMode: {
12
+ options: string[];
13
+ control: "radio";
14
+ };
15
+ themeVariant: {
16
+ options: ThemeVariant[];
17
+ control: "select";
18
+ };
19
+ shape: {
20
+ options: string[];
21
+ control: "radio";
22
+ };
23
+ hoverOverlayPlacement: {
24
+ options: string[];
25
+ control: "radio";
26
+ };
27
+ };
28
+ args: {
29
+ colorMode: "light";
30
+ themeVariant: "datalayer";
31
+ onColorModeChange: (mode: ColorMode) => void;
32
+ onThemeChange: (variant: ThemeVariant) => void;
33
+ size: number;
34
+ shape: "square";
35
+ hoverOverlayPlacement: "bottom-start";
36
+ showThemePreviews: true;
37
+ };
38
+ };
39
+ export default meta;
40
+ type Story = StoryObj<typeof meta>;
41
+ /** The square a header wears. */
42
+ export declare const Default: Story;
43
+ /** A round trigger, larger, without the theme previews in its overlay. */
44
+ export declare const CircleWithoutPreviews: Story;
45
+ /**
46
+ * `AppearanceMenuWithStore`: the menu wired to a theme store, as the
47
+ * appearance plugin puts it in a header.
48
+ */
49
+ export declare const WithStore: Story;
@@ -0,0 +1,80 @@
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
+ import { useEffect, useState } from "react";
7
+ import { Box, Text } from "@primer/react";
8
+ import { AppearanceMenu, AppearanceMenuWithStore, DatalayerThemeProvider, ThemedProvider, themeConfigs, themeVariants, useThemeStore, } from "../..";
9
+ const meta = {
10
+ title: "Components/Appearance/AppearanceMenu",
11
+ component: AppearanceMenu,
12
+ tags: ["autodocs"],
13
+ parameters: {
14
+ layout: "fullscreen",
15
+ },
16
+ argTypes: {
17
+ colorMode: {
18
+ options: ["light", "dark", "auto"],
19
+ control: "radio",
20
+ },
21
+ themeVariant: {
22
+ options: themeVariants,
23
+ control: "select",
24
+ },
25
+ shape: {
26
+ options: ["square", "circle"],
27
+ control: "radio",
28
+ },
29
+ hoverOverlayPlacement: {
30
+ options: ["bottom-start", "bottom-end"],
31
+ control: "radio",
32
+ },
33
+ },
34
+ args: {
35
+ colorMode: "light",
36
+ themeVariant: "datalayer",
37
+ onColorModeChange: (mode) => console.log("Color mode:", mode),
38
+ onThemeChange: (variant) => console.log("Theme:", variant),
39
+ size: 26,
40
+ shape: "square",
41
+ hoverOverlayPlacement: "bottom-start",
42
+ showThemePreviews: true,
43
+ },
44
+ };
45
+ export default meta;
46
+ /** Holds the choice and draws the story in it. */
47
+ const ThemedAppearanceMenu = (props) => {
48
+ const [colorMode, setColorMode] = useState(props.colorMode);
49
+ const [themeVariant, setThemeVariant] = useState(props.themeVariant);
50
+ useEffect(() => setColorMode(props.colorMode), [props.colorMode]);
51
+ useEffect(() => setThemeVariant(props.themeVariant), [props.themeVariant]);
52
+ const config = themeConfigs[themeVariant];
53
+ return (_jsx(DatalayerThemeProvider, { colorMode: colorMode, theme: config.primerTheme, themeStyles: config.themeStyles, children: _jsx(Box, { p: 3, bg: "canvas.default", minHeight: 520, children: _jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 3 }, children: [_jsx(AppearanceMenu, { ...props, colorMode: colorMode, themeVariant: themeVariant, onColorModeChange: (mode) => {
54
+ setColorMode(mode);
55
+ props.onColorModeChange(mode);
56
+ }, onThemeChange: (variant) => {
57
+ setThemeVariant(variant);
58
+ props.onThemeChange(variant);
59
+ } }), _jsx(Text, { sx: { color: "fg.muted", fontSize: 1 }, children: "Hover the control: colour mode, theme, the theme's description and a preview." })] }) }) }));
60
+ };
61
+ /** The square a header wears. */
62
+ export const Default = {
63
+ render: (args) => _jsx(ThemedAppearanceMenu, { ...args }),
64
+ };
65
+ /** A round trigger, larger, without the theme previews in its overlay. */
66
+ export const CircleWithoutPreviews = {
67
+ args: {
68
+ shape: "circle",
69
+ size: 32,
70
+ showThemePreviews: false,
71
+ },
72
+ render: (args) => _jsx(ThemedAppearanceMenu, { ...args }),
73
+ };
74
+ /**
75
+ * `AppearanceMenuWithStore`: the menu wired to a theme store, as the
76
+ * appearance plugin puts it in a header.
77
+ */
78
+ export const WithStore = {
79
+ render: (args) => (_jsx(ThemedProvider, { useStore: useThemeStore, children: _jsx(Box, { p: 3, bg: "canvas.default", minHeight: 520, children: _jsx(AppearanceMenuWithStore, { useStore: useThemeStore, size: args.size, shape: args.shape, hoverOverlayPlacement: args.hoverOverlayPlacement, showThemePreviews: args.showThemePreviews }) }) })),
80
+ };
@@ -0,0 +1,34 @@
1
+ import type { StoryObj } from "@storybook/react";
2
+ import { CollaboratorPalette } from "../..";
3
+ declare const meta: {
4
+ title: string;
5
+ component: typeof CollaboratorPalette;
6
+ tags: string[];
7
+ parameters: {
8
+ layout: string;
9
+ };
10
+ argTypes: {
11
+ variant: {
12
+ options: import("../..").ThemeVariant[];
13
+ control: "select";
14
+ };
15
+ colorMode: {
16
+ options: string[];
17
+ control: "radio";
18
+ };
19
+ };
20
+ args: {
21
+ showValues: true;
22
+ height: number;
23
+ };
24
+ };
25
+ export default meta;
26
+ type Story = StoryObj<typeof meta>;
27
+ /** The seven colours of the active theme, slot by slot. */
28
+ export declare const ActiveTheme: Story;
29
+ /** A room of five: each person's colour is a stable hash of who they are. */
30
+ export declare const ARoomOfFive: Story;
31
+ /** One theme in one mode, whatever the page wears. */
32
+ export declare const LoopDark: Story;
33
+ /** What a caret and its name tag look like in a shared document. */
34
+ export declare const Cursors: Story;
@@ -0,0 +1,59 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Text } from "@primer/react";
3
+ import { CollaboratorPalette, collaboratorColor, themeVariants, } from "../..";
4
+ const ROOM = ["ada", "grace", "alan", "katherine", "edsger"];
5
+ const meta = {
6
+ title: "Components/Appearance/CollaboratorPalette",
7
+ component: CollaboratorPalette,
8
+ tags: ["autodocs"],
9
+ parameters: {
10
+ layout: "fullscreen",
11
+ },
12
+ argTypes: {
13
+ variant: {
14
+ options: themeVariants,
15
+ control: "select",
16
+ },
17
+ colorMode: {
18
+ options: ["light", "dark", "auto"],
19
+ control: "radio",
20
+ },
21
+ },
22
+ args: {
23
+ showValues: true,
24
+ height: 32,
25
+ },
26
+ };
27
+ export default meta;
28
+ const ThemedCollaboratorPalette = (props) => (_jsx(Box, { p: 3, bg: "canvas.default", children: _jsx(CollaboratorPalette, { ...props }) }));
29
+ /** The seven colours of the active theme, slot by slot. */
30
+ export const ActiveTheme = {
31
+ render: (args) => _jsx(ThemedCollaboratorPalette, { ...args }),
32
+ };
33
+ /** A room of five: each person's colour is a stable hash of who they are. */
34
+ export const ARoomOfFive = {
35
+ args: {
36
+ people: ROOM,
37
+ },
38
+ render: (args) => _jsx(ThemedCollaboratorPalette, { ...args }),
39
+ };
40
+ /** One theme in one mode, whatever the page wears. */
41
+ export const LoopDark = {
42
+ args: {
43
+ variant: "loop",
44
+ colorMode: "dark",
45
+ people: ROOM,
46
+ },
47
+ render: (args) => _jsx(ThemedCollaboratorPalette, { ...args }),
48
+ };
49
+ /** What a caret and its name tag look like in a shared document. */
50
+ export const Cursors = {
51
+ args: {
52
+ variant: "datalayer",
53
+ colorMode: "light",
54
+ },
55
+ render: (args) => (_jsx(Box, { p: 3, bg: "canvas.default", sx: { display: "flex", gap: 3, flexWrap: "wrap" }, children: ROOM.map((person) => {
56
+ const color = collaboratorColor(person, args.variant, args.colorMode);
57
+ return (_jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 2 }, children: [_jsx(Box, { "aria-hidden": "true", style: { width: 2, height: 20, backgroundColor: color } }), _jsx(Text, { sx: { fontSize: 0, px: 1, borderRadius: 1, color: "#fff" }, style: { backgroundColor: color }, children: person })] }, person));
58
+ }) })),
59
+ };
@@ -0,0 +1,47 @@
1
+ import type { StoryObj } from "@storybook/react";
2
+ import { ColorModeCircle, type ColorMode, type ThemeVariant } from "../..";
3
+ declare const meta: {
4
+ title: string;
5
+ component: typeof ColorModeCircle;
6
+ tags: string[];
7
+ parameters: {
8
+ layout: string;
9
+ };
10
+ argTypes: {
11
+ colorMode: {
12
+ options: string[];
13
+ control: "radio";
14
+ };
15
+ themeVariant: {
16
+ options: ThemeVariant[];
17
+ control: "select";
18
+ };
19
+ shape: {
20
+ options: string[];
21
+ control: "radio";
22
+ };
23
+ hoverOverlayPlacement: {
24
+ options: string[];
25
+ control: "radio";
26
+ };
27
+ hoverOverlay: {
28
+ control: false;
29
+ };
30
+ };
31
+ args: {
32
+ colorMode: "light";
33
+ themeVariant: "datalayer";
34
+ onColorModeChange: (mode: ColorMode) => void;
35
+ size: number;
36
+ shape: "square";
37
+ cycleOnClick: true;
38
+ };
39
+ };
40
+ export default meta;
41
+ type Story = StoryObj<typeof meta>;
42
+ /** Click to cycle the colour mode. */
43
+ export declare const Default: Story;
44
+ /** The round shape, larger. */
45
+ export declare const Circle: Story;
46
+ /** Hovering reveals an overlay — here the appearance controls; clicking no longer cycles. */
47
+ export declare const WithHoverOverlay: Story;
@@ -0,0 +1,80 @@
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
+ import { useEffect, useState } from "react";
7
+ import { Box, Text } from "@primer/react";
8
+ import { AppearanceControls, ColorModeCircle, themeVariants, } from "../..";
9
+ const meta = {
10
+ title: "Components/Appearance/ColorModeCircle",
11
+ component: ColorModeCircle,
12
+ tags: ["autodocs"],
13
+ parameters: {
14
+ layout: "fullscreen",
15
+ },
16
+ argTypes: {
17
+ colorMode: {
18
+ options: ["light", "dark", "auto"],
19
+ control: "radio",
20
+ },
21
+ themeVariant: {
22
+ options: themeVariants,
23
+ control: "select",
24
+ },
25
+ shape: {
26
+ options: ["square", "circle"],
27
+ control: "radio",
28
+ },
29
+ hoverOverlayPlacement: {
30
+ options: ["bottom-start", "bottom-end"],
31
+ control: "radio",
32
+ },
33
+ hoverOverlay: {
34
+ control: false,
35
+ },
36
+ },
37
+ args: {
38
+ colorMode: "light",
39
+ themeVariant: "datalayer",
40
+ onColorModeChange: (mode) => console.log("Color mode:", mode),
41
+ size: 28,
42
+ shape: "square",
43
+ cycleOnClick: true,
44
+ },
45
+ };
46
+ export default meta;
47
+ /** Holds the mode, so clicking cycles it. */
48
+ const ThemedColorModeCircle = ({ withOverlay = false, ...props }) => {
49
+ const [colorMode, setColorMode] = useState(props.colorMode);
50
+ const [themeVariant, setThemeVariant] = useState(props.themeVariant ?? "datalayer");
51
+ useEffect(() => setColorMode(props.colorMode), [props.colorMode]);
52
+ useEffect(() => setThemeVariant(props.themeVariant ?? "datalayer"), [props.themeVariant]);
53
+ const onColorModeChange = (mode) => {
54
+ setColorMode(mode);
55
+ props.onColorModeChange(mode);
56
+ };
57
+ return (_jsx(Box, { p: 3, bg: "canvas.default", minHeight: withOverlay ? 360 : undefined, children: _jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 3 }, children: [_jsx(ColorModeCircle, { ...props, colorMode: colorMode, themeVariant: themeVariant, onColorModeChange: onColorModeChange, hoverOverlay: withOverlay ? (_jsx(AppearanceControls, { colorMode: colorMode, themeVariant: themeVariant, onColorModeChange: onColorModeChange, onThemeChange: setThemeVariant })) : undefined }), _jsx(Text, { sx: { fontSize: 1, color: "fg.muted" }, children: withOverlay
58
+ ? `Hover to reveal the appearance controls (${colorMode}).`
59
+ : `Click to cycle light → dark → auto (now ${colorMode}).` })] }) }));
60
+ };
61
+ /** Click to cycle the colour mode. */
62
+ export const Default = {
63
+ render: (args) => _jsx(ThemedColorModeCircle, { ...args }),
64
+ };
65
+ /** The round shape, larger. */
66
+ export const Circle = {
67
+ args: {
68
+ shape: "circle",
69
+ size: 36,
70
+ },
71
+ render: (args) => _jsx(ThemedColorModeCircle, { ...args }),
72
+ };
73
+ /** Hovering reveals an overlay — here the appearance controls; clicking no longer cycles. */
74
+ export const WithHoverOverlay = {
75
+ args: {
76
+ cycleOnClick: false,
77
+ hoverOverlayPlacement: "bottom-start",
78
+ },
79
+ render: (args) => _jsx(ThemedColorModeCircle, { ...args, withOverlay: true }),
80
+ };
@@ -0,0 +1,31 @@
1
+ import type { StoryObj } from "@storybook/react";
2
+ import { ThemeCircle, type ThemeVariant } from "../..";
3
+ declare const meta: {
4
+ title: string;
5
+ component: typeof ThemeCircle;
6
+ tags: string[];
7
+ parameters: {
8
+ layout: string;
9
+ };
10
+ argTypes: {
11
+ themeVariant: {
12
+ options: ThemeVariant[];
13
+ control: "select";
14
+ };
15
+ themes: {
16
+ options: ThemeVariant[];
17
+ control: "check";
18
+ };
19
+ };
20
+ args: {
21
+ themeVariant: "datalayer";
22
+ onThemeChange: (variant: ThemeVariant) => void;
23
+ size: number;
24
+ };
25
+ };
26
+ export default meta;
27
+ type Story = StoryObj<typeof meta>;
28
+ /** Click to move through every registered theme. */
29
+ export declare const Default: Story;
30
+ /** Cycling through a chosen few. */
31
+ export declare const AFewThemes: Story;
@@ -0,0 +1,54 @@
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
+ import { useEffect, useState } from "react";
7
+ import { Box, Text } from "@primer/react";
8
+ import { DatalayerThemeProvider, ThemeCircle, themeConfigs, themeVariants, } from "../..";
9
+ const meta = {
10
+ title: "Components/Appearance/ThemeCircle",
11
+ component: ThemeCircle,
12
+ tags: ["autodocs"],
13
+ parameters: {
14
+ layout: "fullscreen",
15
+ },
16
+ argTypes: {
17
+ themeVariant: {
18
+ options: themeVariants,
19
+ control: "select",
20
+ },
21
+ themes: {
22
+ options: themeVariants,
23
+ control: "check",
24
+ },
25
+ },
26
+ args: {
27
+ themeVariant: "datalayer",
28
+ onThemeChange: (variant) => console.log("Theme:", variant),
29
+ size: 28,
30
+ },
31
+ };
32
+ export default meta;
33
+ /** Holds the theme, so clicking moves to the next one, and draws the story in it. */
34
+ const ThemedThemeCircle = (props) => {
35
+ const [themeVariant, setThemeVariant] = useState(props.themeVariant);
36
+ useEffect(() => setThemeVariant(props.themeVariant), [props.themeVariant]);
37
+ const config = themeConfigs[themeVariant];
38
+ return (_jsx(DatalayerThemeProvider, { colorMode: config.defaultColorMode, theme: config.primerTheme, themeStyles: config.themeStyles, children: _jsx(Box, { p: 3, bg: "canvas.default", children: _jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 3 }, children: [_jsx(ThemeCircle, { ...props, themeVariant: themeVariant, onThemeChange: (variant) => {
39
+ setThemeVariant(variant);
40
+ props.onThemeChange(variant);
41
+ } }), _jsxs(Box, { children: [_jsx(Text, { as: "p", sx: { m: 0, fontWeight: "semibold" }, children: config.label }), _jsx(Text, { as: "p", sx: { m: 0, fontSize: 0, color: "fg.muted" }, children: config.description })] })] }) }) }));
42
+ };
43
+ /** Click to move through every registered theme. */
44
+ export const Default = {
45
+ render: (args) => _jsx(ThemedThemeCircle, { ...args }),
46
+ };
47
+ /** Cycling through a chosen few. */
48
+ export const AFewThemes = {
49
+ args: {
50
+ themes: ["datalayer", "loop", "earth", "matrix"],
51
+ size: 36,
52
+ },
53
+ render: (args) => _jsx(ThemedThemeCircle, { ...args }),
54
+ };
@@ -0,0 +1,38 @@
1
+ import type { StoryObj } from "@storybook/react";
2
+ import { ThemePreviewCard, type ThemeVariant } from "../..";
3
+ declare const meta: {
4
+ title: string;
5
+ component: typeof ThemePreviewCard;
6
+ tags: string[];
7
+ parameters: {
8
+ layout: string;
9
+ };
10
+ argTypes: {
11
+ variant: {
12
+ options: ThemeVariant[];
13
+ control: "select";
14
+ };
15
+ colorMode: {
16
+ options: string[];
17
+ control: "radio";
18
+ };
19
+ };
20
+ args: {
21
+ variant: "loop";
22
+ colorMode: "light";
23
+ selected: false;
24
+ compact: false;
25
+ showDescription: true;
26
+ onSelect: (variant: ThemeVariant) => void;
27
+ };
28
+ };
29
+ export default meta;
30
+ type Story = StoryObj<typeof meta>;
31
+ /** One theme's miniature: its name, description and a sketch of a page in it. */
32
+ export declare const Default: Story;
33
+ /** The chosen card, in the dark. */
34
+ export declare const SelectedDark: Story;
35
+ /** Compact, without its description. */
36
+ export declare const Compact: Story;
37
+ /** Every theme as a chooser: click one to select it. */
38
+ export declare const AllThemes: Story;