dssoca 0.2.0 → 0.5.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.
Files changed (37) hide show
  1. package/README.md +54 -18
  2. package/dist/components/Badge.svelte +43 -3
  3. package/dist/components/Badge.svelte.d.ts +3 -0
  4. package/dist/components/Button.svelte +46 -2
  5. package/dist/components/Button.svelte.d.ts +3 -0
  6. package/dist/components/Card.svelte +41 -5
  7. package/dist/components/Card.svelte.d.ts +5 -0
  8. package/dist/components/EmptyState.svelte +45 -34
  9. package/dist/components/EmptyState.svelte.d.ts +5 -0
  10. package/dist/components/Icon.svelte +17 -4
  11. package/dist/components/Icon.svelte.d.ts +7 -1
  12. package/dist/components/Input.svelte +56 -3
  13. package/dist/components/Input.svelte.d.ts +7 -0
  14. package/dist/components/LogStream.svelte +43 -2
  15. package/dist/components/LogStream.svelte.d.ts +3 -0
  16. package/dist/components/MetricTile.svelte +45 -3
  17. package/dist/components/MetricTile.svelte.d.ts +3 -0
  18. package/dist/components/ServiceCard.svelte +68 -3
  19. package/dist/components/ServiceCard.svelte.d.ts +3 -0
  20. package/dist/components/Sidebar.svelte +60 -5
  21. package/dist/components/Sidebar.svelte.d.ts +3 -0
  22. package/dist/components/Sparkline.svelte +26 -2
  23. package/dist/components/Sparkline.svelte.d.ts +5 -0
  24. package/dist/components/Toaster.svelte +91 -59
  25. package/dist/components/Toaster.svelte.d.ts +6 -16
  26. package/dist/components/Topbar.svelte +131 -6
  27. package/dist/components/Topbar.svelte.d.ts +3 -0
  28. package/dist/config.d.ts +32 -14
  29. package/dist/config.js +43 -17
  30. package/dist/dssoca.config.d.ts +50 -0
  31. package/dist/dssoca.config.js +39 -0
  32. package/dist/index.d.ts +2 -2
  33. package/dist/index.js +2 -2
  34. package/dist/theme.css +359 -396
  35. package/package.json +17 -3
  36. package/dist/components/PassocaMark.svelte +0 -15
  37. package/dist/components/PassocaMark.svelte.d.ts +0 -7
package/README.md CHANGED
@@ -1,16 +1,21 @@
1
1
  # dssoca
2
2
 
