@pantoken/email 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 +45 -0
- package/dist/index.d.mts +45 -0
- package/dist/index.mjs +67 -0
- package/package.json +38 -0
package/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# @pantoken/email
|
|
2
|
+
|
|
3
|
+
Instructure design tokens for HTML email. Email clients don't support CSS custom properties and
|
|
4
|
+
often strip `<style>`, so tokens are fully resolved to concrete values for inline styling — colours
|
|
5
|
+
as hex, dimensions with `px`. Icons are excluded.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm i @pantoken/email
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Also available as `pantoken/email`.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { emailTokens } from "@pantoken/email";
|
|
19
|
+
|
|
20
|
+
const t = emailTokens("light");
|
|
21
|
+
// <td style={`background:${t.colorBackgroundBrand};color:${t.colorTextOnColor}`}>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The maps are keyed by camelCased token name (the `--instui-` prefix dropped): `--instui-color-
|
|
25
|
+
background-brand` becomes `colorBackgroundBrand`.
|
|
26
|
+
|
|
27
|
+
## Output
|
|
28
|
+
|
|
29
|
+
Plain `Record<string, string>` maps of concrete token values, ready to interpolate into inline
|
|
30
|
+
`style` attributes. No files are written and there's no CLI target — you import the values.
|
|
31
|
+
|
|
32
|
+
## API
|
|
33
|
+
|
|
34
|
+
- **`emailTokens(mode?): Record<string, string>`** — the token map for a mode (`"light"` default,
|
|
35
|
+
or `"dark"`).
|
|
36
|
+
- **`light`** — the concrete light-mode token map.
|
|
37
|
+
- **`dark`** — the concrete dark-mode token map.
|
|
38
|
+
|
|
39
|
+
## Related
|
|
40
|
+
|
|
41
|
+
- Built on `@pantoken/tokens` (the vendored IR) and `@pantoken/utils` (`resolveTokens`, `camelCase`).
|
|
42
|
+
|
|
43
|
+
## License
|
|
44
|
+
|
|
45
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//#region src/index.d.ts
|
|
2
|
+
type Mode = "light" | "dark";
|
|
3
|
+
/**
|
|
4
|
+
* Concrete `light`-mode token values, for inline email styling.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { light } from "@pantoken/email";
|
|
9
|
+
*
|
|
10
|
+
* const bg = light.colorBackgroundBrand; // e.g. "#…"
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
declare const light: Record<string, string>;
|
|
14
|
+
/**
|
|
15
|
+
* Concrete `dark`-mode token values.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { dark } from "@pantoken/email";
|
|
20
|
+
*
|
|
21
|
+
* const bg = dark.colorBackgroundBrand;
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
declare const dark: Record<string, string>;
|
|
25
|
+
/**
|
|
26
|
+
* Select the token map for a mode (default `"light"`).
|
|
27
|
+
*
|
|
28
|
+
* @example Inline a token into an email cell (light mode)
|
|
29
|
+
* ```ts
|
|
30
|
+
* import { emailTokens } from "@pantoken/email";
|
|
31
|
+
*
|
|
32
|
+
* const t = emailTokens();
|
|
33
|
+
* const html = `<td style="background:${t.colorBackgroundBrand};color:${t.colorTextOnColor}">Hi</td>`;
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @example Dark mode
|
|
37
|
+
* ```ts
|
|
38
|
+
* import { emailTokens } from "@pantoken/email";
|
|
39
|
+
*
|
|
40
|
+
* const t = emailTokens("dark");
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
declare function emailTokens(mode?: Mode): Record<string, string>;
|
|
44
|
+
//#endregion
|
|
45
|
+
export { dark, emailTokens, light };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { tokens } from "@pantoken/tokens";
|
|
2
|
+
import { camelCase, resolveTokens } from "@pantoken/utils";
|
|
3
|
+
//#region src/index.ts
|
|
4
|
+
/**
|
|
5
|
+
* `@pantoken/email` — Instructure design tokens for HTML email.
|
|
6
|
+
*
|
|
7
|
+
* Email clients don't support CSS custom properties and often strip `<style>`, so tokens are fully
|
|
8
|
+
* resolved to concrete values for inline styling. Colours are hex; dimensions keep their `px` units.
|
|
9
|
+
* Icons are excluded. `light`/`dark` maps are keyed by camelCased token name.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
* @experimental
|
|
13
|
+
*/
|
|
14
|
+
function build(mode) {
|
|
15
|
+
const resolved = resolveTokens(tokens, { mode });
|
|
16
|
+
const out = {};
|
|
17
|
+
for (const token of tokens) {
|
|
18
|
+
if (token.meta?.kind === "icon") continue;
|
|
19
|
+
out[camelCase(token.name.replace(/^--instui-/, ""))] = resolved.get(token.name) ?? token.value;
|
|
20
|
+
}
|
|
21
|
+
return out;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Concrete `light`-mode token values, for inline email styling.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* import { light } from "@pantoken/email";
|
|
29
|
+
*
|
|
30
|
+
* const bg = light.colorBackgroundBrand; // e.g. "#…"
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
const light = build("light");
|
|
34
|
+
/**
|
|
35
|
+
* Concrete `dark`-mode token values.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* import { dark } from "@pantoken/email";
|
|
40
|
+
*
|
|
41
|
+
* const bg = dark.colorBackgroundBrand;
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
const dark = build("dark");
|
|
45
|
+
/**
|
|
46
|
+
* Select the token map for a mode (default `"light"`).
|
|
47
|
+
*
|
|
48
|
+
* @example Inline a token into an email cell (light mode)
|
|
49
|
+
* ```ts
|
|
50
|
+
* import { emailTokens } from "@pantoken/email";
|
|
51
|
+
*
|
|
52
|
+
* const t = emailTokens();
|
|
53
|
+
* const html = `<td style="background:${t.colorBackgroundBrand};color:${t.colorTextOnColor}">Hi</td>`;
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @example Dark mode
|
|
57
|
+
* ```ts
|
|
58
|
+
* import { emailTokens } from "@pantoken/email";
|
|
59
|
+
*
|
|
60
|
+
* const t = emailTokens("dark");
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
function emailTokens(mode = "light") {
|
|
64
|
+
return mode === "dark" ? dark : light;
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
67
|
+
export { dark, emailTokens, light };
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pantoken/email",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Instructure design tokens for HTML email: concrete, inline-friendly token values (no CSS vars).",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"type": "module",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": "./dist/index.mjs",
|
|
12
|
+
"./package.json": "./package.json"
|
|
13
|
+
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@pantoken/model": "0.1.0",
|
|
19
|
+
"@pantoken/tokens": "0.1.0",
|
|
20
|
+
"@pantoken/utils": "0.1.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/node": "^24.13.3",
|
|
24
|
+
"typescript": "^6.0.3",
|
|
25
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@0.2.4",
|
|
26
|
+
"vite-plus": "0.2.4"
|
|
27
|
+
},
|
|
28
|
+
"pantoken": {
|
|
29
|
+
"key": "email",
|
|
30
|
+
"kind": "subpath"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "vp pack",
|
|
34
|
+
"dev": "vp pack --watch",
|
|
35
|
+
"test": "vp test",
|
|
36
|
+
"check": "vp check"
|
|
37
|
+
}
|
|
38
|
+
}
|