@pantoken/vitepress 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,56 @@
1
+ # @pantoken/vitepress
2
+
3
+ Theme a VitePress site with Instructure tokens. VitePress theming is driven by `--vp-*` CSS
4
+ variables; this points them at `var(--instui-*)`, so the docs pick up the Instructure look and stay
5
+ in sync with the appearance toggle.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ npm i @pantoken/vitepress @pantoken/css
11
+ ```
12
+
13
+ Also available as `pantoken/vitepress`.
14
+
15
+ ## Usage
16
+
17
+ Register a theme CSS file (`.vitepress/theme/custom.css`) from your theme's `index.ts`, and import
18
+ both the token layer and the bridge:
19
+
20
+ ```css
21
+ /* .vitepress/theme/custom.css */
22
+ @import "@pantoken/css/style.css"; /* defines the --instui-* custom properties */
23
+ @import "@pantoken/vitepress/custom.css"; /* maps VitePress --vp-* → var(--instui-*) */
24
+ ```
25
+
26
+ Or generate the bridge yourself:
27
+
28
+ ```ts
29
+ import { toVitePressCss } from "@pantoken/vitepress";
30
+
31
+ const css = toVitePressCss();
32
+ ```
33
+
34
+ Light and dark flow through the `--instui-*` tokens (which use `light-dark()`), so VitePress's
35
+ appearance toggle stays in sync. VitePress uses `--vp-c-brand-1/2/3` for accent, hover, and solid
36
+ states; this bridge points them all at the brand color, so override individual shades in your
37
+ `custom.css` for distinct states. Because the values are `var(--instui-*)` references, `@pantoken/css`
38
+ must be present to define them.
39
+
40
+ ## API
41
+
42
+ - **`toVitePressCss(options?): string`** — emit the VitePress → Instructure bridge CSS. Pass
43
+ `{ selector }` to change the wrapping selector (default `":root"`).
44
+ - **`vitePressCss: string`** — the ready-made bridge stylesheet.
45
+ - **`VITEPRESS_TO_INSTUI`** — the frozen map of VitePress CSS variable to the Instructure token it
46
+ resolves to.
47
+ - **`ToVitePressCssOptions`** — options type for `toVitePressCss`.
48
+ - **`./custom.css`** — the generated static bridge stylesheet, for `@import` from your `custom.css`.
49
+
50
+ ## Related
51
+
52
+ - Pairs with `@pantoken/css` for the `--instui-*` custom properties the bridge points at.
53
+
54
+ ## License
55
+
56
+ MIT
@@ -0,0 +1 @@
1
+ .vp-doc{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)}.vp-doc h1,.vp-doc h2,.vp-doc h3,.vp-doc h4,.vp-doc h5,.vp-doc 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)}.vp-doc h1{font-size:var(--instui-component-heading-h1-font-size);font-weight:var(--instui-component-heading-h1-font-weight)}.vp-doc h2{font-size:var(--instui-component-heading-h2-font-size);font-weight:var(--instui-component-heading-h2-font-weight)}.vp-doc h3{font-size:var(--instui-component-heading-h3-font-size);font-weight:var(--instui-component-heading-h3-font-weight)}.vp-doc h4{font-size:var(--instui-component-heading-h4-font-size);font-weight:var(--instui-component-heading-h4-font-weight)}.vp-doc h5{font-size:var(--instui-component-heading-h5-font-size);font-weight:var(--instui-component-heading-h5-font-weight)}.vp-doc h6{font-size:var(--instui-component-heading-h6-font-size);font-weight:var(--instui-component-heading-h6-font-weight)}.vp-doc p{margin:var(--instui-spacing-space-md) 0}.vp-doc a{color:var(--instui-color-text-interactive-navigation-primary-base);text-decoration:underline}.vp-doc a:hover{color:var(--instui-color-text-interactive-navigation-primary-hover)}.vp-doc strong,.vp-doc b{font-weight:var(--instui-component-text-content-important-font-weight)}.vp-doc em,.vp-doc i{font-style:italic}.vp-doc small{font-size:var(--instui-component-text-content-small-font-size)}.vp-doc del,.vp-doc s{color:var(--instui-color-text-muted);text-decoration:line-through}.vp-doc ul,.vp-doc ol{margin:var(--instui-spacing-space-md) 0;padding-inline-start:var(--instui-spacing-space-lg)}.vp-doc li{margin:var(--instui-spacing-space2xs) 0}.vp-doc li.task-list-item{list-style:none}.vp-doc input[type=checkbox]{accent-color:var(--instui-color-text-interactive-navigation-primary-base);margin-inline-end:var(--instui-spacing-space-xs)}.vp-doc 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)}.vp-doc 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}.vp-doc 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}.vp-doc pre code{font-size:inherit;background:0 0;border-radius:0;padding:0}.vp-doc hr{border:none;border-top:var(--instui-border-width-sm) solid var(--instui-color-stroke-base);margin:var(--instui-spacing-space-lg) 0}.vp-doc img{border-radius:var(--instui-border-radius-md);max-width:100%}.vp-doc 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)}.vp-doc 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)}.vp-doc 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 @@
1
+ :root{--vp-c-bg:var(--instui-color-background-base);--vp-c-bg-alt:var(--instui-color-background-container);--vp-c-bg-soft:var(--instui-color-background-muted);--vp-c-text-1:var(--instui-color-text-base);--vp-c-text-2:var(--instui-color-text-muted);--vp-c-brand-1:var(--instui-color-text-interactive-navigation-primary-base);--vp-c-brand-2:var(--instui-color-text-interactive-navigation-primary-hover);--vp-c-brand-3:var(--instui-color-background-info);--vp-c-border:var(--instui-color-stroke-base);--vp-c-divider:var(--instui-color-stroke-base);--vp-c-gutter:var(--instui-color-stroke-base);--vp-c-success-1:var(--instui-color-background-success);--vp-c-warning-1:var(--instui-color-background-warning);--vp-c-danger-1:var(--instui-color-background-error)}
@@ -0,0 +1,39 @@
1
+ //#region src/index.d.ts
2
+ /**
3
+ * `@pantoken/vitepress` — theme a VitePress site with Instructure tokens.
4
+ *
5
+ * VitePress theming is driven by `--vp-*` CSS variables. This points them at `var(--instui-*)`, so
6
+ * dropping the output into `.vitepress/theme/custom.css` (alongside `@pantoken/css`, which defines
7
+ * the custom properties) re-skins the docs with the Instructure look while light/dark keeps flowing
8
+ * through the same tokens.
9
+ *
10
+ * @module
11
+ * @beta
12
+ */
13
+ /** VitePress CSS variable → the Instructure token it resolves to. */
14
+ declare const VITEPRESS_TO_INSTUI: Readonly<Record<string, string>>;
15
+ /** Options for {@link toVitePressCss}. */
16
+ interface ToVitePressCssOptions {
17
+ /** The selector the variables are emitted under (default `":root"`). */
18
+ selector?: string;
19
+ }
20
+ /**
21
+ * Emit the VitePress → Instructure CSS-variable bridge.
22
+ *
23
+ * @param options - {@link ToVitePressCssOptions}.
24
+ * @returns The bridging CSS string.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * import { toVitePressCss } from "@pantoken/vitepress";
29
+ *
30
+ * const css = toVitePressCss();
31
+ * // ":root { --vp-c-bg: var(--instui-color-background-base); … }"
32
+ * // Write it into .vitepress/theme/custom.css alongside @pantoken/css.
33
+ * ```
34
+ */
35
+ declare function toVitePressCss(options?: ToVitePressCssOptions): string;
36
+ /** The ready-made bridge stylesheet. */
37
+ declare const vitePressCss: string;
38
+ //#endregion
39
+ export { ToVitePressCssOptions, VITEPRESS_TO_INSTUI, vitePressCss as default, vitePressCss, toVitePressCss };
package/dist/index.mjs ADDED
@@ -0,0 +1,51 @@
1
+ //#region src/index.ts
2
+ /**
3
+ * `@pantoken/vitepress` — theme a VitePress site with Instructure tokens.
4
+ *
5
+ * VitePress theming is driven by `--vp-*` CSS variables. This points them at `var(--instui-*)`, so
6
+ * dropping the output into `.vitepress/theme/custom.css` (alongside `@pantoken/css`, which defines
7
+ * the custom properties) re-skins the docs with the Instructure look while light/dark keeps flowing
8
+ * through the same tokens.
9
+ *
10
+ * @module
11
+ * @beta
12
+ */
13
+ /** VitePress CSS variable → the Instructure token it resolves to. */
14
+ const VITEPRESS_TO_INSTUI = Object.freeze({
15
+ "--vp-c-bg": "--instui-color-background-base",
16
+ "--vp-c-bg-alt": "--instui-color-background-container",
17
+ "--vp-c-bg-soft": "--instui-color-background-muted",
18
+ "--vp-c-text-1": "--instui-color-text-base",
19
+ "--vp-c-text-2": "--instui-color-text-muted",
20
+ "--vp-c-brand-1": "--instui-color-text-interactive-navigation-primary-base",
21
+ "--vp-c-brand-2": "--instui-color-text-interactive-navigation-primary-hover",
22
+ "--vp-c-brand-3": "--instui-color-background-info",
23
+ "--vp-c-border": "--instui-color-stroke-base",
24
+ "--vp-c-divider": "--instui-color-stroke-base",
25
+ "--vp-c-gutter": "--instui-color-stroke-base",
26
+ "--vp-c-success-1": "--instui-color-background-success",
27
+ "--vp-c-warning-1": "--instui-color-background-warning",
28
+ "--vp-c-danger-1": "--instui-color-background-error"
29
+ });
30
+ /**
31
+ * Emit the VitePress → Instructure CSS-variable bridge.
32
+ *
33
+ * @param options - {@link ToVitePressCssOptions}.
34
+ * @returns The bridging CSS string.
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * import { toVitePressCss } from "@pantoken/vitepress";
39
+ *
40
+ * const css = toVitePressCss();
41
+ * // ":root { --vp-c-bg: var(--instui-color-background-base); … }"
42
+ * // Write it into .vitepress/theme/custom.css alongside @pantoken/css.
43
+ * ```
44
+ */
45
+ function toVitePressCss(options = {}) {
46
+ return `/* VitePress themed with Instructure tokens (pantoken) */\n${options.selector ?? ":root"} {\n${Object.entries(VITEPRESS_TO_INSTUI).map(([vp, instui]) => ` ${vp}: var(${instui});`).join("\n")}\n}\n`;
47
+ }
48
+ /** The ready-made bridge stylesheet. */
49
+ const vitePressCss = toVitePressCss();
50
+ //#endregion
51
+ export { VITEPRESS_TO_INSTUI, vitePressCss as default, vitePressCss, toVitePressCss };
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@pantoken/vitepress",
3
+ "version": "0.1.0",
4
+ "description": "Theme a VitePress site with Instructure tokens: maps VitePress --vp-* CSS variables to var(--instui-*).",
5
+ "license": "MIT",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "type": "module",
10
+ "exports": {
11
+ ".": "./dist/index.mjs",
12
+ "./custom.css": "./dist/custom.css",
13
+ "./components.css": "./dist/components.css",
14
+ "./package.json": "./package.json"
15
+ },
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "devDependencies": {
20
+ "@types/node": "^24.13.3",
21
+ "typescript": "^6.0.3",
22
+ "vite": "npm:@voidzero-dev/vite-plus-core@0.2.4",
23
+ "vite-plus": "0.2.4",
24
+ "@pantoken/components": "0.1.0",
25
+ "@pantoken/tokens": "0.1.0",
26
+ "@pantoken/utils": "0.1.0"
27
+ },
28
+ "pantoken": {
29
+ "key": "vitepress",
30
+ "kind": "namespace"
31
+ },
32
+ "scripts": {
33
+ "generate": "node scripts/generate.ts",
34
+ "build": "vp run generate && vp pack",
35
+ "dev": "vp run generate && vp pack --watch",
36
+ "test": "vp test",
37
+ "check": "vp check"
38
+ }
39
+ }