@pantoken/mintlify 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,38 @@
1
+ # @pantoken/mintlify
2
+
3
+ Theme a [Mintlify](https://mintlify.com) docs site with Instructure tokens. Mintlify reads concrete
4
+ hex from its `docs.json` at build, so this renderer resolves the tokens to per-mode values (like the
5
+ MUI renderer) rather than shipping a CSS-variable bridge.
6
+
7
+ ## What it maps
8
+
9
+ | Mintlify `docs.json` key | Instructure token | Notes |
10
+ | ------------------------ | ------------------------------------------------------------------- | ------------------------- |
11
+ | `colors.primary` | `--instui-color-background-brand` (light) | Emphasis in light mode. |
12
+ | `colors.light` | `--instui-color-background-brand` (dark) | Emphasis in dark mode. |
13
+ | `colors.dark` | `--instui-color-background-interactive-action-primary-base` (light) | Buttons and hover states. |
14
+ | `background.color.light` | `--instui-color-background-page` (light) | Page surface, light mode. |
15
+ | `background.color.dark` | `--instui-color-background-page` (dark) | Page surface, dark mode. |
16
+
17
+ ## Usage
18
+
19
+ Import the ready-made `rebrand` fragment and merge it into your `docs.json`:
20
+
21
+ ```ts
22
+ import { docsJson } from "@pantoken/mintlify";
23
+ // { colors: { primary, light, dark }, background: { color: { light, dark } } }
24
+ ```
25
+
26
+ Or grab the generated file at `@pantoken/mintlify/docs.json` and merge its keys into your own
27
+ `docs.json`. For a different IR, call `toMintlifyConfig(tokens)`.
28
+
29
+ A `docs.json` with the theming keys merged in:
30
+
31
+ ```json
32
+ {
33
+ "name": "My docs",
34
+ "theme": "mint",
35
+ "colors": { "primary": "#1D354F", "light": "#EEF4FD", "dark": "#1D354F" },
36
+ "background": { "color": { "light": "#F2F4F5", "dark": "#10141A" } }
37
+ }
38
+ ```
@@ -0,0 +1,47 @@
1
+ import { Token } from "@pantoken/model";
2
+
3
+ //#region src/to-mintlify.d.ts
4
+ /** Mintlify `colors` (docs.json): `primary` is required; `light`/`dark` tune emphasis per mode. */
5
+ interface MintlifyColors {
6
+ /** Emphasis colour in light mode. */
7
+ primary: string;
8
+ /** Emphasis colour in dark mode. */
9
+ light: string;
10
+ /** Buttons and hover states across both modes. */
11
+ dark: string;
12
+ }
13
+ /** Mintlify `background.color` (docs.json): the page surface per mode. */
14
+ interface MintlifyBackground {
15
+ color: {
16
+ light: string;
17
+ dark: string;
18
+ };
19
+ }
20
+ /** The subset of a Mintlify `docs.json` this renderer emits — merge it into your own `docs.json`. */
21
+ interface MintlifyTheme {
22
+ colors: MintlifyColors;
23
+ background: MintlifyBackground;
24
+ }
25
+ /**
26
+ * Build the Mintlify `docs.json` theming keys from a token IR.
27
+ *
28
+ * @param tokens - The IR (e.g. from `@pantoken/tokens`).
29
+ * @returns The `colors` + `background` keys to merge into a Mintlify `docs.json`.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * import { toMintlifyConfig } from "@pantoken/mintlify";
34
+ * import { tokens } from "@pantoken/tokens";
35
+ *
36
+ * const theme = toMintlifyConfig(tokens);
37
+ * // { colors: { primary: "#1D354F", light: "#EEF4FD", dark: "#1D354F" },
38
+ * // background: { color: { light: "#F2F4F5", dark: "#10141A" } } }
39
+ * ```
40
+ */
41
+ declare function toMintlifyConfig(tokens: readonly Token[]): MintlifyTheme;
42
+ //#endregion
43
+ //#region src/index.d.ts
44
+ /** Ready-made `rebrand` Mintlify `docs.json` theming keys (colors + background). */
45
+ declare const docsJson: MintlifyTheme;
46
+ //#endregion
47
+ export { type MintlifyBackground, type MintlifyColors, type MintlifyTheme, docsJson as default, docsJson, toMintlifyConfig };
package/dist/index.mjs ADDED
@@ -0,0 +1,74 @@
1
+ import { tokens } from "@pantoken/tokens";
2
+ import { resolveTokens } from "@pantoken/utils";
3
+ //#region src/to-mintlify.ts
4
+ /**
5
+ * Map the pantoken IR onto a Mintlify `docs.json` theming fragment. Mintlify is Tailwind-based and
6
+ * reads concrete hex from `docs.json` at build, so — unlike the var()-backed bridges — this resolves
7
+ * tokens to concrete per-mode values (like the MUI renderer). Mintlify drives light/dark itself, so
8
+ * `colors.primary`/`colors.light` carry the light/dark emphasis colours and `background.color` the
9
+ * two page surfaces.
10
+ *
11
+ * @module
12
+ */
13
+ /** The Instructure token behind each Mintlify colour slot. */
14
+ const BRAND = "--instui-color-background-brand";
15
+ const BUTTON = "--instui-color-background-interactive-action-primary-base";
16
+ const PAGE = "--instui-color-background-page";
17
+ /**
18
+ * Build the Mintlify `docs.json` theming keys from a token IR.
19
+ *
20
+ * @param tokens - The IR (e.g. from `@pantoken/tokens`).
21
+ * @returns The `colors` + `background` keys to merge into a Mintlify `docs.json`.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * import { toMintlifyConfig } from "@pantoken/mintlify";
26
+ * import { tokens } from "@pantoken/tokens";
27
+ *
28
+ * const theme = toMintlifyConfig(tokens);
29
+ * // { colors: { primary: "#1D354F", light: "#EEF4FD", dark: "#1D354F" },
30
+ * // background: { color: { light: "#F2F4F5", dark: "#10141A" } } }
31
+ * ```
32
+ */
33
+ function toMintlifyConfig(tokens) {
34
+ const light = resolveTokens(tokens, { mode: "light" });
35
+ const dark = resolveTokens(tokens, { mode: "dark" });
36
+ const get = (map, name) => map.get(name) ?? "";
37
+ return {
38
+ colors: {
39
+ primary: get(light, BRAND),
40
+ light: get(dark, BRAND),
41
+ dark: get(light, BUTTON)
42
+ },
43
+ background: { color: {
44
+ light: get(light, PAGE),
45
+ dark: get(dark, PAGE)
46
+ } }
47
+ };
48
+ }
49
+ //#endregion
50
+ //#region src/index.ts
51
+ /**
52
+ * `@pantoken/mintlify` — theme a Mintlify docs site with Instructure tokens.
53
+ *
54
+ * {@link toMintlifyConfig} maps any IR onto the `colors` + `background` keys of a Mintlify
55
+ * `docs.json`; {@link docsJson} is the ready-made `rebrand` fragment. Merge it into your `docs.json`.
56
+ *
57
+ * @example
58
+ * ```jsonc
59
+ * // docs.json
60
+ * {
61
+ * "name": "My docs",
62
+ * "theme": "mint",
63
+ * "colors": { "primary": "#1D354F", "light": "#EEF4FD", "dark": "#1D354F" },
64
+ * "background": { "color": { "light": "#F2F4F5", "dark": "#10141A" } }
65
+ * }
66
+ * ```
67
+ *
68
+ * @module
69
+ * @experimental
70
+ */
71
+ /** Ready-made `rebrand` Mintlify `docs.json` theming keys (colors + background). */
72
+ const docsJson = toMintlifyConfig(tokens);
73
+ //#endregion
74
+ export { docsJson as default, docsJson, toMintlifyConfig };
@@ -0,0 +1,13 @@
1
+ {
2
+ "colors": {
3
+ "primary": "#1D354F",
4
+ "light": "#EEF4FD",
5
+ "dark": "#1D354F"
6
+ },
7
+ "background": {
8
+ "color": {
9
+ "light": "#F2F4F5",
10
+ "dark": "#10141A"
11
+ }
12
+ }
13
+ }
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@pantoken/mintlify",
3
+ "version": "0.1.0",
4
+ "description": "Theme a Mintlify docs site with Instructure tokens: the docs.json colors + background, resolved to concrete hex per mode.",
5
+ "license": "MIT",
6
+ "files": [
7
+ "dist",
8
+ "generated/docs.json"
9
+ ],
10
+ "type": "module",
11
+ "exports": {
12
+ ".": "./dist/index.mjs",
13
+ "./docs.json": "./generated/docs.json",
14
+ "./package.json": "./package.json"
15
+ },
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "dependencies": {
20
+ "@pantoken/model": "0.1.0",
21
+ "@pantoken/utils": "0.1.0",
22
+ "@pantoken/tokens": "0.1.0"
23
+ },
24
+ "devDependencies": {
25
+ "@types/node": "^24.13.3",
26
+ "typescript": "^6.0.3",
27
+ "vite": "npm:@voidzero-dev/vite-plus-core@0.2.4",
28
+ "vite-plus": "0.2.4"
29
+ },
30
+ "pantoken": {
31
+ "key": "mintlify",
32
+ "kind": "namespace"
33
+ },
34
+ "scripts": {
35
+ "generate": "node scripts/generate.ts",
36
+ "build": "vp pack && vp run generate",
37
+ "dev": "vp pack --watch",
38
+ "test": "vp test",
39
+ "check": "vp check"
40
+ }
41
+ }