@pantoken/svelte 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 +41 -0
- package/dist/components.css +1 -0
- package/dist/index.d.mts +38 -0
- package/dist/index.mjs +57 -0
- package/package.json +47 -0
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# @pantoken/svelte
|
|
2
|
+
|
|
3
|
+
Svelte helpers over `@pantoken/web-components`: an `icon` action that renders an Instructure glyph
|
|
4
|
+
into a node, plus a token reader.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npm i @pantoken/svelte
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Also available as `pantoken/svelte`.
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```svelte
|
|
17
|
+
<script>
|
|
18
|
+
import { icon, readToken } from "@pantoken/svelte";
|
|
19
|
+
import "@pantoken/css";
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<span use:icon={"arrow-left"} />
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The `<instui-icon>` custom element also works directly once `register()` has run.
|
|
26
|
+
|
|
27
|
+
## API
|
|
28
|
+
|
|
29
|
+
- **`icon(node, name): ActionResult`** — Svelte action that renders the icon's inline SVG into the host element and updates when the name changes.
|
|
30
|
+
- **`readToken(name, fallback?): string`** — read a resolved `--instui-*` value. Returns `fallback` on the server.
|
|
31
|
+
- **`ActionResult`** — the action's return shape (`update`, `destroy`).
|
|
32
|
+
- **`register`** — re-exported from `@pantoken/web-components` for direct control over registration timing.
|
|
33
|
+
|
|
34
|
+
## Related
|
|
35
|
+
|
|
36
|
+
- Pairs with `@pantoken/css` for the base `--instui-*` custom properties.
|
|
37
|
+
- Wraps `@pantoken/web-components`, which supplies the custom elements and icon SVGs.
|
|
38
|
+
|
|
39
|
+
## License
|
|
40
|
+
|
|
41
|
+
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)}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { register } from "@pantoken/web-components";
|
|
2
|
+
|
|
3
|
+
//#region src/index.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Read a resolved token value. Returns `fallback` on the server.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { readToken } from "@pantoken/svelte";
|
|
10
|
+
*
|
|
11
|
+
* const brand = readToken("--instui-color-background-brand", "#0374B5");
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
declare function readToken(name: string, fallback?: string): string;
|
|
15
|
+
/** A Svelte action's return shape. */
|
|
16
|
+
interface ActionResult {
|
|
17
|
+
update(name: string): void;
|
|
18
|
+
destroy(): void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Svelte action: `<span use:icon={"arrow-left"} />` renders the icon's inline SVG into the node.
|
|
22
|
+
*
|
|
23
|
+
* @param node - The host element.
|
|
24
|
+
* @param name - The icon name.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```svelte
|
|
28
|
+
* <script>
|
|
29
|
+
* import { icon } from "@pantoken/svelte";
|
|
30
|
+
* import "@pantoken/css";
|
|
31
|
+
* </script>
|
|
32
|
+
*
|
|
33
|
+
* <span use:icon={"arrow-left"} />
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
declare function icon(node: Element, name: string): ActionResult;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { ActionResult, icon, readToken, register };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { iconSvg, register, register as register$1 } from "@pantoken/web-components";
|
|
2
|
+
//#region src/index.ts
|
|
3
|
+
/**
|
|
4
|
+
* `@pantoken/svelte` — Svelte helpers over `@pantoken/web-components`.
|
|
5
|
+
*
|
|
6
|
+
* `icon` is a Svelte action that renders an Instructure glyph into an element. `readToken` reads a
|
|
7
|
+
* resolved `--instui-*` value (SSR-safe). The custom elements also work directly once `register()`
|
|
8
|
+
* has run.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
* @experimental
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Read a resolved token value. Returns `fallback` on the server.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { readToken } from "@pantoken/svelte";
|
|
19
|
+
*
|
|
20
|
+
* const brand = readToken("--instui-color-background-brand", "#0374B5");
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
function readToken(name, fallback = "") {
|
|
24
|
+
if (typeof document === "undefined") return fallback;
|
|
25
|
+
return getComputedStyle(document.documentElement).getPropertyValue(name).trim() || fallback;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Svelte action: `<span use:icon={"arrow-left"} />` renders the icon's inline SVG into the node.
|
|
29
|
+
*
|
|
30
|
+
* @param node - The host element.
|
|
31
|
+
* @param name - The icon name.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```svelte
|
|
35
|
+
* <script>
|
|
36
|
+
* import { icon } from "@pantoken/svelte";
|
|
37
|
+
* import "@pantoken/css";
|
|
38
|
+
* <\/script>
|
|
39
|
+
*
|
|
40
|
+
* <span use:icon={"arrow-left"} />
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
function icon(node, name) {
|
|
44
|
+
const render = (iconName) => {
|
|
45
|
+
node.innerHTML = iconSvg(iconName);
|
|
46
|
+
};
|
|
47
|
+
register$1();
|
|
48
|
+
render(name);
|
|
49
|
+
return {
|
|
50
|
+
update: render,
|
|
51
|
+
destroy() {
|
|
52
|
+
node.innerHTML = "";
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
export { icon, readToken, register };
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pantoken/svelte",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Svelte helpers for pantoken: an icon action over the web components, plus token reads.",
|
|
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/web-components": "0.1.0"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/node": "^24.13.3",
|
|
23
|
+
"typescript": "^6.0.3",
|
|
24
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@0.2.4",
|
|
25
|
+
"vite-plus": "0.2.4",
|
|
26
|
+
"@pantoken/components": "0.1.0"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"svelte": ">=4"
|
|
30
|
+
},
|
|
31
|
+
"peerDependenciesMeta": {
|
|
32
|
+
"svelte": {
|
|
33
|
+
"optional": true
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"pantoken": {
|
|
37
|
+
"key": "svelte",
|
|
38
|
+
"kind": "subpath"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"generate": "node scripts/generate.ts",
|
|
42
|
+
"build": "vp run generate && vp pack",
|
|
43
|
+
"dev": "vp run generate && vp pack --watch",
|
|
44
|
+
"test": "vp test",
|
|
45
|
+
"check": "vp check"
|
|
46
|
+
}
|
|
47
|
+
}
|