@motion-proto/live-tokens 0.36.0 → 0.38.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/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.38.0 — Overridable scroll reset for smooth-scroll hosts
4
+
5
+ ### Added
6
+
7
+ - **`setScrollReset(fn)` lets a host route navigation's scroll reset through its
8
+ own scroll system.** On a non-hash `navigate()` the router resets the viewport
9
+ to the top. That default calls `window.scrollTo(0, 0)`, which is invisible to
10
+ consumers driving scroll with a smooth-scroll library (Lenis, Locomotive):
11
+ their scroll position is decoupled from the window, so the rendered page stays
12
+ put — most visibly when `LiveTokensRouter` intercepts an in-page link (e.g. a
13
+ card) and the new page opens mid-scroll instead of at the top. Register a reset
14
+ that drives your provider (`setScrollReset(() => lenis.scrollTo(0, { immediate: true }))`)
15
+ and both the overlay's nav and intercepted links reset correctly. Hash targets
16
+ still skip the reset so in-page anchors are unaffected. Backward compatible —
17
+ unset, the native `window.scrollTo` behavior is unchanged.
18
+
19
+ ## 0.37.0 — ImageLightbox `capNatural` accepts a multiple
20
+
21
+ ### Added
22
+
23
+ - **`ImageLightbox`'s `capNatural` now takes a number as well as a boolean.**
24
+ `true` still caps the open fit at 1:1 (100%); a number caps at that multiple of
25
+ the source's natural resolution (`capNatural={2}` = up to 200%). This allows a
26
+ small source to open a little larger than native without being upscaled all the
27
+ way to the viewport. Backward compatible — the boolean form is unchanged.
28
+
3
29
  ## 0.36.0 — ImageLightbox `capNatural`: stop upscaling small sources
4
30
 
5
31
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@motion-proto/live-tokens",
3
- "version": "0.36.0",
3
+ "version": "0.38.0",
4
4
  "type": "module",
5
5
  "description": "Design token editor with live CSS variable editing. Svelte 5 + Vite 8.",
6
6
  "keywords": [
@@ -13,6 +13,17 @@ function rememberPrev(current: string) {
13
13
 
14
14
  export const route = writable<string>('/');
15
15
 
16
+ // Scroll reset on navigation. The default jumps the native viewport to the top,
17
+ // which is invisible to consumers that drive scrolling with a smooth-scroll
18
+ // library (Lenis, Locomotive): their internal scroll position is decoupled from
19
+ // the window, so `window.scrollTo` leaves the rendered page where it was.
20
+ // `setScrollReset` lets such hosts route the reset through their own provider.
21
+ let scrollReset = () => window.scrollTo(0, 0);
22
+
23
+ export function setScrollReset(fn: () => void) {
24
+ scrollReset = fn;
25
+ }
26
+
16
27
  let initialised = false;
17
28
 
18
29
  /**
@@ -43,7 +54,7 @@ export function navigate(path: string) {
43
54
  rememberPrev(window.location.pathname || '/');
44
55
  history.pushState(null, '', path);
45
56
  if (!path.includes('#')) {
46
- window.scrollTo(0, 0);
57
+ scrollReset();
47
58
  }
48
59
  }
49
60
  route.set(pathname);
@@ -9,7 +9,7 @@ export type { BootLiveTokensOptions } from './bootstrap';
9
9
  export { columnsVisible, toggleColumns, init as initColumnsOverlay } from './overlay/columnsOverlay';
10
10
  export { configureEditor, storageKey } from './core/store/editorConfig';
11
11
  export { activeFileName } from './core/store/editorConfigStore';
12
- export { init as initRouter, route, navigate } from './core/routing/router';
12
+ export { init as initRouter, route, navigate, setScrollReset } from './core/routing/router';
13
13
  export { init as initCssVarSync } from './core/cssVarSync';
14
14
  export {
15
15
  init as initEditorStore,
@@ -28,22 +28,23 @@
28
28
  extended?: boolean;
29
29
  /** Maximum zoom, as a multiple of the image's natural resolution: `1` = 100%
30
30
  of the source's real pixels (1 source px = 1 screen px), `2` = 200%. The
31
- modal opens fitted to the viewport (or to natural size when `capNatural`
32
- is set); this only caps how far the `extended` zoom controls can magnify.
31
+ modal opens fitted to the viewport (or to a `capNatural`-capped size when
32
+ that's set); this only caps how far the `extended` zoom controls magnify.
33
33
  Unset = the default 5x-the-fit cap. An image whose fitted size already
34
34
  exceeds the cap simply can't be zoomed in. Needs the natural pixel size
35
35
  (from `width`/`height`, or the loaded image); until that's known the
36
36
  default cap applies. */
37
37
  maxZoom?: number | undefined;
38
- /** Cap the opened image at its natural resolution (100%): the modal still
39
- opens centered, but never scales the source above 1:1, so a small source
40
- (e.g. a low-res GIF) stays crisp instead of being upscaled to fill the
41
- viewport. Larger images are unaffected they fit the viewport as usual.
42
- Only bounds the initial open fit; pair with `maxZoom={1}` to also stop the
43
- `extended` controls zooming past 100%. Needs the natural pixel size (from
44
- `width`/`height`, or the loaded image); until that's known the image fits
45
- the viewport, then snaps to the cap once measured. */
46
- capNatural?: boolean;
38
+ /** Cap the opened image's fit relative to its natural resolution, so a small
39
+ source (e.g. a low-res GIF) isn't upscaled to fill the viewport until it
40
+ looks soft. `true` caps at 1:1 (100%); a number caps at that multiple
41
+ (`2` = up to 200% of native). The modal still opens centered and never
42
+ below the viewport fit, so larger sources are unaffected. Only bounds the
43
+ initial open fit — the `extended` zoom controls still run up to `maxZoom`
44
+ (pair with `maxZoom` to also bound zoom). Needs the natural pixel size
45
+ (from `width`/`height`, or the loaded image); until that's known the image
46
+ fits the viewport, then snaps to the cap once measured. */
47
+ capNatural?: boolean | number;
47
48
  }
48
49
 
49
50
  let {
@@ -165,7 +166,8 @@
165
166
  let tileW = Math.min(capW, capH * aspect);
166
167
  if (capNatural) {
167
168
  const nw = naturalWidthOf(current);
168
- if (nw) tileW = Math.min(tileW, nw);
169
+ const mult = capNatural === true ? 1 : capNatural;
170
+ if (nw) tileW = Math.min(tileW, nw * mult);
169
171
  }
170
172
  const tileH = tileW / aspect;
171
173
  return {