@pantoken/astro 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,55 @@
1
+ # @pantoken/astro
2
+
3
+ Astro / Starlight integration for pantoken. `InstUI` is a Starlight plugin that injects the
4
+ Instructure design tokens and icons as CSS into the page head. It ports the approach of
5
+ `starlight-theme-instui` onto the shared `@pantoken/css` pipeline.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ npm i @pantoken/astro
11
+ ```
12
+
13
+ Also available as `pantoken/astro`.
14
+
15
+ ## Usage
16
+
17
+ ```ts
18
+ // astro.config.mjs
19
+ import starlight from "@astrojs/starlight";
20
+ import { InstUI } from "@pantoken/astro";
21
+ import { transition } from "@pantoken/plugin-transition";
22
+
23
+ export default defineConfig({
24
+ integrations: [
25
+ starlight({
26
+ title: "Docs",
27
+ plugins: [InstUI({ theme: "rebrand", plugins: [transition()] })],
28
+ }),
29
+ ],
30
+ });
31
+ ```
32
+
33
+ Or build the stylesheet directly:
34
+
35
+ ```ts
36
+ import { pantokenCss } from "@pantoken/astro";
37
+
38
+ const css = pantokenCss({ theme: "canvas" });
39
+ ```
40
+
41
+ ## API
42
+
43
+ - **`InstUI(options?): StarlightPluginLike`** — create the Starlight plugin that injects the pantoken stylesheet into the page head. Also the default export.
44
+ - **`pantokenCss(options?): string`** — build the pantoken stylesheet for a theme, with optional plugin CSS.
45
+ - **`InstUIOptions`** — options interface: `theme` (default `"rebrand"`) and `plugins` (default none).
46
+ - **`HeadEntry`, `StarlightPluginLike`** — minimal structural types that avoid a hard dependency on Starlight.
47
+
48
+ ## Related
49
+
50
+ - Builds on `@pantoken/css` and `@pantoken/tokens` for the token-to-CSS pipeline.
51
+ - Accepts pantoken plugins such as `@pantoken/plugin-transition`.
52
+
53
+ ## License
54
+
55
+ MIT
@@ -0,0 +1 @@
1
+ .pantoken-prose{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)}.pantoken-prose h1,.pantoken-prose h2,.pantoken-prose h3,.pantoken-prose h4,.pantoken-prose h5,.pantoken-prose 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)}.pantoken-prose h1{font-size:var(--instui-component-heading-h1-font-size);font-weight:var(--instui-component-heading-h1-font-weight)}.pantoken-prose h2{font-size:var(--instui-component-heading-h2-font-size);font-weight:var(--instui-component-heading-h2-font-weight)}.pantoken-prose h3{font-size:var(--instui-component-heading-h3-font-size);font-weight:var(--instui-component-heading-h3-font-weight)}.pantoken-prose h4{font-size:var(--instui-component-heading-h4-font-size);font-weight:var(--instui-component-heading-h4-font-weight)}.pantoken-prose h5{font-size:var(--instui-component-heading-h5-font-size);font-weight:var(--instui-component-heading-h5-font-weight)}.pantoken-prose h6{font-size:var(--instui-component-heading-h6-font-size);font-weight:var(--instui-component-heading-h6-font-weight)}.pantoken-prose p{margin:var(--instui-spacing-space-md) 0}.pantoken-prose a{color:var(--instui-color-text-interactive-navigation-primary-base);text-decoration:underline}.pantoken-prose a:hover{color:var(--instui-color-text-interactive-navigation-primary-hover)}.pantoken-prose strong,.pantoken-prose b{font-weight:var(--instui-component-text-content-important-font-weight)}.pantoken-prose em,.pantoken-prose i{font-style:italic}.pantoken-prose small{font-size:var(--instui-component-text-content-small-font-size)}.pantoken-prose del,.pantoken-prose s{color:var(--instui-color-text-muted);text-decoration:line-through}.pantoken-prose ul,.pantoken-prose ol{margin:var(--instui-spacing-space-md) 0;padding-inline-start:var(--instui-spacing-space-lg)}.pantoken-prose li{margin:var(--instui-spacing-space2xs) 0}.pantoken-prose li.task-list-item{list-style:none}.pantoken-prose input[type=checkbox]{accent-color:var(--instui-color-text-interactive-navigation-primary-base);margin-inline-end:var(--instui-spacing-space-xs)}.pantoken-prose 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)}.pantoken-prose 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}.pantoken-prose 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}.pantoken-prose pre code{font-size:inherit;background:0 0;border-radius:0;padding:0}.pantoken-prose hr{border:none;border-top:var(--instui-border-width-sm) solid var(--instui-color-stroke-base);margin:var(--instui-spacing-space-lg) 0}.pantoken-prose img{border-radius:var(--instui-border-radius-md);max-width:100%}.pantoken-prose 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)}.pantoken-prose 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)}.pantoken-prose 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,72 @@
1
+ import { PantokenPlugin, Theme } from "@pantoken/model";
2
+
3
+ //#region src/index.d.ts
4
+ /** A minimal structural type for a Starlight head entry (avoids a hard dependency on Starlight). */
5
+ interface HeadEntry {
6
+ tag: "style";
7
+ attrs: Record<string, string>;
8
+ content: string;
9
+ }
10
+ /** A minimal structural type for a Starlight plugin. */
11
+ interface StarlightPluginLike {
12
+ name: string;
13
+ hooks: {
14
+ "config:setup"(context: {
15
+ config: {
16
+ head?: HeadEntry[];
17
+ };
18
+ updateConfig(patch: {
19
+ head: HeadEntry[];
20
+ }): void;
21
+ logger?: {
22
+ info(msg: string): void;
23
+ };
24
+ }): void;
25
+ };
26
+ }
27
+ /** Options for {@link InstUI}. */
28
+ interface InstUIOptions {
29
+ /** The theme to emit (default: `"rebrand"`). */
30
+ theme?: Theme;
31
+ /** Plugins whose `css` hooks contribute to the injected stylesheet (default: none). */
32
+ plugins?: readonly PantokenPlugin[];
33
+ }
34
+ /**
35
+ * Build the pantoken stylesheet for a theme (with optional plugin CSS). Exposed for direct use.
36
+ *
37
+ * @param options - {@link InstUIOptions}.
38
+ * @returns The CSS string.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * import { pantokenCss } from "@pantoken/astro";
43
+ *
44
+ * const css = pantokenCss({ theme: "canvas" });
45
+ * ```
46
+ */
47
+ declare function pantokenCss(options?: InstUIOptions): string;
48
+ /**
49
+ * Create the pantoken Starlight plugin.
50
+ *
51
+ * @param options - {@link InstUIOptions}.
52
+ * @returns A Starlight plugin that injects the pantoken stylesheet into the page head.
53
+ *
54
+ * @example astro.config.mjs
55
+ * ```ts
56
+ * import starlight from "@astrojs/starlight";
57
+ * import { InstUI } from "@pantoken/astro";
58
+ * import { transition } from "@pantoken/plugin-transition";
59
+ *
60
+ * export default defineConfig({
61
+ * integrations: [
62
+ * starlight({
63
+ * title: "Docs",
64
+ * plugins: [InstUI({ theme: "rebrand", plugins: [transition()] })],
65
+ * }),
66
+ * ],
67
+ * });
68
+ * ```
69
+ */
70
+ declare function InstUI(options?: InstUIOptions): StarlightPluginLike;
71
+ //#endregion
72
+ export { HeadEntry, InstUI, InstUI as default, InstUIOptions, StarlightPluginLike, pantokenCss };
package/dist/index.mjs ADDED
@@ -0,0 +1,68 @@
1
+ import { toCss } from "@pantoken/css";
2
+ import { byTheme } from "@pantoken/tokens";
3
+ //#region src/index.ts
4
+ /**
5
+ * `@pantoken/astro` — Astro / Starlight integration for pantoken.
6
+ *
7
+ * {@link InstUI} is a Starlight plugin that injects the pantoken stylesheet (and any plugin CSS,
8
+ * e.g. a focus ring) into the page head. It ports the approach of `starlight-theme-instui` onto the
9
+ * shared `@pantoken/css` pipeline, so it no longer carries its own token resolver.
10
+ *
11
+ * @module
12
+ * @alpha
13
+ */
14
+ /**
15
+ * Build the pantoken stylesheet for a theme (with optional plugin CSS). Exposed for direct use.
16
+ *
17
+ * @param options - {@link InstUIOptions}.
18
+ * @returns The CSS string.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * import { pantokenCss } from "@pantoken/astro";
23
+ *
24
+ * const css = pantokenCss({ theme: "canvas" });
25
+ * ```
26
+ */
27
+ function pantokenCss(options = {}) {
28
+ const { theme = "rebrand", plugins = [] } = options;
29
+ return toCss(byTheme(theme), { plugins });
30
+ }
31
+ /**
32
+ * Create the pantoken Starlight plugin.
33
+ *
34
+ * @param options - {@link InstUIOptions}.
35
+ * @returns A Starlight plugin that injects the pantoken stylesheet into the page head.
36
+ *
37
+ * @example astro.config.mjs
38
+ * ```ts
39
+ * import starlight from "@astrojs/starlight";
40
+ * import { InstUI } from "@pantoken/astro";
41
+ * import { transition } from "@pantoken/plugin-transition";
42
+ *
43
+ * export default defineConfig({
44
+ * integrations: [
45
+ * starlight({
46
+ * title: "Docs",
47
+ * plugins: [InstUI({ theme: "rebrand", plugins: [transition()] })],
48
+ * }),
49
+ * ],
50
+ * });
51
+ * ```
52
+ */
53
+ function InstUI(options = {}) {
54
+ const css = pantokenCss(options);
55
+ return {
56
+ name: "@pantoken/astro",
57
+ hooks: { "config:setup": (context) => {
58
+ context.updateConfig({ head: [...context.config.head ?? [], {
59
+ tag: "style",
60
+ attrs: { "data-pantoken": "base" },
61
+ content: css
62
+ }] });
63
+ context.logger?.info(`pantoken: injected ${options.theme ?? "rebrand"} tokens (${css.length} bytes)`);
64
+ } }
65
+ };
66
+ }
67
+ //#endregion
68
+ export { InstUI, InstUI as default, pantokenCss };
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@pantoken/astro",
3
+ "version": "0.1.0",
4
+ "description": "Astro / Starlight integration for pantoken: inject Instructure design tokens and icons as CSS.",
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/css": "0.1.0",
20
+ "@pantoken/model": "0.1.0",
21
+ "@pantoken/tokens": "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
+ "@pantoken/plugin-transition": "0.1.0"
30
+ },
31
+ "pantoken": {
32
+ "key": "astro",
33
+ "kind": "namespace"
34
+ },
35
+ "scripts": {
36
+ "generate": "node scripts/generate.ts",
37
+ "build": "vp run generate && vp pack",
38
+ "dev": "vp run generate && vp pack --watch",
39
+ "test": "vp test",
40
+ "check": "vp check"
41
+ }
42
+ }