@streamscloud/kit 0.20.3 → 0.21.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.
@@ -55,11 +55,16 @@ export class ImgCropperCoverWorker extends ImgCropperBaseWorker {
55
55
  const width = Math.min(fitted.width, maxWidth);
56
56
  this.canvasGeometry = { aspectRatio, width, height: width / aspectRatio };
57
57
  }
58
+ else if (visualWidth <= 0 || visualHeight <= 0) {
59
+ this.canvasGeometry = { aspectRatio, width: containerWidth, height: containerHeight };
60
+ }
61
+ else if (visualWidth <= containerWidth && visualHeight <= containerHeight) {
62
+ this.canvasGeometry = { aspectRatio, width: visualWidth, height: visualHeight };
63
+ }
58
64
  else {
59
- // Cap each dimension at visual size to avoid upscaling small images
60
- const width = visualWidth > 0 ? Math.min(containerWidth, visualWidth) : containerWidth;
61
- const height = visualHeight > 0 ? Math.min(containerHeight, visualHeight) : containerHeight;
62
- this.canvasGeometry = { aspectRatio, width, height };
65
+ // Fit at image AR; per-axis capping collapses an oversized image to the container AR.
66
+ const fitted = fitInContainer({ ratio: visualWidth / visualHeight, containerWidth, containerHeight });
67
+ this.canvasGeometry = { aspectRatio, width: fitted.width, height: fitted.height };
63
68
  }
64
69
  };
65
70
  }
@@ -1,15 +1,15 @@
1
1
  <script lang="ts">"use strict";
2
- let { shape = 'rect', lines = 1 } = $props();
2
+ let { shape = 'rect', lines = 1, shimmer = false } = $props();
3
3
  </script>
4
4
 
5
5
  {#if shape === 'text' && lines > 1}
6
6
  <span class="skeleton-stack">
7
7
  {#each Array(lines) as _, i (i)}
8
- <span class="skeleton skeleton--text" class:skeleton--text-last={i === lines - 1}></span>
8
+ <span class="skeleton skeleton--text" class:skeleton--shimmer={shimmer} class:skeleton--text-last={i === lines - 1}></span>
9
9
  {/each}
10
10
  </span>
11
11
  {:else}
12
- <span class="skeleton skeleton--{shape}"></span>
12
+ <span class="skeleton skeleton--{shape}" class:skeleton--shimmer={shimmer}></span>
13
13
  {/if}
14
14
 
15
15
  <!--
@@ -24,10 +24,10 @@ Skeleton — content placeholder rendered while data is loading. Three shapes: `
24
24
  | `--sc-kit--skeleton--text-height` | Per-line height in `shape='text'` | `0.75em` |
25
25
  | `--sc-kit--skeleton--text-last-width` | Width of the last line in multi-line text | `70%` |
26
26
  | `--sc-kit--skeleton--text-gap` | Vertical gap between text lines | `--sc-kit--space--2` |
27
- | `--sc-kit--skeleton--base-color` | Shimmer base (darker stop) | `--sc-kit--color--bg--active` |
28
- | `--sc-kit--skeleton--highlight-color` | Shimmer peak (lighter stop) | `--sc-kit--color--bg--hover` |
27
+ | `--sc-kit--skeleton--base-color` | Placeholder fill / shimmer darker stop | `--sc-kit--color--bg--active` |
28
+ | `--sc-kit--skeleton--highlight-color` | Shimmer peak (lighter stop) — `shimmer` only | `--sc-kit--color--bg--hover` |
29
29
  | `--sc-kit--skeleton--radius` | Corner radius (rect / text) | `--sc-kit--radius--sm` |
30
- | `--sc-kit--skeleton--duration` | Animation cycle length | `2.2s` |
30
+ | `--sc-kit--skeleton--duration` | Shimmer cycle length — `shimmer` only | `2.2s` |
31
31
  -->
32
32
 
33
33
  <style>.skeleton {
@@ -36,17 +36,26 @@ Skeleton — content placeholder rendered while data is loading. Three shapes: `
36
36
  --_skeleton--text-height: var(--sc-kit--skeleton--text-height, 0.75em);
37
37
  --_skeleton--text-last-width: var(--sc-kit--skeleton--text-last-width, 70%);
38
38
  --_skeleton--base-color: var(--sc-kit--skeleton--base-color, var(--sc-kit--color--bg--active));
39
- --_skeleton--highlight-color: var(--sc-kit--skeleton--highlight-color, var(--sc-kit--color--bg--hover));
40
39
  --_skeleton--radius: var(--sc-kit--skeleton--radius, var(--sc-kit--radius--sm));
41
- --_skeleton--duration: var(--sc-kit--skeleton--duration, 2.2s);
42
40
  display: block;
43
- background: linear-gradient(90deg, var(--_skeleton--base-color) 0%, var(--_skeleton--highlight-color) 50%, var(--_skeleton--base-color) 100%);
44
- background-size: 200% 100%;
45
- animation: kit-skeleton-shimmer var(--_skeleton--duration) ease-in-out infinite;
41
+ background: var(--_skeleton--base-color);
46
42
  border-radius: var(--_skeleton--radius);
47
43
  width: var(--_skeleton--width);
48
44
  height: var(--_skeleton--height);
49
45
  }
46
+ .skeleton--shimmer {
47
+ --_skeleton--highlight-color: var(--sc-kit--skeleton--highlight-color, var(--sc-kit--color--bg--hover));
48
+ --_skeleton--duration: var(--sc-kit--skeleton--duration, 2.2s);
49
+ background: linear-gradient(90deg, var(--_skeleton--base-color) 0%, var(--_skeleton--highlight-color) 50%, var(--_skeleton--base-color) 100%);
50
+ background-size: 200% 100%;
51
+ animation: kit-skeleton-shimmer var(--_skeleton--duration) ease-in-out infinite;
52
+ }
53
+ @media (prefers-reduced-motion: reduce) {
54
+ .skeleton--shimmer {
55
+ background: var(--_skeleton--base-color);
56
+ animation: none;
57
+ }
58
+ }
50
59
  .skeleton--circle {
51
60
  border-radius: 50%;
52
61
  }
@@ -57,12 +66,6 @@ Skeleton — content placeholder rendered while data is loading. Three shapes: `
57
66
  width: var(--_skeleton--text-last-width);
58
67
  }
59
68
 
60
- .skeleton-stack {
61
- display: flex;
62
- flex-direction: column;
63
- gap: var(--sc-kit--skeleton--text-gap, var(--sc-kit--space--2));
64
- }
65
-
66
69
  @keyframes kit-skeleton-shimmer {
67
70
  0% {
68
71
  background-position: 200% 0;
@@ -70,4 +73,9 @@ Skeleton — content placeholder rendered while data is loading. Three shapes: `
70
73
  100% {
71
74
  background-position: -200% 0;
72
75
  }
76
+ }
77
+ .skeleton-stack {
78
+ display: flex;
79
+ flex-direction: column;
80
+ gap: var(--sc-kit--skeleton--text-gap, var(--sc-kit--space--2));
73
81
  }</style>
