@motion-proto/live-tokens 0.1.0 → 0.1.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/package.json +6 -4
- package/src/lib/LiveEditorOverlay.svelte +25 -21
- package/src/lib/index.ts +1 -2
- package/src/lib/router.ts +17 -0
- package/src/pages/ShowcasePage.svelte +0 -2
- package/src/showcase/ComponentsTab.svelte +0 -2
- package/src/showcase/SurfacesTab.svelte +0 -2
- package/src/showcase/TextTab.svelte +0 -2
- package/src/showcase/VariablesTab.svelte +0 -2
- package/src/showcase/VisualsTab.svelte +0 -2
- package/src/showcase/demos/BadgeDemo.svelte +0 -2
- package/src/showcase/demos/CardDemo.svelte +0 -2
- package/src/showcase/demos/ChoiceButtonsDemo.svelte +0 -2
- package/src/showcase/demos/CollapsibleSectionDemo.svelte +0 -2
- package/src/showcase/demos/InlineEditActionsDemo.svelte +0 -2
- package/src/showcase/demos/NotificationDemo.svelte +0 -2
- package/src/showcase/demos/ProgressBarDemo.svelte +0 -2
- package/src/showcase/demos/RadioButtonDemo.svelte +0 -2
- package/src/showcase/demos/SectionDividerDemo.svelte +0 -2
- package/src/showcase/demos/StandardButtonsDemo.svelte +0 -2
- package/src/showcase/demos/TabBarDemo.svelte +0 -2
- package/src/showcase/demos/TooltipDemo.svelte +0 -2
- package/src/lib/pageSource.ts +0 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@motion-proto/live-tokens",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Design token editor with live CSS variable editing. Svelte 4 + Vite.",
|
|
6
6
|
"keywords": ["svelte", "vite", "design-tokens", "css-variables", "editor"],
|
|
@@ -65,22 +65,24 @@
|
|
|
65
65
|
"prepublishOnly": "npm run build:lib"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
|
+
"sass": "^1.0",
|
|
68
69
|
"svelte": "^4.2",
|
|
70
|
+
"svelte-preprocess": "^6.0",
|
|
69
71
|
"vite": "^5.0"
|
|
70
72
|
},
|
|
71
73
|
"devDependencies": {
|
|
72
74
|
"@sveltejs/vite-plugin-svelte": "^3.1.2",
|
|
73
75
|
"@tsconfig/svelte": "^5.0.8",
|
|
74
76
|
"@types/node": "^24.12.0",
|
|
77
|
+
"sass": "^1.98.0",
|
|
75
78
|
"svelte": "^4.2.20",
|
|
76
79
|
"svelte-check": "^3.8.6",
|
|
80
|
+
"svelte-preprocess": "^6.0.3",
|
|
77
81
|
"tsup": "^8.5.1",
|
|
78
82
|
"typescript": "~5.9.3",
|
|
79
83
|
"vite": "^5.4.21"
|
|
80
84
|
},
|
|
81
85
|
"dependencies": {
|
|
82
|
-
"@fortawesome/fontawesome-free": "^7.2.0"
|
|
83
|
-
"sass": "^1.98.0",
|
|
84
|
-
"svelte-preprocess": "^6.0.3"
|
|
86
|
+
"@fortawesome/fontawesome-free": "^7.2.0"
|
|
85
87
|
}
|
|
86
88
|
}
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
+
<script lang="ts" context="module">
|
|
2
|
+
export type NavLink = { path: string; label: string; icon?: string };
|
|
3
|
+
</script>
|
|
4
|
+
|
|
1
5
|
<script lang="ts">
|
|
2
6
|
import { onMount, onDestroy } from 'svelte';
|
|
3
|
-
import { route, navigate } from '
|
|
4
|
-
import { resolvePageSource } from './pageSource';
|
|
7
|
+
import { route, navigate } from './router';
|
|
5
8
|
import { columnsVisible, toggleColumns } from './columnsOverlay';
|
|
6
9
|
import { storageKey } from './editorConfig';
|
|
7
10
|
|
|
8
|
-
const projectRoot = __PROJECT_ROOT__;
|
|
9
|
-
|
|
10
|
-
$: sourceFile = resolvePageSource($route);
|
|
11
|
-
|
|
12
|
-
// `open` controls the editor's visible state. The overlay chrome itself
|
|
13
|
-
// is always rendered (in dev, on non-admin pages):
|
|
14
|
-
// open === true → full panel (docked or floating) with the iframe
|
|
15
|
-
// open === false → just the header bar pinned to top-right
|
|
16
11
|
export let open: boolean = false;
|
|
12
|
+
export let editorPath: string = '/admin';
|
|
13
|
+
export let navLinks: NavLink[] = [];
|
|
14
|
+
export let pageSources: Record<string, string> = {};
|
|
15
|
+
export let projectRoot: string =
|
|
16
|
+
typeof __PROJECT_ROOT__ !== 'undefined' ? __PROJECT_ROOT__ : '';
|
|
17
|
+
|
|
18
|
+
$: sourceFile = pageSources[$route];
|
|
17
19
|
|
|
18
20
|
// Mount the iframe the first time the editor is shown, then keep it mounted
|
|
19
21
|
// across hide/show cycles so editor state (unsaved slider values, scroll
|
|
@@ -228,16 +230,18 @@
|
|
|
228
230
|
<div class="spacer"></div>
|
|
229
231
|
{/if}
|
|
230
232
|
|
|
231
|
-
{#if open}
|
|
233
|
+
{#if open && navLinks.length > 0}
|
|
232
234
|
<div class="preview-nav">
|
|
233
|
-
|
|
234
|
-
<
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
235
|
+
{#each navLinks as link (link.path)}
|
|
236
|
+
<button
|
|
237
|
+
class="hdr-btn nav"
|
|
238
|
+
class:active={$route === link.path}
|
|
239
|
+
on:click={() => navigate(link.path)}
|
|
240
|
+
>
|
|
241
|
+
{#if link.icon}<i class="fas {link.icon}"></i>{/if}
|
|
242
|
+
<span>{link.label}</span>
|
|
243
|
+
</button>
|
|
244
|
+
{/each}
|
|
241
245
|
</div>
|
|
242
246
|
{/if}
|
|
243
247
|
|
|
@@ -260,7 +264,7 @@
|
|
|
260
264
|
</button>
|
|
261
265
|
{/if}
|
|
262
266
|
|
|
263
|
-
{#if sourceFile}
|
|
267
|
+
{#if sourceFile && projectRoot}
|
|
264
268
|
<a
|
|
265
269
|
class="hdr-btn text source"
|
|
266
270
|
href="vscode://file/{projectRoot}/{sourceFile}"
|
|
@@ -275,7 +279,7 @@
|
|
|
275
279
|
{#if hasBeenOpen}
|
|
276
280
|
<div class="frame-wrap">
|
|
277
281
|
<iframe
|
|
278
|
-
src=
|
|
282
|
+
src={editorPath}
|
|
279
283
|
title="Design editor"
|
|
280
284
|
class="editor-frame"
|
|
281
285
|
></iframe>
|
package/src/lib/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as LiveEditorOverlay } from './LiveEditorOverlay.svelte';
|
|
2
|
+
export type { NavLink } from './LiveEditorOverlay.svelte';
|
|
2
3
|
export { default as ColumnsOverlay } from './ColumnsOverlay.svelte';
|
|
3
4
|
|
|
4
5
|
export { columnsVisible, toggleColumns } from './columnsOverlay';
|
|
@@ -47,5 +48,3 @@ export { hexToOklch, oklchToHex, gamutClamp } from './oklch';
|
|
|
47
48
|
export type { Oklch } from './oklch';
|
|
48
49
|
|
|
49
50
|
export { initializeTokens } from './tokenInit';
|
|
50
|
-
|
|
51
|
-
export { resolvePageSource } from './pageSource';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { writable } from 'svelte/store';
|
|
2
|
+
|
|
3
|
+
export const route = writable(window.location.pathname || '/');
|
|
4
|
+
|
|
5
|
+
export function navigate(path: string) {
|
|
6
|
+
const [pathname] = path.split('#');
|
|
7
|
+
history.pushState(null, '', path);
|
|
8
|
+
route.set(pathname);
|
|
9
|
+
window.dispatchEvent(new PopStateEvent('popstate'));
|
|
10
|
+
if (!path.includes('#')) {
|
|
11
|
+
window.scrollTo(0, 0);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
window.addEventListener('popstate', () => {
|
|
16
|
+
route.set(window.location.pathname || '/');
|
|
17
|
+
});
|
package/src/lib/pageSource.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export function resolvePageSource(route: string): string | undefined {
|
|
2
|
-
if (route === '/') return 'src/pages/Landing.svelte';
|
|
3
|
-
if (route === '/components') return 'src/pages/ShowcasePage.svelte';
|
|
4
|
-
if (route === '/admin') return 'src/pages/Admin.svelte';
|
|
5
|
-
return undefined;
|
|
6
|
-
}
|