@pantoken/storybook 0.1.0

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 ADDED
@@ -0,0 +1,39 @@
1
+ # @pantoken/storybook
2
+
3
+ A Storybook theme built from Instructure tokens. It maps the token IR onto a Storybook `ThemeVars`
4
+ object with colors resolved concretely, so your Storybook manager and preview pick up the
5
+ Instructure look.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ npm i @pantoken/storybook
11
+ ```
12
+
13
+ `@storybook/theming` is an optional peer — this package returns a plain object, so you don't need it
14
+ installed to build a theme.
15
+
16
+ Also available as `pantoken/storybook`.
17
+
18
+ ## Usage
19
+
20
+ ```ts
21
+ // .storybook/manager.ts
22
+ import { addons } from "@storybook/manager-api";
23
+ import { pantokenStorybookTheme } from "@pantoken/storybook";
24
+
25
+ addons.setConfig({ theme: pantokenStorybookTheme("light") });
26
+ ```
27
+
28
+ Pass `"dark"` for the dark palette. The result is a plain `ThemeVars`-shaped object with colors
29
+ resolved to concrete values.
30
+
31
+ ## API
32
+
33
+ - **`pantokenStorybookTheme(mode?): StorybookTheme`** — build a Storybook theme from the Instructure
34
+ tokens. `mode` is `"light"` or `"dark"` (default `"light"`).
35
+ - **`StorybookTheme`** — the returned object type (a subset of Storybook's `ThemeVars`).
36
+
37
+ ## License
38
+
39
+ MIT
@@ -0,0 +1 @@
1
+ .sbdocs-content{color:var(--instui-component-text-base-color);font-family:var(--instui-component-text-content-font-family);font-size:var(--instui-component-text-content-font-size);font-weight:var(--instui-component-text-content-font-weight);line-height:var(--instui-component-text-content-line-height)}.sbdocs-content h1,.sbdocs-content h2,.sbdocs-content h3,.sbdocs-content h4,.sbdocs-content h5,.sbdocs-content h6{color:var(--instui-component-heading-base-color);font-family:var(--instui-component-heading-h1-font-family);line-height:var(--instui-component-heading-line-height);margin:var(--instui-spacing-space-lg) 0 var(--instui-spacing-space-sm)}.sbdocs-content h1{font-size:var(--instui-component-heading-h1-font-size);font-weight:var(--instui-component-heading-h1-font-weight)}.sbdocs-content h2{font-size:var(--instui-component-heading-h2-font-size);font-weight:var(--instui-component-heading-h2-font-weight)}.sbdocs-content h3{font-size:var(--instui-component-heading-h3-font-size);font-weight:var(--instui-component-heading-h3-font-weight)}.sbdocs-content h4{font-size:var(--instui-component-heading-h4-font-size);font-weight:var(--instui-component-heading-h4-font-weight)}.sbdocs-content h5{font-size:var(--instui-component-heading-h5-font-size);font-weight:var(--instui-component-heading-h5-font-weight)}.sbdocs-content h6{font-size:var(--instui-component-heading-h6-font-size);font-weight:var(--instui-component-heading-h6-font-weight)}.sbdocs-content p{margin:var(--instui-spacing-space-md) 0}.sbdocs-content a{color:var(--instui-color-text-interactive-navigation-primary-base);text-decoration:underline}.sbdocs-content a:hover{color:var(--instui-color-text-interactive-navigation-primary-hover)}.sbdocs-content strong,.sbdocs-content b{font-weight:var(--instui-component-text-content-important-font-weight)}.sbdocs-content em,.sbdocs-content i{font-style:italic}.sbdocs-content small{font-size:var(--instui-component-text-content-small-font-size)}.sbdocs-content del,.sbdocs-content s{color:var(--instui-color-text-muted);text-decoration:line-through}.sbdocs-content ul,.sbdocs-content ol{margin:var(--instui-spacing-space-md) 0;padding-inline-start:var(--instui-spacing-space-lg)}.sbdocs-content li{margin:var(--instui-spacing-space2xs) 0}.sbdocs-content li.task-list-item{list-style:none}.sbdocs-content input[type=checkbox]{accent-color:var(--instui-color-text-interactive-navigation-primary-base);margin-inline-end:var(--instui-spacing-space-xs)}.sbdocs-content blockquote{margin:var(--instui-spacing-space-md) 0;border-inline-start:var(--instui-border-width-lg) solid var(--instui-color-stroke-base);color:var(--instui-component-text-base-color);font-size:var(--instui-component-text-content-quote-font-size);line-height:var(--instui-component-text-content-quote-line-height);padding-inline-start:var(--instui-spacing-space-md)}.sbdocs-content code{font-family:var(--instui-font-family-code);background:var(--instui-color-background-muted);padding:var(--instui-spacing-space2xs) var(--instui-spacing-space-xs);border-radius:var(--instui-border-radius-sm);font-size:.9em}.sbdocs-content pre{font-family:var(--instui-font-family-code);background:var(--instui-color-background-container);color:var(--instui-color-text-base);padding:var(--instui-spacing-space-md);border:var(--instui-border-width-sm) solid var(--instui-color-stroke-base);border-radius:var(--instui-border-radius-md);overflow-x:auto}.sbdocs-content pre code{font-size:inherit;background:0 0;border-radius:0;padding:0}.sbdocs-content hr{border:none;border-top:var(--instui-border-width-sm) solid var(--instui-color-stroke-base);margin:var(--instui-spacing-space-lg) 0}.sbdocs-content img{border-radius:var(--instui-border-radius-md);max-width:100%}.sbdocs-content table:not([class]){border-collapse:collapse;width:100%;margin:var(--instui-spacing-space-md) 0;background:var(--instui-component-table-background);color:var(--instui-component-table-color);font-family:var(--instui-component-table-font-family);font-size:var(--instui-component-table-font-size)}.sbdocs-content table:not([class]) th{text-align:start;background:var(--instui-component-table-col-header-background);color:var(--instui-component-table-col-header-color);font-weight:var(--instui-component-table-head-font-weight);padding:var(--instui-component-table-col-header-padding-vertical) var(--instui-component-table-col-header-padding-horizontal);border-bottom:var(--instui-border-width-md) solid var(--instui-component-table-row-border-color)}.sbdocs-content table:not([class]) td{color:var(--instui-component-table-cell-color);line-height:var(--instui-component-table-cell-line-height);padding:var(--instui-component-table-cell-padding-vertical) var(--instui-component-table-cell-padding-horizontal);border-bottom:var(--instui-border-width-sm) solid var(--instui-component-table-row-border-color)}
@@ -0,0 +1,25 @@
1
+ import { Mode } from "@pantoken/utils";
2
+
3
+ //#region src/index.d.ts
4
+ /** A Storybook theme object (a subset of `ThemeVars`). */
5
+ type StorybookTheme = {
6
+ base: Mode;
7
+ } & Record<string, string>;
8
+ /**
9
+ * Build a Storybook theme from the Instructure tokens.
10
+ *
11
+ * @param mode - `"light"` or `"dark"` (default `"light"`).
12
+ * @returns A `ThemeVars`-shaped object.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * // .storybook/manager.ts
17
+ * import { addons } from "@storybook/manager-api";
18
+ * import { pantokenStorybookTheme } from "@pantoken/storybook";
19
+ *
20
+ * addons.setConfig({ theme: pantokenStorybookTheme("dark") });
21
+ * ```
22
+ */
23
+ declare function pantokenStorybookTheme(mode?: Mode): StorybookTheme;
24
+ //#endregion
25
+ export { StorybookTheme, pantokenStorybookTheme as default, pantokenStorybookTheme };
package/dist/index.mjs ADDED
@@ -0,0 +1,57 @@
1
+ import { resolveTokens } from "@pantoken/utils";
2
+ import { tokens } from "@pantoken/tokens";
3
+ //#region src/index.ts
4
+ /**
5
+ * `@pantoken/storybook` — a Storybook theme built from Instructure tokens.
6
+ *
7
+ * {@link pantokenStorybookTheme} returns a plain `ThemeVars`-shaped object (so `@storybook/theming`
8
+ * stays an optional peer) with colours resolved concretely from the IR. Pass it to Storybook's
9
+ * `manager`/`preview` theme.
10
+ *
11
+ * @module
12
+ * @experimental
13
+ */
14
+ /** Storybook ThemeVars key → the Instructure token it draws from. */
15
+ const THEME_MAP = {
16
+ colorPrimary: "--instui-color-background-brand",
17
+ colorSecondary: "--instui-color-background-info",
18
+ appBg: "--instui-color-background-base",
19
+ appContentBg: "--instui-color-background-container",
20
+ appBorderColor: "--instui-color-stroke-base",
21
+ textColor: "--instui-color-text-base",
22
+ textInverseColor: "--instui-color-text-inverse",
23
+ barBg: "--instui-color-background-brand",
24
+ barTextColor: "--instui-color-text-on-color",
25
+ inputBg: "--instui-color-background-base",
26
+ inputBorder: "--instui-color-stroke-base",
27
+ inputTextColor: "--instui-color-text-base"
28
+ };
29
+ /**
30
+ * Build a Storybook theme from the Instructure tokens.
31
+ *
32
+ * @param mode - `"light"` or `"dark"` (default `"light"`).
33
+ * @returns A `ThemeVars`-shaped object.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * // .storybook/manager.ts
38
+ * import { addons } from "@storybook/manager-api";
39
+ * import { pantokenStorybookTheme } from "@pantoken/storybook";
40
+ *
41
+ * addons.setConfig({ theme: pantokenStorybookTheme("dark") });
42
+ * ```
43
+ */
44
+ function pantokenStorybookTheme(mode = "light") {
45
+ const resolved = resolveTokens(tokens, { mode });
46
+ const theme = {
47
+ base: mode,
48
+ brandTitle: "Instructure"
49
+ };
50
+ for (const [key, instui] of Object.entries(THEME_MAP)) {
51
+ const value = resolved.get(instui);
52
+ if (value) theme[key] = value;
53
+ }
54
+ return theme;
55
+ }
56
+ //#endregion
57
+ export { pantokenStorybookTheme as default, pantokenStorybookTheme };
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@pantoken/storybook",
3
+ "version": "0.1.0",
4
+ "description": "A Storybook theme built from Instructure tokens (maps to Storybook ThemeVars).",
5
+ "license": "MIT",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "type": "module",
10
+ "exports": {
11
+ ".": "./dist/index.mjs",
12
+ "./components.css": "./dist/components.css",
13
+ "./package.json": "./package.json"
14
+ },
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "dependencies": {
19
+ "@pantoken/tokens": "0.1.0",
20
+ "@pantoken/utils": "0.1.0",
21
+ "@pantoken/model": "0.1.0"
22
+ },
23
+ "devDependencies": {
24
+ "@types/node": "^24.13.3",
25
+ "typescript": "^6.0.3",
26
+ "vite": "npm:@voidzero-dev/vite-plus-core@0.2.4",
27
+ "vite-plus": "0.2.4",
28
+ "@pantoken/components": "0.1.0"
29
+ },
30
+ "peerDependencies": {
31
+ "@storybook/theming": ">=7"
32
+ },
33
+ "peerDependenciesMeta": {
34
+ "@storybook/theming": {
35
+ "optional": true
36
+ }
37
+ },
38
+ "pantoken": {
39
+ "key": "storybook",
40
+ "kind": "subpath"
41
+ },
42
+ "scripts": {
43
+ "generate": "node scripts/generate.ts",
44
+ "build": "vp run generate && vp pack",
45
+ "dev": "vp run generate && vp pack --watch",
46
+ "test": "vp test",
47
+ "check": "vp check"
48
+ }
49
+ }