@motion-proto/live-tokens 0.36.0 → 0.37.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,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.37.0 — ImageLightbox `capNatural` accepts a multiple
4
+
5
+ ### Added
6
+
7
+ - **`ImageLightbox`'s `capNatural` now takes a number as well as a boolean.**
8
+ `true` still caps the open fit at 1:1 (100%); a number caps at that multiple of
9
+ the source's natural resolution (`capNatural={2}` = up to 200%). This allows a
10
+ small source to open a little larger than native without being upscaled all the
11
+ way to the viewport. Backward compatible — the boolean form is unchanged.
12
+
3
13
  ## 0.36.0 — ImageLightbox `capNatural`: stop upscaling small sources
4
14
 
5
15
  ### 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.37.0",
4
4
  "type": "module",
5
5
  "description": "Design token editor with live CSS variable editing. Svelte 5 + Vite 8.",
6
6
  "keywords": [
@@ -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 {