@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@motion-proto/live-tokens",
3
- "version": "0.1.0",
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 '../router';
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
- <button class="hdr-btn nav" class:active={$route === '/'} on:click={() => navigate('/')}>
234
- <i class="fas fa-home"></i>
235
- <span>Site</span>
236
- </button>
237
- <button class="hdr-btn nav" class:active={$route === '/components'} on:click={() => navigate('/components')}>
238
- <i class="fas fa-puzzle-piece"></i>
239
- <span>Components</span>
240
- </button>
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="/admin"
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
+ });
@@ -55,8 +55,6 @@
55
55
 
56
56
  <style>
57
57
  @import '../showcase/editor.css';
58
- @import '../styles/variables.css';
59
-
60
58
  .components-shell {
61
59
  display: grid;
62
60
  grid-template-columns: 240px minmax(0, 1fr);
@@ -52,8 +52,6 @@
52
52
  </div>
53
53
 
54
54
  <style>
55
- @import '../styles/variables.css';
56
-
57
55
  .components-container {
58
56
  display: flex;
59
57
  flex-direction: column;
@@ -259,8 +259,6 @@
259
259
  </div>
260
260
 
261
261
  <style>
262
- @import '../styles/variables.css';
263
-
264
262
  .surfaces-container {
265
263
  display: flex;
266
264
  flex-direction: column;
@@ -112,8 +112,6 @@
112
112
  </div>
113
113
 
114
114
  <style>
115
- @import '../styles/variables.css';
116
-
117
115
  .text-container {
118
116
  display: flex;
119
117
  flex-direction: column;
@@ -1705,8 +1705,6 @@
1705
1705
  </div>
1706
1706
 
1707
1707
  <style>
1708
- @import '../styles/variables.css';
1709
-
1710
1708
  .variables-container {
1711
1709
  display: flex;
1712
1710
  flex-direction: column;
@@ -122,8 +122,6 @@
122
122
  </div>
123
123
 
124
124
  <style>
125
- @import '../styles/variables.css';
126
-
127
125
  .layout {
128
126
  display: grid;
129
127
  grid-template-columns: 240px minmax(0, 1fr);
@@ -42,8 +42,6 @@
42
42
  </div>
43
43
 
44
44
  <style>
45
- @import '../../styles/variables.css';
46
-
47
45
  .trait-demo-row {
48
46
  display: flex;
49
47
  gap: var(--space-8);
@@ -42,8 +42,6 @@
42
42
  </div>
43
43
 
44
44
  <style>
45
- @import '../../styles/variables.css';
46
-
47
45
  .card-demo-grid {
48
46
  display: grid;
49
47
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
@@ -90,8 +90,6 @@
90
90
  </div>
91
91
 
92
92
  <style>
93
- @import '../../styles/variables.css';
94
-
95
93
  .choice-buttons-container {
96
94
  display: flex;
97
95
  flex-wrap: wrap;
@@ -40,8 +40,6 @@
40
40
  </div>
41
41
 
42
42
  <style>
43
- @import '../../styles/variables.css';
44
-
45
43
  .collapsible-demo-wrapper {
46
44
  border: 1px solid var(--ui-border-subtle);
47
45
  border-radius: var(--radius-md);
@@ -17,8 +17,6 @@
17
17
  </div>
18
18
 
19
19
  <style>
20
- @import '../../styles/variables.css';
21
-
22
20
  .inline-edit-demo-row {
23
21
  display: flex;
24
22
  align-items: center;
@@ -133,8 +133,6 @@
133
133
  </div>
134
134
 
135
135
  <style>
136
- @import '../../styles/variables.css';
137
-
138
136
  .notification-showcase {
139
137
  display: flex;
140
138
  flex-direction: column;
@@ -39,8 +39,6 @@
39
39
  </div>
40
40
 
41
41
  <style>
42
- @import '../../styles/variables.css';
43
-
44
42
  .progress-demo-stack {
45
43
  display: flex;
46
44
  flex-direction: column;
@@ -48,8 +48,6 @@
48
48
  </div>
49
49
 
50
50
  <style>
51
- @import '../../styles/variables.css';
52
-
53
51
  .radio-demo-row {
54
52
  display: flex;
55
53
  gap: var(--space-16);
@@ -54,8 +54,6 @@
54
54
  </div>
55
55
 
56
56
  <style>
57
- @import '../../styles/variables.css';
58
-
59
57
  .divider-showcase {
60
58
  display: flex;
61
59
  flex-direction: column;
@@ -339,8 +339,6 @@
339
339
  </div>
340
340
 
341
341
  <style>
342
- @import '../../styles/variables.css';
343
-
344
342
  .variant-group {
345
343
  padding: var(--space-16);
346
344
  background: var(--ui-surface-low);
@@ -47,8 +47,6 @@
47
47
  </div>
48
48
 
49
49
  <style>
50
- @import '../../styles/variables.css';
51
-
52
50
  .tab-content-demo {
53
51
  padding: var(--space-16);
54
52
  color: var(--ui-text-secondary);
@@ -36,8 +36,6 @@
36
36
  </div>
37
37
 
38
38
  <style>
39
- @import '../../styles/variables.css';
40
-
41
39
  .tooltip-demo-row {
42
40
  display: flex;
43
41
  gap: var(--space-24);
@@ -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
- }