@pantoken/css 0.1.0 → 0.2.1
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/dist/index.d.mts +16 -2
- package/dist/index.mjs +2 -2
- package/dist/inject.mjs +1 -1
- package/dist/{src-DnTeei9H.mjs → src-7owOg5z_.mjs} +47 -9
- package/dist/style.css +1 -1
- package/dist/style.lean.css +1 -0
- package/package.json +32 -18
package/dist/index.d.mts
CHANGED
|
@@ -98,7 +98,7 @@ declare function buildCssFile({
|
|
|
98
98
|
//#endregion
|
|
99
99
|
//#region src/index.d.ts
|
|
100
100
|
/**
|
|
101
|
-
* The ready-made `rebrand` stylesheet string.
|
|
101
|
+
* The ready-made `rebrand` stylesheet string (typed: concrete tokens as `@property` registrations).
|
|
102
102
|
*
|
|
103
103
|
* @example
|
|
104
104
|
* ```ts
|
|
@@ -108,5 +108,19 @@ declare function buildCssFile({
|
|
|
108
108
|
* ```
|
|
109
109
|
*/
|
|
110
110
|
declare const css: string;
|
|
111
|
+
/**
|
|
112
|
+
* The lean `rebrand` stylesheet string — the full sheet minus the `--instui-icon-*` glyph tokens (the
|
|
113
|
+
* ~1,777 icon data-URIs that make up most of {@link css}). Roughly a sixth the size over the wire; the
|
|
114
|
+
* recommended foundation for CDN/embed delivery. Components reference only a handful of icons, shipped
|
|
115
|
+
* separately as `@pantoken/components`'s `component-icons.css`; consumers who use `var(--instui-icon-*)`
|
|
116
|
+
* broadly should load the full {@link css} (or the `icons.css` glyph sheet). See
|
|
117
|
+
* `@pantoken/css/style.lean.css`.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```ts
|
|
121
|
+
* import { leanCss } from "@pantoken/css";
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
declare const leanCss: string;
|
|
111
125
|
//#endregion
|
|
112
|
-
export { type CssSection, type ToCssOptions, buildCssFile, css, css as default, toCss };
|
|
126
|
+
export { type CssSection, type ToCssOptions, buildCssFile, css, css as default, leanCss, toCss };
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
export { buildCssFile, css, css as default, toCss };
|
|
1
|
+
import { i as buildCssFile, n as leanCss, r as toCss, t as css } from "./src-7owOg5z_.mjs";
|
|
2
|
+
export { buildCssFile, css, css as default, leanCss, toCss };
|
package/dist/inject.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { checkPlugins, definePlugin } from "@pantoken/plugin-kit";
|
|
1
2
|
import { tokens } from "@pantoken/tokens";
|
|
2
|
-
import {
|
|
3
|
+
import { elevationDeclarations, focusOutlineDeclarations } from "@pantoken/utils";
|
|
3
4
|
//#region src/emit.ts
|
|
4
5
|
function renderSection(scope, { layer, pairs }) {
|
|
5
6
|
const declarations = [
|
|
@@ -147,9 +148,13 @@ function toCss(tokens, options = {}) {
|
|
|
147
148
|
}
|
|
148
149
|
function appendContribution(c, prepends, appends) {
|
|
149
150
|
if (c.prepend) prepends.push(marked(c.marker, c.prepend));
|
|
151
|
+
const typedProps = [];
|
|
152
|
+
const declPairs = [...c.declarations ?? []];
|
|
153
|
+
for (const p of c.properties ?? []) if (isContextual(p.value)) declPairs.push([p.name, p.value]);
|
|
154
|
+
else typedProps.push(p);
|
|
150
155
|
const block = [
|
|
151
|
-
|
|
152
|
-
|
|
156
|
+
typedProps.map((p) => `@property ${p.name} {\n syntax: "${p.syntax}";\n inherits: true;\n initial-value: ${p.value};\n}`).join("\n\n"),
|
|
157
|
+
declPairs.length ? `:root {\n${declPairs.map(([n, v]) => ` ${n}: ${v};`).join("\n")}\n}` : "",
|
|
153
158
|
c.append
|
|
154
159
|
].filter(Boolean).join("\n\n");
|
|
155
160
|
if (block) appends.push(marked(c.marker, block));
|
|
@@ -159,15 +164,32 @@ function appendContribution(c, prepends, appends) {
|
|
|
159
164
|
/**
|
|
160
165
|
* `@pantoken/css` — emit Instructure design tokens as `@property`-typed CSS.
|
|
161
166
|
*
|
|
162
|
-
* {@link toCss} turns any token IR into CSS; {@link css} is the ready-made `rebrand` stylesheet
|
|
163
|
-
*
|
|
164
|
-
*
|
|
167
|
+
* {@link toCss} turns any token IR into CSS; {@link css} is the ready-made `rebrand` stylesheet and
|
|
168
|
+
* {@link leanCss} is a lean variant that drops the full `--instui-icon-*` set (the ~1,777 icon data-URIs
|
|
169
|
+
* that dominate the sheet) for CDN/embed delivery — ~a sixth the size over the wire. Both carry the
|
|
170
|
+
* elevation + focus-outline foundation (composite custom properties whose pure builders live in
|
|
171
|
+
* `@pantoken/utils`), so a component sheet resolves its shadows and focus ring against the token sheet
|
|
172
|
+
* alone. A DOM side-effect entry lives at `@pantoken/css/inject`; static files at
|
|
173
|
+
* `@pantoken/css/style.css` and `@pantoken/css/style.lean.css`.
|
|
165
174
|
*
|
|
166
175
|
* @module
|
|
167
176
|
* @beta
|
|
168
177
|
*/
|
|
169
178
|
/**
|
|
170
|
-
* The
|
|
179
|
+
* The elevation (`--instui-elevation-*`) and focus-outline (`--instui-focus-outline-*`) composite custom
|
|
180
|
+
* properties. Their pure builders live in `@pantoken/utils`, so this package (which sits below
|
|
181
|
+
* `@pantoken/components`) owns the emission without an upward dependency. The values are contextual
|
|
182
|
+
* (`var(...)`), so they land as `:root` declarations in both the typed and lean builds.
|
|
183
|
+
*/
|
|
184
|
+
const foundationPlugin = definePlugin({
|
|
185
|
+
name: "pantoken-foundation",
|
|
186
|
+
css: () => ({
|
|
187
|
+
marker: "pantoken foundation — elevation + focus-outline custom properties",
|
|
188
|
+
declarations: [...elevationDeclarations(), ...focusOutlineDeclarations()]
|
|
189
|
+
})
|
|
190
|
+
});
|
|
191
|
+
/**
|
|
192
|
+
* The ready-made `rebrand` stylesheet string (typed: concrete tokens as `@property` registrations).
|
|
171
193
|
*
|
|
172
194
|
* @example
|
|
173
195
|
* ```ts
|
|
@@ -176,6 +198,22 @@ function appendContribution(c, prepends, appends) {
|
|
|
176
198
|
* document.head.insertAdjacentHTML("beforeend", `<style>${css}</style>`);
|
|
177
199
|
* ```
|
|
178
200
|
*/
|
|
179
|
-
const css = toCss(tokens);
|
|
201
|
+
const css = toCss(tokens, { plugins: [foundationPlugin] });
|
|
202
|
+
/** The `--instui-icon-*` glyph tokens — the full icon set as data-URIs, ~86% of the sheet's bytes. */
|
|
203
|
+
const ICON_TOKEN_PREFIX = "--instui-icon-";
|
|
204
|
+
/**
|
|
205
|
+
* The lean `rebrand` stylesheet string — the full sheet minus the `--instui-icon-*` glyph tokens (the
|
|
206
|
+
* ~1,777 icon data-URIs that make up most of {@link css}). Roughly a sixth the size over the wire; the
|
|
207
|
+
* recommended foundation for CDN/embed delivery. Components reference only a handful of icons, shipped
|
|
208
|
+
* separately as `@pantoken/components`'s `component-icons.css`; consumers who use `var(--instui-icon-*)`
|
|
209
|
+
* broadly should load the full {@link css} (or the `icons.css` glyph sheet). See
|
|
210
|
+
* `@pantoken/css/style.lean.css`.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```ts
|
|
214
|
+
* import { leanCss } from "@pantoken/css";
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
217
|
+
const leanCss = toCss(tokens.filter((t) => !t.name.startsWith(ICON_TOKEN_PREFIX)), { plugins: [foundationPlugin] });
|
|
180
218
|
//#endregion
|
|
181
|
-
export {
|
|
219
|
+
export { buildCssFile as i, leanCss as n, toCss as r, css as t };
|