@dorsk/tsumikit 0.2.0 → 0.2.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.
@@ -118,7 +118,14 @@
118
118
  .fs-2xl {
119
119
  font-size: var(--fs-2xl);
120
120
  }
121
+ /* `text-overflow: ellipsis` is a no-op on an inline box, so a truncated bare
122
+ <Text> (default as="span") would overrun its container instead of clipping.
123
+ inline-block gives it a block formatting context so the ellipsis applies,
124
+ while max-width keeps it from overflowing the parent; on block elements
125
+ (as="p"/"div") these are harmless. */
121
126
  .truncate {
127
+ display: inline-block;
128
+ max-width: 100%;
122
129
  overflow: hidden;
123
130
  text-overflow: ellipsis;
124
131
  white-space: nowrap;
@@ -4,13 +4,16 @@
4
4
  // adapts to whatever space it's given (including inside a narrow column). This
5
5
  // is the "columns just adapt to available space" layout from the AppShell
6
6
  // demo, as a named component. `min` is the minimum column width, `gap` the
7
- // gutter.
7
+ // gutter. `maxCols` optionally caps how many columns the grid will ever show:
8
+ // it raises the effective per-column minimum to the width N columns would
9
+ // need, so auto-fit can never pack more than N across.
8
10
  import type { Snippet } from 'svelte';
9
11
 
10
12
  let {
11
13
  as = 'div',
12
14
  min = '14rem',
13
15
  gap = 'var(--sp-4)',
16
+ maxCols,
14
17
  class: klass = '',
15
18
  children,
16
19
  ...rest
@@ -18,13 +21,26 @@
18
21
  as?: 'div' | 'section' | 'ul' | 'ol';
19
22
  min?: string;
20
23
  gap?: string;
24
+ maxCols?: number;
21
25
  class?: string;
22
26
  children?: Snippet;
23
27
  [key: string]: unknown;
24
28
  } = $props();
29
+
30
+ let style = $derived(
31
+ maxCols != null
32
+ ? `--ag-min: ${min}; --ag-gap: ${gap}; --ag-cols: ${maxCols}; gap: ${gap}`
33
+ : `--ag-min: ${min}; gap: ${gap}`
34
+ );
25
35
  </script>
26
36
 
27
- <svelte:element this={as} class="autogrid-c {klass}" style="--ag-min: {min}; gap: {gap}" {...rest}>
37
+ <svelte:element
38
+ this={as}
39
+ class="autogrid-c {klass}"
40
+ class:capped={maxCols != null}
41
+ {style}
42
+ {...rest}
43
+ >
28
44
  {@render children?.()}
29
45
  </svelte:element>
30
46
 
@@ -33,4 +49,18 @@
33
49
  display: grid;
34
50
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--ag-min)), 1fr));
35
51
  }
52
+
53
+ /* Cap at N columns: the per-column floor becomes the larger of `min` and the
54
+ width each column gets when N share the row (minus the N-1 gaps), so
55
+ auto-fit stops adding tracks once N fit. `min(100%, …)` keeps it from
56
+ overflowing when the container is narrower than a single `min` track. */
57
+ .autogrid-c.capped {
58
+ grid-template-columns: repeat(
59
+ auto-fit,
60
+ minmax(
61
+ min(100%, max(var(--ag-min), (100% - (var(--ag-cols) - 1) * var(--ag-gap)) / var(--ag-cols))),
62
+ 1fr
63
+ )
64
+ );
65
+ }
36
66
  </style>
@@ -3,6 +3,7 @@ type $$ComponentProps = {
3
3
  as?: 'div' | 'section' | 'ul' | 'ol';
4
4
  min?: string;
5
5
  gap?: string;
6
+ maxCols?: number;
6
7
  class?: string;
7
8
  children?: Snippet;
8
9
  [key: string]: unknown;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dorsk/tsumikit",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Minimal, dependency-free Svelte 5 + pure-CSS UI kit. Token-driven atoms, molecules & layouts with theming out of the box.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -50,6 +50,7 @@
50
50
  "lint": "biome check .",
51
51
  "format": "biome check --write .",
52
52
  "package": "svelte-kit sync && svelte-package && publint",
53
+ "package:watch": "svelte-kit sync && svelte-package --watch",
53
54
  "prepublishOnly": "npm run package"
54
55
  },
55
56
  "peerDependencies": {