@datalayer/primer-addons 1.0.42 → 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.
- package/README.md +6 -2
- package/lib/components/appearance/AppearanceControls.stories.d.ts +45 -0
- package/lib/components/appearance/AppearanceControls.stories.js +91 -0
- package/lib/components/appearance/AppearanceMenu.stories.d.ts +49 -0
- package/lib/components/appearance/AppearanceMenu.stories.js +80 -0
- package/lib/components/appearance/CollaboratorPalette.stories.d.ts +34 -0
- package/lib/components/appearance/CollaboratorPalette.stories.js +59 -0
- package/lib/components/appearance/ColorModeCircle.stories.d.ts +47 -0
- package/lib/components/appearance/ColorModeCircle.stories.js +80 -0
- package/lib/components/appearance/ThemeCircle.stories.d.ts +31 -0
- package/lib/components/appearance/ThemeCircle.stories.js +54 -0
- package/lib/components/appearance/ThemePreviewCard.stories.d.ts +38 -0
- package/lib/components/appearance/ThemePreviewCard.stories.js +72 -0
- package/lib/components/box/Box.stories.d.ts +61 -0
- package/lib/components/box/Box.stories.js +103 -0
- package/lib/components/calendar-picker/CalendarPicker.stories.d.ts +53 -0
- package/lib/components/calendar-picker/CalendarPicker.stories.js +89 -0
- package/lib/components/card/Card.d.ts +40 -0
- package/lib/components/card/Card.js +59 -3
- package/lib/components/card/Card.stories.d.ts +8 -0
- package/lib/components/card/Card.stories.js +17 -1
- package/lib/components/color/ColorSwatch.stories.d.ts +26 -0
- package/lib/components/color/ColorSwatch.stories.js +54 -0
- package/lib/components/color-picker/ColorPicker.stories.d.ts +36 -0
- package/lib/components/color-picker/ColorPicker.stories.js +85 -0
- package/lib/components/date-picker/DatePicker.stories.d.ts +65 -0
- package/lib/components/date-picker/DatePicker.stories.js +110 -0
- package/lib/components/entity-avatar/EntityAvatar.stories.d.ts +47 -0
- package/lib/components/entity-avatar/EntityAvatar.stories.js +81 -0
- package/lib/components/hover-card/HoverCard.js +4 -1
- package/lib/components/hover-card/HoverCard.stories.d.ts +48 -0
- package/lib/components/hover-card/HoverCard.stories.js +98 -0
- package/lib/components/logo/DatalayerLogo.stories.d.ts +37 -0
- package/lib/components/logo/DatalayerLogo.stories.js +58 -0
- package/lib/components/sheet/Sheet.stories.d.ts +25 -0
- package/lib/components/sheet/Sheet.stories.js +32 -0
- package/lib/components/toolbar/Toolbar.stories.d.ts +36 -0
- package/lib/components/toolbar/Toolbar.stories.js +209 -0
- package/lib/story-helpers.d.ts +11 -0
- package/lib/story-helpers.js +19 -1
- package/package.json +1 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Text } from "@primer/react";
|
|
3
|
+
import { DatalayerLogo, DatalayerLogoText, DatalayerText, DatalayerTextAI, themeConfigs, themeVariants, } from "../..";
|
|
4
|
+
const meta = {
|
|
5
|
+
title: "Components/DatalayerLogo",
|
|
6
|
+
component: DatalayerLogo,
|
|
7
|
+
tags: ["autodocs"],
|
|
8
|
+
parameters: {
|
|
9
|
+
layout: "fullscreen",
|
|
10
|
+
},
|
|
11
|
+
argTypes: {
|
|
12
|
+
variant: {
|
|
13
|
+
options: themeVariants,
|
|
14
|
+
control: "select",
|
|
15
|
+
},
|
|
16
|
+
colorMode: {
|
|
17
|
+
options: ["light", "dark", "auto"],
|
|
18
|
+
control: "radio",
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
args: {
|
|
22
|
+
size: 64,
|
|
23
|
+
variant: "datalayer",
|
|
24
|
+
colorMode: "light",
|
|
25
|
+
gradient: false,
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
export default meta;
|
|
29
|
+
/** The square mark, in a theme's colours. */
|
|
30
|
+
export const Logo = {
|
|
31
|
+
render: (args) => (_jsx(Box, { p: 3, bg: "canvas.default", children: _jsx(DatalayerLogo, { ...args }) })),
|
|
32
|
+
};
|
|
33
|
+
/** The mark with gradients. */
|
|
34
|
+
export const Gradient = {
|
|
35
|
+
args: {
|
|
36
|
+
gradient: true,
|
|
37
|
+
variant: "loop",
|
|
38
|
+
},
|
|
39
|
+
render: (args) => (_jsx(Box, { p: 3, bg: "canvas.default", children: _jsx(DatalayerLogo, { ...args }) })),
|
|
40
|
+
};
|
|
41
|
+
/** The mark beside the wordmark, and the wordmark with the AI glyph. */
|
|
42
|
+
export const LogoTextAndTextAI = {
|
|
43
|
+
args: {
|
|
44
|
+
size: 32,
|
|
45
|
+
},
|
|
46
|
+
render: (args) => (_jsxs(Box, { p: 3, bg: "canvas.default", sx: { display: "grid", gap: 4, justifyItems: "start" }, children: [_jsx(DatalayerLogoText, { size: args.size, variant: args.variant, colorMode: args.colorMode }), _jsx(DatalayerLogoText, { size: args.size, variant: args.variant, colorMode: args.colorMode, inverse: true }), _jsx(DatalayerTextAI, { size: args.size, variant: args.variant, colorMode: args.colorMode })] })),
|
|
47
|
+
};
|
|
48
|
+
/** The bare wordmark: an SVG group, placed in an SVG of the host's own. */
|
|
49
|
+
export const Wordmark = {
|
|
50
|
+
render: () => (_jsx(Box, { p: 3, bg: "canvas.default", children: _jsx("svg", { viewBox: "0 0 124.672 25", height: 50, role: "img", "aria-label": "Datalayer", children: _jsx(DatalayerText, { x: -12 }) }) })),
|
|
51
|
+
};
|
|
52
|
+
/** The mark in every theme. */
|
|
53
|
+
export const AllThemes = {
|
|
54
|
+
args: {
|
|
55
|
+
size: 48,
|
|
56
|
+
},
|
|
57
|
+
render: (args) => (_jsx(Box, { p: 3, bg: "canvas.default", sx: { display: "flex", flexWrap: "wrap", gap: 4 }, children: themeVariants.map((variant) => (_jsxs(Box, { sx: { display: "grid", gap: 1, justifyItems: "center" }, children: [_jsx(DatalayerLogo, { size: args.size, variant: variant, colorMode: args.colorMode, gradient: args.gradient }), _jsx(Text, { sx: { fontSize: 0, color: "fg.muted" }, children: themeConfigs[variant].label })] }, variant))) })),
|
|
58
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { StoryObj } from "@storybook/react";
|
|
2
|
+
import { Sheet } from "../..";
|
|
3
|
+
declare const meta: {
|
|
4
|
+
title: string;
|
|
5
|
+
component: typeof Sheet;
|
|
6
|
+
tags: string[];
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: string;
|
|
9
|
+
};
|
|
10
|
+
args: {
|
|
11
|
+
px: (string | number)[];
|
|
12
|
+
py: number;
|
|
13
|
+
maxWidth: number;
|
|
14
|
+
mx: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export default meta;
|
|
18
|
+
type Story = StoryObj<typeof meta>;
|
|
19
|
+
/**
|
|
20
|
+
* A sheet on a quiet canvas — the page the page layout draws, on its own:
|
|
21
|
+
* the canvas colour, its hairline, the theme's card corner and a paper's shadow.
|
|
22
|
+
*/
|
|
23
|
+
export declare const Page: Story;
|
|
24
|
+
/** Three sheets side by side, each padded as its content needs. */
|
|
25
|
+
export declare const SideBySide: Story;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Sheet } from "../..";
|
|
3
|
+
const meta = {
|
|
4
|
+
title: "Components/Sheet",
|
|
5
|
+
component: Sheet,
|
|
6
|
+
tags: ["autodocs"],
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: "fullscreen",
|
|
9
|
+
},
|
|
10
|
+
args: {
|
|
11
|
+
px: [3, 4, "56px"],
|
|
12
|
+
py: 4,
|
|
13
|
+
maxWidth: 640,
|
|
14
|
+
mx: "auto",
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
export default meta;
|
|
18
|
+
/**
|
|
19
|
+
* A sheet on a quiet canvas — the page the page layout draws, on its own:
|
|
20
|
+
* the canvas colour, its hairline, the theme's card corner and a paper's shadow.
|
|
21
|
+
*/
|
|
22
|
+
export const Page = {
|
|
23
|
+
render: (args) => (_jsx(Box, { bg: "canvas.subtle", p: 4, children: _jsxs(Sheet, { ...args, children: [_jsx(Box, { as: "h3", m: 0, mb: 2, fontSize: 3, children: "A page" }), _jsx(Box, { as: "p", m: 0, color: "fg.muted", children: "The canvas colour, its hairline, the theme's card corner and the shadow a sheet of paper has. Its size, padding and layout are yours." })] }) })),
|
|
24
|
+
};
|
|
25
|
+
/** Three sheets side by side, each padded as its content needs. */
|
|
26
|
+
export const SideBySide = {
|
|
27
|
+
args: {
|
|
28
|
+
p: 3,
|
|
29
|
+
minHeight: 120,
|
|
30
|
+
},
|
|
31
|
+
render: (args) => (_jsx(Box, { bg: "canvas.subtle", p: 4, display: "grid", gridTemplateColumns: ["1fr", "repeat(3, 1fr)"], gap: 3, children: ["Notes", "Draft", "Report"].map((name) => (_jsxs(Sheet, { p: args.p, minHeight: args.minHeight, children: [_jsx(Box, { fontWeight: "semibold", children: name }), _jsx(Box, { color: "fg.muted", fontSize: 0, children: "Three sheets side by side, each padded as its content needs." })] }, name))) })),
|
|
32
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { StoryObj } from "@storybook/react";
|
|
2
|
+
import { Toolbar } from "../..";
|
|
3
|
+
declare const meta: {
|
|
4
|
+
title: string;
|
|
5
|
+
component: typeof Toolbar;
|
|
6
|
+
tags: string[];
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: string;
|
|
9
|
+
};
|
|
10
|
+
argTypes: {
|
|
11
|
+
items: {
|
|
12
|
+
control: false;
|
|
13
|
+
};
|
|
14
|
+
extraItems: {
|
|
15
|
+
control: false;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
args: {
|
|
19
|
+
items: never[];
|
|
20
|
+
ariaLabel: string;
|
|
21
|
+
disabled: false;
|
|
22
|
+
overflow: true;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export default meta;
|
|
26
|
+
type Story = StoryObj<typeof meta>;
|
|
27
|
+
/** A formatting toolbar: a block-type dropdown, toggles that stay pressed, dividers. */
|
|
28
|
+
export declare const Default: Story;
|
|
29
|
+
/** Text labels instead of icons. */
|
|
30
|
+
export declare const TextLabels: Story;
|
|
31
|
+
/** In a narrow column: what does not fit moves into the overflow menu. */
|
|
32
|
+
export declare const Overflow: Story;
|
|
33
|
+
/** The whole toolbar disabled. */
|
|
34
|
+
export declare const Disabled: Story;
|
|
35
|
+
/** `FloatingToolbar`: select text in the paragraph and it appears by the selection. */
|
|
36
|
+
export declare const Floating: Story;
|
|
@@ -0,0 +1,209 @@
|
|
|
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 { useRef, useState } from "react";
|
|
7
|
+
import { BoldIcon, CodeIcon, ItalicIcon, LinkIcon, ListOrderedIcon, ListUnorderedIcon, QuoteIcon, StrikethroughIcon, } from "@primer/octicons-react";
|
|
8
|
+
import { Box, Text } from "@primer/react";
|
|
9
|
+
import { FloatingToolbar, Toolbar } from "../..";
|
|
10
|
+
const BLOCK_LABELS = {
|
|
11
|
+
paragraph: "Paragraph",
|
|
12
|
+
heading: "Heading",
|
|
13
|
+
quote: "Quote",
|
|
14
|
+
};
|
|
15
|
+
/** An editor's formatting state, and the toolbar items that change it. */
|
|
16
|
+
const useFormattingItems = () => {
|
|
17
|
+
const [formats, setFormats] = useState({
|
|
18
|
+
bold: false,
|
|
19
|
+
italic: false,
|
|
20
|
+
strikethrough: false,
|
|
21
|
+
code: false,
|
|
22
|
+
});
|
|
23
|
+
const [block, setBlock] = useState("paragraph");
|
|
24
|
+
const toggle = (key) => setFormats((previous) => ({ ...previous, [key]: !previous[key] }));
|
|
25
|
+
const items = [
|
|
26
|
+
{
|
|
27
|
+
key: "block-type",
|
|
28
|
+
type: "dropdown",
|
|
29
|
+
ariaLabel: "Block type",
|
|
30
|
+
label: BLOCK_LABELS[block],
|
|
31
|
+
minWidth: 96,
|
|
32
|
+
options: Object.keys(BLOCK_LABELS).map((key) => ({
|
|
33
|
+
key,
|
|
34
|
+
label: BLOCK_LABELS[key],
|
|
35
|
+
isActive: block === key,
|
|
36
|
+
onClick: () => setBlock(key),
|
|
37
|
+
})),
|
|
38
|
+
},
|
|
39
|
+
{ key: "divider-1", type: "divider" },
|
|
40
|
+
{
|
|
41
|
+
key: "bold",
|
|
42
|
+
type: "button",
|
|
43
|
+
ariaLabel: "Bold",
|
|
44
|
+
title: "Bold",
|
|
45
|
+
icon: BoldIcon,
|
|
46
|
+
shortcut: "⌘B",
|
|
47
|
+
isActive: formats.bold,
|
|
48
|
+
onClick: () => toggle("bold"),
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
key: "italic",
|
|
52
|
+
type: "button",
|
|
53
|
+
ariaLabel: "Italic",
|
|
54
|
+
title: "Italic",
|
|
55
|
+
icon: ItalicIcon,
|
|
56
|
+
shortcut: "⌘I",
|
|
57
|
+
isActive: formats.italic,
|
|
58
|
+
onClick: () => toggle("italic"),
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
key: "strikethrough",
|
|
62
|
+
type: "button",
|
|
63
|
+
ariaLabel: "Strikethrough",
|
|
64
|
+
title: "Strikethrough",
|
|
65
|
+
icon: StrikethroughIcon,
|
|
66
|
+
isActive: formats.strikethrough,
|
|
67
|
+
onClick: () => toggle("strikethrough"),
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
key: "code",
|
|
71
|
+
type: "button",
|
|
72
|
+
ariaLabel: "Inline code",
|
|
73
|
+
title: "Inline code",
|
|
74
|
+
icon: CodeIcon,
|
|
75
|
+
isActive: formats.code,
|
|
76
|
+
onClick: () => toggle("code"),
|
|
77
|
+
},
|
|
78
|
+
{ key: "divider-2", type: "divider" },
|
|
79
|
+
{
|
|
80
|
+
key: "bullets",
|
|
81
|
+
type: "button",
|
|
82
|
+
ariaLabel: "Bulleted list",
|
|
83
|
+
title: "Bulleted list",
|
|
84
|
+
icon: ListUnorderedIcon,
|
|
85
|
+
onClick: () => setBlock("paragraph"),
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
key: "numbers",
|
|
89
|
+
type: "button",
|
|
90
|
+
ariaLabel: "Numbered list",
|
|
91
|
+
title: "Numbered list",
|
|
92
|
+
icon: ListOrderedIcon,
|
|
93
|
+
onClick: () => setBlock("paragraph"),
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
key: "quote",
|
|
97
|
+
type: "button",
|
|
98
|
+
ariaLabel: "Quote",
|
|
99
|
+
title: "Quote",
|
|
100
|
+
icon: QuoteIcon,
|
|
101
|
+
isActive: block === "quote",
|
|
102
|
+
onClick: () => setBlock("quote"),
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
key: "link",
|
|
106
|
+
type: "button",
|
|
107
|
+
ariaLabel: "Insert link",
|
|
108
|
+
title: "Insert link",
|
|
109
|
+
icon: LinkIcon,
|
|
110
|
+
onClick: () => console.log("Insert link"),
|
|
111
|
+
},
|
|
112
|
+
];
|
|
113
|
+
return [items, formats, block];
|
|
114
|
+
};
|
|
115
|
+
const meta = {
|
|
116
|
+
title: "Components/Toolbar",
|
|
117
|
+
component: Toolbar,
|
|
118
|
+
tags: ["autodocs"],
|
|
119
|
+
parameters: {
|
|
120
|
+
layout: "fullscreen",
|
|
121
|
+
},
|
|
122
|
+
argTypes: {
|
|
123
|
+
items: { control: false },
|
|
124
|
+
extraItems: { control: false },
|
|
125
|
+
},
|
|
126
|
+
args: {
|
|
127
|
+
items: [],
|
|
128
|
+
ariaLabel: "Editor toolbar",
|
|
129
|
+
disabled: false,
|
|
130
|
+
overflow: true,
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
export default meta;
|
|
134
|
+
/** A formatting toolbar: a block-type dropdown, toggles that stay pressed, dividers. */
|
|
135
|
+
export const Default = {
|
|
136
|
+
render: function DefaultStory(args) {
|
|
137
|
+
const [items, formats, block] = useFormattingItems();
|
|
138
|
+
return (_jsxs(Box, { p: 3, bg: "canvas.default", children: [_jsx(Toolbar, { ...args, items: items }), _jsxs(Text, { as: "p", sx: { mt: 2, fontSize: 0, color: "fg.muted" }, children: [BLOCK_LABELS[block], ";", " ", Object.entries(formats)
|
|
139
|
+
.filter(([, on]) => on)
|
|
140
|
+
.map(([key]) => key)
|
|
141
|
+
.join(", ") || "no inline format", "."] })] }));
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
/** Text labels instead of icons. */
|
|
145
|
+
export const TextLabels = {
|
|
146
|
+
render: function TextLabelsStory(args) {
|
|
147
|
+
const [bold, setBold] = useState(false);
|
|
148
|
+
const [italic, setItalic] = useState(false);
|
|
149
|
+
const items = [
|
|
150
|
+
{
|
|
151
|
+
key: "bold",
|
|
152
|
+
type: "button",
|
|
153
|
+
ariaLabel: "Bold",
|
|
154
|
+
label: "B",
|
|
155
|
+
isActive: bold,
|
|
156
|
+
onClick: () => setBold((value) => !value),
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
key: "italic",
|
|
160
|
+
type: "button",
|
|
161
|
+
ariaLabel: "Italic",
|
|
162
|
+
label: "I",
|
|
163
|
+
isActive: italic,
|
|
164
|
+
onClick: () => setItalic((value) => !value),
|
|
165
|
+
},
|
|
166
|
+
];
|
|
167
|
+
return (_jsx(Box, { p: 3, bg: "canvas.default", children: _jsx(Toolbar, { ...args, items: items }) }));
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
/** In a narrow column: what does not fit moves into the overflow menu. */
|
|
171
|
+
export const Overflow = {
|
|
172
|
+
render: function OverflowStory(args) {
|
|
173
|
+
const [items] = useFormattingItems();
|
|
174
|
+
return (_jsx(Box, { p: 3, bg: "canvas.default", children: _jsx(Box, { sx: {
|
|
175
|
+
width: 240,
|
|
176
|
+
border: "1px dashed",
|
|
177
|
+
borderColor: "border.default",
|
|
178
|
+
}, children: _jsx(Toolbar, { ...args, items: items }) }) }));
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
/** The whole toolbar disabled. */
|
|
182
|
+
export const Disabled = {
|
|
183
|
+
args: {
|
|
184
|
+
disabled: true,
|
|
185
|
+
},
|
|
186
|
+
render: function DisabledStory(args) {
|
|
187
|
+
const [items] = useFormattingItems();
|
|
188
|
+
return (_jsx(Box, { p: 3, bg: "canvas.default", children: _jsx(Toolbar, { ...args, items: items }) }));
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
/** `FloatingToolbar`: select text in the paragraph and it appears by the selection. */
|
|
192
|
+
export const Floating = {
|
|
193
|
+
render: function FloatingStory(args) {
|
|
194
|
+
const [items] = useFormattingItems();
|
|
195
|
+
const [visible, setVisible] = useState(false);
|
|
196
|
+
const anchorRef = useRef(null);
|
|
197
|
+
const onSelectionChange = () => {
|
|
198
|
+
const selection = window.getSelection();
|
|
199
|
+
setVisible(Boolean(selection && !selection.isCollapsed));
|
|
200
|
+
};
|
|
201
|
+
return (_jsxs(Box, { p: 3, bg: "canvas.default", minHeight: 240, children: [_jsx(Text, { as: "p", sx: { mb: 2, fontSize: 0, color: "fg.muted" }, children: "Select a few words below." }), _jsxs("div", { ref: anchorRef, style: { position: "relative", paddingTop: 56 }, children: [_jsx(Box, { contentEditable: true, suppressContentEditableWarning: true, onMouseUp: onSelectionChange, onKeyUp: onSelectionChange, sx: {
|
|
202
|
+
p: 3,
|
|
203
|
+
border: "1px solid",
|
|
204
|
+
borderColor: "border.default",
|
|
205
|
+
borderRadius: 2,
|
|
206
|
+
maxWidth: 560,
|
|
207
|
+
}, children: "The floating toolbar suits inline editing: select a few words in this paragraph and it appears near the selection, then goes when the selection collapses." }), _jsx(FloatingToolbar, { anchorElement: anchorRef.current, isVisible: visible, items: items, ariaLabel: args.ariaLabel, disabled: args.disabled, onClose: () => setVisible(false) })] })] }));
|
|
208
|
+
},
|
|
209
|
+
};
|
package/lib/story-helpers.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { Icon } from '@primer/octicons-react';
|
|
|
4
4
|
type StoryContext = Record<string, unknown> & {
|
|
5
5
|
globals: {
|
|
6
6
|
colorScheme: string;
|
|
7
|
+
themeVariant?: string;
|
|
7
8
|
};
|
|
8
9
|
parameters: Record<string, unknown>;
|
|
9
10
|
};
|
|
@@ -20,6 +21,16 @@ export declare const toolbarTypes: {
|
|
|
20
21
|
title: string;
|
|
21
22
|
};
|
|
22
23
|
};
|
|
24
|
+
themeVariant: {
|
|
25
|
+
name: string;
|
|
26
|
+
description: string;
|
|
27
|
+
defaultValue: string;
|
|
28
|
+
toolbar: {
|
|
29
|
+
icon: string;
|
|
30
|
+
items: string[];
|
|
31
|
+
title: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
23
34
|
};
|
|
24
35
|
export declare const inputWrapperArgTypes: ArgTypes;
|
|
25
36
|
export declare const getTextInputArgTypes: (category?: string) => Record<string, unknown>;
|
package/lib/story-helpers.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { createGlobalStyle } from 'styled-components';
|
|
3
3
|
import { ThemeProvider, themeGet, BaseStyles, theme } from '@primer/react';
|
|
4
|
+
import { DatalayerThemeProvider } from './theme/DatalayerThemeProvider';
|
|
5
|
+
import { themeConfigs, themeVariants, } from './theme/themeRegistry';
|
|
4
6
|
// set global theme styles for each story
|
|
5
7
|
const GlobalStyle = createGlobalStyle `
|
|
6
8
|
body,
|
|
@@ -16,7 +18,13 @@ export const withThemeProvider = (Story, context) => {
|
|
|
16
18
|
// used for testing ThemeProvider.stories.tsx
|
|
17
19
|
if (context.parameters.disableThemeDecorator)
|
|
18
20
|
return Story(context);
|
|
19
|
-
const { colorScheme } = context.globals;
|
|
21
|
+
const { colorScheme, themeVariant } = context.globals;
|
|
22
|
+
// One of the package's themes: the provider applications use, so the
|
|
23
|
+
// story wears that theme's tokens (its corners, hairlines, palette).
|
|
24
|
+
if (themeVariant && themeVariant !== 'primer') {
|
|
25
|
+
const config = themeConfigs[themeVariant];
|
|
26
|
+
return (_jsx(DatalayerThemeProvider, { colorMode: colormodeFromScheme(colorScheme), theme: config.primerTheme, themeStyles: config.themeStyles, children: _jsx("div", { id: "html-addon-root", children: Story(context) }) }));
|
|
27
|
+
}
|
|
20
28
|
return (_jsxs(ThemeProvider, { theme: theme, colorMode: colormodeFromScheme(colorScheme), dayScheme: colorScheme, nightScheme: colorScheme, children: [colorScheme.startsWith('light') ? (_jsx(GlobalStyle, { "$lightTheme": true })) : (_jsx(GlobalStyle, {})), _jsx(BaseStyles, { children: _jsx("div", { id: "html-addon-root", children: Story(context) }) })] }));
|
|
21
29
|
};
|
|
22
30
|
export const toolbarTypes = {
|
|
@@ -30,6 +38,16 @@ export const toolbarTypes = {
|
|
|
30
38
|
title: 'Color Scheme',
|
|
31
39
|
},
|
|
32
40
|
},
|
|
41
|
+
themeVariant: {
|
|
42
|
+
name: 'Theme',
|
|
43
|
+
description: "The package's theme the story is drawn in, or plain Primer",
|
|
44
|
+
defaultValue: 'datalayer',
|
|
45
|
+
toolbar: {
|
|
46
|
+
icon: 'paintbrush',
|
|
47
|
+
items: ['primer', ...themeVariants],
|
|
48
|
+
title: 'Theme',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
33
51
|
};
|
|
34
52
|
export const inputWrapperArgTypes = {
|
|
35
53
|
block: {
|