3
+ [![npm](https://img.shields.io/npm/v/dssoca.svg)](https://www.npmjs.com/package/dssoca)
4
+ [![CI](https://github.com/httpassoca/dssoca/actions/workflows/ci.yml/badge.svg)](https://github.com/httpassoca/dssoca/actions/workflows/ci.yml)
5
+ [![license](https://img.shields.io/npm/l/dssoca.svg)](./LICENSE)
6
+
3
7
  A Svelte 5 design system — **signal green on near-black, monospace-forward, zero border-radius**
4
8
  everywhere. Configured along two orthogonal axes:
5
9
 
6
- | Axis | Attribute | Values | Default |
7
- |-------------|----------------|---------------------|---------|
8
- | **Color** | `data-theme` | `dark` · `light` | `dark` |
9
- | **Density** | `data-density` | `comfy` · `compact` | `comfy` |
10
+ | Axis | Attribute | Values | Default |
11
+ |------------|----------------------|--------------------|---------|
12
+ | **Color** | `data-theme` | `dark` · `light` | `dark` |
13
+ | **Size** | `data-size-variant` | `sm` · `md` · `lg` | `md` |
10
14
 
11
- Components are thin wrappers over a token-driven `theme.css`; flip an axis on any ancestor
12
- (usually `<html>`) and everything below rescales/recolors. See [`DESIGN.md`](./DESIGN.md) for the
13
- full rationale and [`docs/tokens.md`](./docs/tokens.md) for the token reference.
15
+ Each component styles itself in a scoped block and consumes token-driven CSS custom properties;
16
+ flip an axis on any ancestor (usually `<html>`) and everything below rescales/recolors. Components
17
+ also take a per-instance `size` prop. See [`DESIGN.md`](./DESIGN.md) for the full rationale and
18
+ [`docs/tokens.md`](./docs/tokens.md) for the token reference.
14
19
 
15
20
  ## Install
16
21
 
@@ -44,11 +49,14 @@ Import the stylesheet once (global tokens + base styles), then use components:
44
49
  ```ts
45
50
  import { applyDesignConfig, designAttributes } from 'dssoca'
46
51
 
47
- // flip one or both axes; merges over current config; writes to <html>
48
- applyDesignConfig({ density: 'compact' }) // dense dashboard
49
- applyDesignConfig({ theme: 'light' }) // keeps density
52
+ // flip axes; merges over current config; writes to <html>
53
+ applyDesignConfig({ sizeVariant: 'sm' }) // global: everything small
54
+ applyDesignConfig({ theme: 'light' }) // keeps size
55
+ applyDesignConfig({ componentsSize: { Button: 'lg' } }) // per-component default
50
56
  ```
51
57
 
58
+ Per instance, just set the `size` prop: `<Button size="lg">`.
59
+
52
60
  SSR / no-flash — spread the attributes directly in markup instead of mutating the DOM:
53
61
 
54
62
  ```svelte
@@ -56,34 +64,62 @@ SSR / no-flash — spread the attributes directly in markup instead of mutating
56
64
  import { designAttributes } from 'dssoca'
57
65
  </script>
58
66
 
59
- <html {...designAttributes({ density: 'compact' })}>
67
+ <html {...designAttributes({ sizeVariant: 'sm' })}>
60
68
  ```
61
69
 
62
70
  ## What's in the box
63
71
 
64
- **Components:** `PassocaMark`, `Icon`, `Badge`, `Button`, `Input`, `Card`, `Sparkline`,
72
+ **Components:** `Icon`, `Badge`, `Button`, `Input`, `Card`, `Sparkline`,
65
73
  `ServiceCard`, `MetricTile`, `Topbar`, `Sidebar`, `LogStream`, `Toaster`, `EmptyState`.
66
74
 
67
75
  **Toasts:** `toast` (`.success` / `.error` / `.info`) + the `toasts` store — render once with
68
76
  `<Toaster />`.
69
77
 
70
- **Config:** `applyDesignConfig`, `designAttributes`, `getDesignConfig`, `defaultDesignConfig`, and
71
- the `ColorTheme` / `Density` / `DesignConfig` types.
78
+ **Config:** `dssocaConfig` (the manifest), `applyDesignConfig`, `designAttributes`,
79
+ `getDesignConfig`, `resolveComponentSize`, `defaultDesignConfig`, and the `ColorTheme` / `Size` /
80
+ `DesignConfig` / `ComponentsSize` types.
81
+
82
+ ## Accessibility
83
+
84
+ Targets **WCAG 2.2 AA**: native/keyboard-operable controls (Enter + Space), labelled
85
+ inputs (auto-associated ids, `aria-invalid` / `aria-describedby`), live-region toasts
86
+ (`role="status"`, `role="alert"` for errors), `aria-current` on active nav/tabs, decorative
87
+ icons/graphics `aria-hidden`, AA-contrast text tokens, and `prefers-reduced-motion` support
88
+ (motion-duration tokens collapse; the toast transition is guarded). Components are checked with
89
+ `vitest-axe` in unit tests and `@storybook/addon-a11y` in Storybook.
72
90
 
73
91
  ## House rules
74
92
 
75
93
  - **Zero border-radius.** Every radius token is `0` — never override.
76
- - New chrome reads density tokens (`--ss-*`), not hardcoded px, so it rescales with `data-density`.
94
+ - New chrome reads size tokens (`--ss-*`), not hardcoded px, so it rescales with `data-size-variant`.
95
+
96
+ ## Documentation
97
+
98
+ A custom documentation site lives in [`documentation/`](./documentation) (SvelteKit + mdsvex). It
99
+ dogfoods dssoca for its own chrome and covers the Introduction, Installation, Theming & config, a
100
+ live Tokens gallery, and a page per component that embeds the component's live Storybook story.
101
+
102
+ ```sh
103
+ pnpm docs:dev # docs site (run `pnpm storybook` alongside for the live demos)
104
+ pnpm docs:build # static build of the docs site
105
+ ```
106
+
107
+ The docs app is local-only and is **not** part of the published npm package.
77
108
 
78
109
  ## Develop
79
110
 
80
111
  ```sh
81
112
  pnpm install
82
- pnpm dev # showcase app with live theme + density toggles
83
- pnpm test # Vitest component/unit suite
84
- pnpm pack # build dist/ (svelte-package) + validate (publint)
113
+ pnpm dev # library SvelteKit app (stub landing)
114
+ pnpm storybook # interactive component explorer (:6006)
115
+ pnpm docs:dev # documentation site
116
+ pnpm test # Vitest component/unit suite
117
+ pnpm pack # build dist/ (svelte-package) + validate (publint)
85
118
  ```
86
119
 
120
+ See [`CONTRIBUTING.md`](./CONTRIBUTING.md) for the full workflow and [`CHANGELOG.md`](./CHANGELOG.md)
121
+ for release history.
122
+
87
123
  ## License
88
124
 
89
125
  [MIT](./LICENSE) © Rafael Passoca
@@ -1,16 +1,56 @@
1
1
  <script lang="ts">
2
2
  import type { Snippet } from 'svelte'
3
+ import { resolveComponentSize, type Size } from '../config.js'
3
4
 
4
5
  interface Props {
5
6
  tone?: 'up' | 'deg' | 'down' | 'info'
7
+ /** Token size (sm|md|lg); inherits the global size when unset. */
8
+ size?: Size
6
9
  children: Snippet
7
10
  }
8
- let { tone = 'info', children }: Props = $props()
11
+ let { tone = 'info', size, children }: Props = $props()
9
12
 
10
13
  const hasDot = $derived(['up', 'deg', 'down', 'info'].includes(tone))
11
14
  </script>
12
15
 
13
- <span class="ss-badge {tone}">
14
- {#if hasDot}<span class="dot"></span>{/if}
16
+ <span class="ss-badge {tone}" data-size-variant={resolveComponentSize('Badge', size)}>
17
+ {#if hasDot}<span class="dot" aria-hidden="true"></span>{/if}
15
18
  {@render children()}
16
19
  </span>
20
+
21
+ <style>.ss-badge {
22
+ font-family: var(--ss-font-mono);
23
+ font-size: var(--ss-ui-xs);
24
+ padding: var(--ss-badge-py) var(--ss-badge-px);
25
+ letter-spacing: 0.05em;
26
+ display: inline-flex;
27
+ align-items: center;
28
+ gap: 6px;
29
+ text-transform: lowercase;
30
+ border: 1px solid var(--ss-line);
31
+ }
32
+ .ss-badge.up {
33
+ background: rgba(102, 239, 115, 0.12);
34
+ color: var(--ss-primary);
35
+ border-color: rgba(102, 239, 115, 0.4);
36
+ }
37
+ .ss-badge.deg {
38
+ background: rgba(224, 195, 106, 0.12);
39
+ color: var(--ss-yellow);
40
+ border-color: rgba(224, 195, 106, 0.4);
41
+ }
42
+ .ss-badge.down {
43
+ background: rgba(255, 92, 92, 0.12);
44
+ color: var(--ss-red);
45
+ border-color: rgba(255, 92, 92, 0.4);
46
+ }
47
+ .ss-badge.info {
48
+ background: rgba(102, 217, 239, 0.12);
49
+ color: var(--ss-cyan);
50
+ border-color: rgba(102, 217, 239, 0.4);
51
+ }
52
+ .ss-badge .dot {
53
+ width: 5px;
54
+ height: 5px;
55
+ background: currentColor;
56
+ }</style>
@@ -1,6 +1,9 @@
1
1
  import type { Snippet } from 'svelte';
2
+ import { type Size } from '../config.js';
2
3
  interface Props {
3
4
  tone?: 'up' | 'deg' | 'down' | 'info';
5
+ /** Token size (sm|md|lg); inherits the global size when unset. */
6
+ size?: Size;
4
7
  children: Snippet;
5
8
  }
6
9
  declare const Badge: import("svelte").Component<Props, {}, "">;
@@ -1,16 +1,60 @@
1
1
  <script lang="ts">
2
2
  import type { Snippet } from 'svelte'
3
+ import { resolveComponentSize, type Size } from '../config.js'
3
4
 
4
5
  interface Props {
5
6
  variant?: 'primary' | 'secondary' | 'ghost'
6
7
  type?: 'button' | 'submit' | 'reset'
7
8
  disabled?: boolean
8
9
  onclick?: (e: MouseEvent) => void
10
+ /** Token size (sm|md|lg); inherits the global size when unset. */
11
+ size?: Size
9
12
  children: Snippet
10
13
  }
11
- let { variant = 'secondary', type = 'button', disabled = false, onclick, children }: Props = $props()
14
+ let { variant = 'secondary', type = 'button', disabled = false, onclick, size, children }: Props = $props()
12
15
  </script>
13
16
 
14
- <button class="ss-btn {variant}" {type} {disabled} {onclick}>
17
+ <button class="ss-btn {variant}" {type} {disabled} {onclick} data-size-variant={resolveComponentSize('Button', size)}>
15
18
  {@render children()}
16
19
  </button>
20
+
21
+ <style>.ss-btn {
22
+ font-family: var(--ss-font-body);
23
+ font-size: var(--ss-control-font);
24
+ line-height: 1;
25
+ font-weight: 500;
26
+ padding: var(--ss-control-py) var(--ss-control-px);
27
+ border: 1px solid var(--ss-line);
28
+ background: transparent;
29
+ color: var(--ss-fg);
30
+ cursor: pointer;
31
+ display: inline-flex;
32
+ align-items: center;
33
+ gap: 6px;
34
+ transition: all var(--ss-dur-fast) var(--ss-ease);
35
+ }
36
+ .ss-btn:hover {
37
+ background: var(--ss-hover);
38
+ border-color: var(--ss-line-strong);
39
+ }
40
+ .ss-btn.primary {
41
+ background: var(--ss-primary);
42
+ color: var(--ss-fg-on-primary);
43
+ border-color: var(--ss-primary);
44
+ font-weight: 600;
45
+ }
46
+ .ss-btn.primary:hover {
47
+ background: var(--ss-primary-hover);
48
+ border-color: var(--ss-primary-hover);
49
+ box-shadow: var(--ss-shadow-glow);
50
+ }
51
+ .ss-btn.ghost {
52
+ border-color: transparent;
53
+ color: var(--ss-fg-muted);
54
+ padding: var(--ss-control-py) var(--ss-gap-sm);
55
+ }
56
+ .ss-btn.ghost:hover {
57
+ color: var(--ss-fg);
58
+ background: var(--ss-hover);
59
+ border-color: transparent;
60
+ }</style>
@@ -1,9 +1,12 @@
1
1
  import type { Snippet } from 'svelte';
2
+ import { type Size } from '../config.js';
2
3
  interface Props {
3
4
  variant?: 'primary' | 'secondary' | 'ghost';
4
5
  type?: 'button' | 'submit' | 'reset';
5
6
  disabled?: boolean;
6
7
  onclick?: (e: MouseEvent) => void;
8
+ /** Token size (sm|md|lg); inherits the global size when unset. */
9
+ size?: Size;
7
10
  children: Snippet;
8
11
  }
9
12
  declare const Button: import("svelte").Component<Props, {}, "">;
@@ -1,26 +1,62 @@
1
1
  <script lang="ts">
2
2
  import type { Snippet } from 'svelte'
3
+ import { resolveComponentSize, type Size } from '../config.js'
3
4
 
4
5
  interface Props {
5
6
  title?: string
6
7
  meta?: string
7
8
  action?: Snippet
8
9
  children: Snippet
10
+ /** Token size (sm|md|lg); inherits the global size when unset. */
11
+ size?: Size
12
+ /** Heading level for the title (aria-level), for correct document outline. */
13
+ titleLevel?: number
9
14
  }
10
- let { title, meta, action, children }: Props = $props()
15
+ let { title, meta, action, children, size, titleLevel = 3 }: Props = $props()
11
16
  </script>
12
17
 
13
- <div class="ss-panel">
18
+ <div class="ss-panel" data-size-variant={resolveComponentSize('Card', size)}>
14
19
  {#if title}
15
- <div class="ss-panel-head">
16
- <div class="title">{title}</div>
20
+ <div class="head">
21
+ <div class="title" role="heading" aria-level={titleLevel}>{title}</div>
17
22
  <div style="display:flex;gap:12px;align-items:center">
18
23
  {#if meta}<div class="meta">{meta}</div>{/if}
19
24
  {#if action}{@render action()}{/if}
20
25
  </div>
21
26
  </div>
22
27
  {/if}
23
- <div class="ss-panel-body">
28
+ <div class="body">
24
29
  {@render children()}
25
30
  </div>
26
31
  </div>
32
+
33
+ <style>.ss-panel {
34
+ border: 1px solid var(--ss-line);
35
+ background: var(--ss-bg-elev);
36
+ }
37
+
38
+ .head {
39
+ padding: var(--ss-panel-head-py) var(--ss-panel-head-px);
40
+ border-bottom: 1px solid var(--ss-line);
41
+ display: flex;
42
+ align-items: center;
43
+ justify-content: space-between;
44
+ font-family: var(--ss-font-mono);
45
+ font-size: var(--ss-ui-sm);
46
+ color: var(--ss-fg-faint);
47
+ text-transform: uppercase;
48
+ letter-spacing: 0.06em;
49
+ }
50
+ .head .title {
51
+ color: var(--ss-fg);
52
+ letter-spacing: 0.06em;
53
+ }
54
+ .head .meta {
55
+ color: var(--ss-fg-faint);
56
+ text-transform: lowercase;
57
+ letter-spacing: 0.04em;
58
+ }
59
+
60
+ .body {
61
+ padding: var(--ss-panel-body-py) var(--ss-panel-body-px);
62
+ }</style>
@@ -1,9 +1,14 @@
1
1
  import type { Snippet } from 'svelte';
2
+ import { type Size } from '../config.js';
2
3
  interface Props {
3
4
  title?: string;
4
5
  meta?: string;
5
6
  action?: Snippet;
6
7
  children: Snippet;
8
+ /** Token size (sm|md|lg); inherits the global size when unset. */
9
+ size?: Size;
10
+ /** Heading level for the title (aria-level), for correct document outline. */
11
+ titleLevel?: number;
7
12
  }
8
13
  declare const Card: import("svelte").Component<Props, {}, "">;
9
14
  type Card = ReturnType<typeof Card>;
@@ -1,5 +1,6 @@
1
1
  <script lang="ts">
2
2
  import type { Snippet } from 'svelte'
3
+ import { resolveComponentSize, type Size } from '../config.js'
3
4
 
4
5
  interface Props {
5
6
  variant?: 'empty' | 'error'
@@ -7,44 +8,54 @@
7
8
  message?: string
8
9
  icon?: string
9
10
  action?: Snippet
11
+ /** Token size (sm|md|lg); inherits the global size when unset. */
12
+ size?: Size
13
+ /** Heading level for the title (aria-level), for correct document outline. */
14
+ headingLevel?: number
10
15
  }
11
- let { variant = 'empty', title, message, icon, action }: Props = $props()
16
+ let { variant = 'empty', title, message, icon, action, size, headingLevel = 2 }: Props = $props()
12
17
  </script>
13
18
 
14
- <div class="ss-empty {variant}">
15
- {#if icon}<div class="ic">{icon}</div>{/if}
16
- <p class="title">{title}</p>
19
+ <div
20
+ class="ss-empty {variant}"
21
+ data-size-variant={resolveComponentSize('EmptyState', size)}
22
+ role={variant === 'error' ? 'alert' : undefined}
23
+ >
24
+ {#if icon}<div class="ic" aria-hidden="true">{icon}</div>{/if}
25
+ <p class="title" role="heading" aria-level={headingLevel}>{title}</p>
17
26
  {#if message}<p class="msg">{message}</p>{/if}
18
27
  {#if action}<div class="act">{@render action()}</div>{/if}
19
28
  </div>
20
29
 
21
- <style>
22
- .ss-empty {
23
- display: flex;
24
- flex-direction: column;
25
- align-items: center;
26
- gap: var(--ss-s-3);
27
- text-align: center;
28
- padding: var(--ss-s-12) var(--ss-s-4);
29
- }
30
- .ic {
31
- font-size: 40px;
32
- line-height: 1;
33
- margin-bottom: var(--ss-s-1);
34
- }
35
- .title {
36
- margin: 0;
37
- font-family: var(--ss-font-display);
38
- font-size: var(--ss-size-h2);
39
- color: var(--ss-fg);
40
- }
41
- .error .title { color: var(--ss-red); }
42
- .msg {
43
- margin: 0;
44
- color: var(--ss-fg-muted);
45
- font-size: var(--ss-ui-md);
46
- max-width: 40ch;
47
- line-height: var(--ss-leading);
48
- }
49
- .act { margin-top: var(--ss-s-4); }
50
- </style>
30
+ <style>.ss-empty {
31
+ display: flex;
32
+ flex-direction: column;
33
+ align-items: center;
34
+ gap: var(--ss-s-3);
35
+ text-align: center;
36
+ padding: var(--ss-s-12) var(--ss-s-4);
37
+ }
38
+ .ss-empty .ic {
39
+ font-size: 40px;
40
+ line-height: 1;
41
+ margin-bottom: var(--ss-s-1);
42
+ }
43
+ .ss-empty .title {
44
+ margin: 0;
45
+ font-family: var(--ss-font-display);
46
+ font-size: var(--ss-size-h2);
47
+ color: var(--ss-fg);
48
+ }
49
+ .ss-empty.error .title {
50
+ color: var(--ss-red);
51
+ }
52
+ .ss-empty .msg {
53
+ margin: 0;
54
+ color: var(--ss-fg-muted);
55
+ font-size: var(--ss-ui-md);
56
+ max-width: 40ch;
57
+ line-height: var(--ss-leading);
58
+ }
59
+ .ss-empty .act {
60
+ margin-top: var(--ss-s-4);
61
+ }</style>
@@ -1,10 +1,15 @@
1
1
  import type { Snippet } from 'svelte';
2
+ import { type Size } from '../config.js';
2
3
  interface Props {
3
4
  variant?: 'empty' | 'error';
4
5
  title: string;
5
6
  message?: string;
6
7
  icon?: string;
7
8
  action?: Snippet;
9
+ /** Token size (sm|md|lg); inherits the global size when unset. */
10
+ size?: Size;
11
+ /** Heading level for the title (aria-level), for correct document outline. */
12
+ headingLevel?: number;
8
13
  }
9
14
  declare const EmptyState: import("svelte").Component<Props, {}, "">;
10
15
  type EmptyState = ReturnType<typeof EmptyState>;
@@ -22,25 +22,38 @@
22
22
  </script>
23
23
 
24
24
  <script lang="ts">
25
+ import { resolveComponentSize, type Size } from '../config.js'
26
+
25
27
  interface Props {
26
28
  name: IconName
27
- size?: number
29
+ /** Token-driven size (sm|md|lg); inherits the active size when unset. */
30
+ size?: Size
31
+ /** Explicit pixel size — overrides the token sizing. */
32
+ px?: number
33
+ /** Accessible name; when set the icon is exposed to AT (role="img"). Omit for decorative icons (default: aria-hidden). */
34
+ title?: string
28
35
  class?: string
29
36
  }
30
- let { name, size = 16, class: cls = '' }: Props = $props()
37
+ let { name, size, px, title, class: cls = '' }: Props = $props()
38
+
39
+ const dim = $derived(px != null ? `${px}px` : 'var(--ss-icon)')
31
40
  </script>
32
41
 
33
42
  <!-- eslint-disable-next-line svelte/no-at-html-tags -->
34
43
  <svg
35
44
  viewBox="0 0 24 24"
36
- width={size}
37
- height={size}
38
45
  fill="none"
39
46
  stroke="currentColor"
40
47
  stroke-width="2"
41
48
  stroke-linecap="square"
42
49
  stroke-linejoin="miter"
43
50
  class={cls}
51
+ data-size-variant={resolveComponentSize('Icon', size)}
52
+ style="width:{dim};height:{dim}"
53
+ role={title ? 'img' : undefined}
54
+ aria-label={title}
55
+ aria-hidden={title ? undefined : 'true'}
56
+ focusable="false"
44
57
  >
45
58
  {@html PATHS[name] ?? ''}
46
59
  </svg>
@@ -1,8 +1,14 @@
1
1
  export declare const PATHS: Record<string, string>;
2
2
  export type IconName = keyof typeof PATHS;
3
+ import { type Size } from '../config.js';
3
4
  interface Props {
4
5
  name: IconName;
5
- size?: number;
6
+ /** Token-driven size (sm|md|lg); inherits the active size when unset. */
7
+ size?: Size;
8
+ /** Explicit pixel size — overrides the token sizing. */
9
+ px?: number;
10
+ /** Accessible name; when set the icon is exposed to AT (role="img"). Omit for decorative icons (default: aria-hidden). */
11
+ title?: string;
6
12
  class?: string;
7
13
  }
8
14
  declare const Icon: import("svelte").Component<Props, {}, "">;
@@ -1,4 +1,6 @@
1
1
  <script lang="ts">
2
+ import { resolveComponentSize, type Size } from '../config.js'
3
+
2
4
  interface Props {
3
5
  label?: string
4
6
  id?: string
@@ -9,6 +11,12 @@
9
11
  required?: boolean
10
12
  disabled?: boolean
11
13
  oninput?: (e: Event & { currentTarget: HTMLInputElement }) => void
14
+ /** Token size (sm|md|lg); inherits the global size when unset. */
15
+ size?: Size
16
+ /** Marks the field invalid for assistive tech (aria-invalid). */
17
+ invalid?: boolean
18
+ /** id(s) of element(s) describing the field (aria-describedby) — e.g. hint/error text. */
19
+ describedby?: string
12
20
  }
13
21
  let {
14
22
  label,
@@ -20,34 +28,79 @@
20
28
  required = false,
21
29
  disabled = false,
22
30
  oninput,
31
+ size,
32
+ invalid,
33
+ describedby,
23
34
  }: Props = $props()
35
+
36
+ // Guarantee a label↔input association even when no `id` is passed.
37
+ const uid = $props.id()
38
+ const inputId = $derived(id ?? uid)
24
39
  </script>
25
40
 
26
41
  {#if label}
27
- <label class="ss-field" for={id}>
42
+ <label class="ss-field" for={inputId} data-size-variant={resolveComponentSize('Input', size)}>
28
43
  <span class="lbl">{label}</span>
29
44
  <input
30
45
  class="ss-input"
31
- {id}
46
+ id={inputId}
32
47
  {name}
33
48
  {type}
34
49
  bind:value
35
50
  {placeholder}
36
51
  {required}
37
52
  {disabled}
53
+ aria-invalid={invalid || undefined}
54
+ aria-describedby={describedby}
38
55
  {oninput}
39
56
  />
40
57
  </label>
41
58
  {:else}
42
59
  <input
43
60
  class="ss-input"
44
- {id}
61
+ data-size-variant={resolveComponentSize('Input', size)}
62
+ id={inputId}
45
63
  {name}
46
64
  {type}
47
65
  bind:value
48
66
  {placeholder}
49
67
  {required}
50
68
  {disabled}
69
+ aria-invalid={invalid || undefined}
70
+ aria-describedby={describedby}
51
71
  {oninput}
52
72
  />
53
73
  {/if}
74
+
75
+ <style>.ss-input {
76
+ font-family: var(--ss-font-body);
77
+ font-size: var(--ss-input-font);
78
+ background: transparent;
79
+ color: var(--ss-fg);
80
+ border: 1px solid var(--ss-line);
81
+ padding: var(--ss-input-py) var(--ss-input-px);
82
+ width: 100%;
83
+ transition: all 0.2s var(--ss-ease);
84
+ }
85
+ .ss-input:focus {
86
+ outline: none;
87
+ border-color: var(--ss-primary);
88
+ box-shadow: 0 0 0 3px var(--ss-primary-soft);
89
+ }
90
+ .ss-input::placeholder {
91
+ font-style: italic;
92
+ color: var(--ss-fg-faint);
93
+ }
94
+
95
+ .ss-field {
96
+ display: flex;
97
+ flex-direction: column;
98
+ gap: 6px;
99
+ }
100
+ .ss-field .lbl {
101
+ font-family: var(--ss-font-mono);
102
+ font-size: var(--ss-ui-xs);
103
+ color: var(--ss-fg-muted);
104
+ text-transform: uppercase;
105
+ letter-spacing: 0.08em;
106
+ }</style>
@@ -1,3 +1,4 @@
1
+ import { type Size } from '../config.js';
1
2
  interface Props {
2
3
  label?: string;
3
4
  id?: string;
@@ -10,6 +11,12 @@ interface Props {
10
11
  oninput?: (e: Event & {
11
12
  currentTarget: HTMLInputElement;
12
13
  }) => void;
14
+ /** Token size (sm|md|lg); inherits the global size when unset. */
15
+ size?: Size;
16
+ /** Marks the field invalid for assistive tech (aria-invalid). */
17
+ invalid?: boolean;
18
+ /** id(s) of element(s) describing the field (aria-describedby) — e.g. hint/error text. */
19
+ describedby?: string;
13
20
  }
14
21
  declare const Input: import("svelte").Component<Props, {}, "value">;
15
22
  type Input = ReturnType<typeof Input>;