@@ -3,6 +3,8 @@ type Props = {
3
3
  shape?: 'rect' | 'circle' | 'text';
4
4
  /** For `shape='text'` only — render N stacked text lines (last one naturally shorter to suggest paragraph end). @default 1 */
5
5
  lines?: number;
6
+ /** Animate a shimmer sweep instead of a flat static placeholder. @default false */
7
+ shimmer?: boolean;
6
8
  };
7
9
  /**
8
10
  * Skeleton — content placeholder rendered while data is loading. Three shapes: `rect` (default — generic block), `circle` (avatars), `text` (one or more text lines via `lines` — the last line is naturally shorter to suggest a paragraph end). All dimensions are CSS-var driven; sizing is the consumer's concern.
@@ -15,10 +17,10 @@ type Props = {
15
17
  * | `--sc-kit--skeleton--text-height` | Per-line height in `shape='text'` | `0.75em` |
16
18
  * | `--sc-kit--skeleton--text-last-width` | Width of the last line in multi-line text | `70%` |
17
19
  * | `--sc-kit--skeleton--text-gap` | Vertical gap between text lines | `--sc-kit--space--2` |
18
- * | `--sc-kit--skeleton--base-color` | Shimmer base (darker stop) | `--sc-kit--color--bg--active` |
19
- * | `--sc-kit--skeleton--highlight-color` | Shimmer peak (lighter stop) | `--sc-kit--color--bg--hover` |
20
+ * | `--sc-kit--skeleton--base-color` | Placeholder fill / shimmer darker stop | `--sc-kit--color--bg--active` |
21
+ * | `--sc-kit--skeleton--highlight-color` | Shimmer peak (lighter stop) — `shimmer` only | `--sc-kit--color--bg--hover` |
20
22
  * | `--sc-kit--skeleton--radius` | Corner radius (rect / text) | `--sc-kit--radius--sm` |
21
- * | `--sc-kit--skeleton--duration` | Animation cycle length | `2.2s` |
23
+ * | `--sc-kit--skeleton--duration` | Shimmer cycle length — `shimmer` only | `2.2s` |
22
24
  */
23
25
  declare const Cmp: import("svelte").Component<Props, {}, "">;
24
26
  type Cmp = ReturnType<typeof Cmp>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamscloud/kit",
3
- "version": "0.20.3",
3
+ "version": "0.21.0",
4
4
  "author": "StreamsCloud",
5
5
  "repository": {
6
6
  "type": "git",