dssoca 0.1.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 (38) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +89 -0
  3. package/dist/components/Badge.svelte +16 -0
  4. package/dist/components/Badge.svelte.d.ts +8 -0
  5. package/dist/components/Button.svelte +16 -0
  6. package/dist/components/Button.svelte.d.ts +11 -0
  7. package/dist/components/Card.svelte +26 -0
  8. package/dist/components/Card.svelte.d.ts +10 -0
  9. package/dist/components/EmptyState.svelte +50 -0
  10. package/dist/components/EmptyState.svelte.d.ts +11 -0
  11. package/dist/components/Icon.svelte +46 -0
  12. package/dist/components/Icon.svelte.d.ts +10 -0
  13. package/dist/components/Input.svelte +53 -0
  14. package/dist/components/Input.svelte.d.ts +16 -0
  15. package/dist/components/LogStream.svelte +61 -0
  16. package/dist/components/LogStream.svelte.d.ts +14 -0
  17. package/dist/components/MetricTile.svelte +20 -0
  18. package/dist/components/MetricTile.svelte.d.ts +10 -0
  19. package/dist/components/PassocaMark.svelte +15 -0
  20. package/dist/components/PassocaMark.svelte.d.ts +7 -0
  21. package/dist/components/ServiceCard.svelte +44 -0
  22. package/dist/components/ServiceCard.svelte.d.ts +11 -0
  23. package/dist/components/Sidebar.svelte +49 -0
  24. package/dist/components/Sidebar.svelte.d.ts +20 -0
  25. package/dist/components/Sparkline.svelte +15 -0
  26. package/dist/components/Sparkline.svelte.d.ts +7 -0
  27. package/dist/components/Toaster.svelte +72 -0
  28. package/dist/components/Toaster.svelte.d.ts +18 -0
  29. package/dist/components/Topbar.svelte +60 -0
  30. package/dist/components/Topbar.svelte.d.ts +9 -0
  31. package/dist/config.d.ts +34 -0
  32. package/dist/config.js +42 -0
  33. package/dist/index.d.ts +16 -0
  34. package/dist/index.js +16 -0
  35. package/dist/theme.css +610 -0
  36. package/dist/toast.svelte.d.ts +25 -0
  37. package/dist/toast.svelte.js +32 -0
  38. package/package.json +68 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rafael Passoca
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,89 @@
1
+ # dssoca
2
+
3
+ A Svelte 5 design system — **signal green on near-black, monospace-forward, zero border-radius**
4
+ everywhere. Configured along two orthogonal axes:
5
+
6
+ | Axis | Attribute | Values | Default |
7
+ |-------------|----------------|---------------------|---------|
8
+ | **Color** | `data-theme` | `dark` · `light` | `dark` |
9
+ | **Density** | `data-density` | `comfy` · `compact` | `comfy` |
10
+
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.
14
+
15
+ ## Install
16
+
17
+ ```sh
18
+ npm i dssoca
19
+ ```
20
+
21
+ Svelte 5 is a peer dependency:
22
+
23
+ ```sh
24
+ npm i -D svelte@^5
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ Import the stylesheet once (global tokens + base styles), then use components:
30
+
31
+ ```svelte
32
+ <script>
33
+ import { Button, Card, toast } from 'dssoca'
34
+ import 'dssoca/theme.css'
35
+ </script>
36
+
37
+ <Card title="Hello">
38
+ <Button onclick={() => toast.success('it works')}>Click</Button>
39
+ </Card>
40
+ ```
41
+
42
+ ### Configure the axes from code
43
+
44
+ ```ts
45
+ import { applyDesignConfig, designAttributes } from 'dssoca'
46
+
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
50
+ ```
51
+
52
+ SSR / no-flash — spread the attributes directly in markup instead of mutating the DOM:
53
+
54
+ ```svelte
55
+ <script>
56
+ import { designAttributes } from 'dssoca'
57
+ </script>
58
+
59
+ <html {...designAttributes({ density: 'compact' })}>
60
+ ```
61
+
62
+ ## What's in the box
63
+
64
+ **Components:** `PassocaMark`, `Icon`, `Badge`, `Button`, `Input`, `Card`, `Sparkline`,
65
+ `ServiceCard`, `MetricTile`, `Topbar`, `Sidebar`, `LogStream`, `Toaster`, `EmptyState`.
66
+
67
+ **Toasts:** `toast` (`.success` / `.error` / `.info`) + the `toasts` store — render once with
68
+ `<Toaster />`.
69
+
70
+ **Config:** `applyDesignConfig`, `designAttributes`, `getDesignConfig`, `defaultDesignConfig`, and
71
+ the `ColorTheme` / `Density` / `DesignConfig` types.
72
+
73
+ ## House rules
74
+
75
+ - **Zero border-radius.** Every radius token is `0` — never override.
76
+ - New chrome reads density tokens (`--hs-*`), not hardcoded px, so it rescales with `data-density`.
77
+
78
+ ## Develop
79
+
80
+ ```sh
81
+ 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)
85
+ ```
86
+
87
+ ## License
88
+
89
+ [MIT](./LICENSE) © Rafael Passoca
@@ -0,0 +1,16 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte'
3
+
4
+ interface Props {
5
+ tone?: 'up' | 'deg' | 'down' | 'info'
6
+ children: Snippet
7
+ }
8
+ let { tone = 'info', children }: Props = $props()
9
+
10
+ const hasDot = $derived(['up', 'deg', 'down', 'info'].includes(tone))
11
+ </script>
12
+
13
+ <span class="hub-badge {tone}">
14
+ {#if hasDot}<span class="dot"></span>{/if}
15
+ {@render children()}
16
+ </span>
@@ -0,0 +1,8 @@
1
+ import type { Snippet } from 'svelte';
2
+ interface Props {
3
+ tone?: 'up' | 'deg' | 'down' | 'info';
4
+ children: Snippet;
5
+ }
6
+ declare const Badge: import("svelte").Component<Props, {}, "">;
7
+ type Badge = ReturnType<typeof Badge>;
8
+ export default Badge;
@@ -0,0 +1,16 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte'
3
+
4
+ interface Props {
5
+ variant?: 'primary' | 'secondary' | 'ghost'
6
+ type?: 'button' | 'submit' | 'reset'
7
+ disabled?: boolean
8
+ onclick?: (e: MouseEvent) => void
9
+ children: Snippet
10
+ }
11
+ let { variant = 'secondary', type = 'button', disabled = false, onclick, children }: Props = $props()
12
+ </script>
13
+
14
+ <button class="hub-btn {variant}" {type} {disabled} {onclick}>
15
+ {@render children()}
16
+ </button>
@@ -0,0 +1,11 @@
1
+ import type { Snippet } from 'svelte';
2
+ interface Props {
3
+ variant?: 'primary' | 'secondary' | 'ghost';
4
+ type?: 'button' | 'submit' | 'reset';
5
+ disabled?: boolean;
6
+ onclick?: (e: MouseEvent) => void;
7
+ children: Snippet;
8
+ }
9
+ declare const Button: import("svelte").Component<Props, {}, "">;
10
+ type Button = ReturnType<typeof Button>;
11
+ export default Button;
@@ -0,0 +1,26 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte'
3
+
4
+ interface Props {
5
+ title?: string
6
+ meta?: string
7
+ action?: Snippet
8
+ children: Snippet
9
+ }
10
+ let { title, meta, action, children }: Props = $props()
11
+ </script>
12
+
13
+ <div class="hub-panel">
14
+ {#if title}
15
+ <div class="hub-panel-head">
16
+ <div class="title">{title}</div>
17
+ <div style="display:flex;gap:12px;align-items:center">
18
+ {#if meta}<div class="meta">{meta}</div>{/if}
19
+ {#if action}{@render action()}{/if}
20
+ </div>
21
+ </div>
22
+ {/if}
23
+ <div class="hub-panel-body">
24
+ {@render children()}
25
+ </div>
26
+ </div>
@@ -0,0 +1,10 @@
1
+ import type { Snippet } from 'svelte';
2
+ interface Props {
3
+ title?: string;
4
+ meta?: string;
5
+ action?: Snippet;
6
+ children: Snippet;
7
+ }
8
+ declare const Card: import("svelte").Component<Props, {}, "">;
9
+ type Card = ReturnType<typeof Card>;
10
+ export default Card;
@@ -0,0 +1,50 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte'
3
+
4
+ interface Props {
5
+ variant?: 'empty' | 'error'
6
+ title: string
7
+ message?: string
8
+ icon?: string
9
+ action?: Snippet
10
+ }
11
+ let { variant = 'empty', title, message, icon, action }: Props = $props()
12
+ </script>
13
+
14
+ <div class="hub-empty {variant}">
15
+ {#if icon}<div class="ic">{icon}</div>{/if}
16
+ <p class="title">{title}</p>
17
+ {#if message}<p class="msg">{message}</p>{/if}
18
+ {#if action}<div class="act">{@render action()}</div>{/if}
19
+ </div>
20
+
21
+ <style>
22
+ .hub-empty {
23
+ display: flex;
24
+ flex-direction: column;
25
+ align-items: center;
26
+ gap: var(--hs-s-3);
27
+ text-align: center;
28
+ padding: var(--hs-s-12) var(--hs-s-4);
29
+ }
30
+ .ic {
31
+ font-size: 40px;
32
+ line-height: 1;
33
+ margin-bottom: var(--hs-s-1);
34
+ }
35
+ .title {
36
+ margin: 0;
37
+ font-family: var(--hs-font-display);
38
+ font-size: var(--hs-size-h2);
39
+ color: var(--hs-fg);
40
+ }
41
+ .error .title { color: var(--hs-red); }
42
+ .msg {
43
+ margin: 0;
44
+ color: var(--hs-fg-muted);
45
+ font-size: var(--hs-ui-md);
46
+ max-width: 40ch;
47
+ line-height: var(--hs-leading);
48
+ }
49
+ .act { margin-top: var(--hs-s-4); }
50
+ </style>
@@ -0,0 +1,11 @@
1
+ import type { Snippet } from 'svelte';
2
+ interface Props {
3
+ variant?: 'empty' | 'error';
4
+ title: string;
5
+ message?: string;
6
+ icon?: string;
7
+ action?: Snippet;
8
+ }
9
+ declare const EmptyState: import("svelte").Component<Props, {}, "">;
10
+ type EmptyState = ReturnType<typeof EmptyState>;
11
+ export default EmptyState;
@@ -0,0 +1,46 @@
1
+ <script module lang="ts">
2
+ export const PATHS: Record<string, string> = {
3
+ grid: '<rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/><rect x="3" y="14" width="7" height="7"/><rect x="14" y="14" width="7" height="7"/>',
4
+ activity: '<path d="M3 12h4l3-8 4 16 3-8h4"/>',
5
+ database: '<rect x="3" y="4" width="18" height="16"/><path d="M3 9h18M8 4v5"/>',
6
+ logs: '<path d="M4 6h16M4 12h16M4 18h10"/>',
7
+ terminal: '<rect x="3" y="5" width="18" height="14"/><path d="M3 9h18M7 14h4"/>',
8
+ settings: '<circle cx="12" cy="12" r="3"/><path d="M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M4.9 19.1L7 17M17 7l2.1-2.1"/>',
9
+ user: '<circle cx="12" cy="8" r="4"/><path d="M4 21c0-4 4-7 8-7s8 3 8 7"/>',
10
+ arrow: '<path d="M5 12h14M13 5l7 7-7 7"/>',
11
+ external: '<path d="M7 17L17 7M9 7h8v8"/>',
12
+ film: '<rect x="3" y="4" width="18" height="16"/><path d="M3 8h4M3 16h4M17 8h4M17 16h4M3 12h18"/>',
13
+ note: '<rect x="4" y="3" width="16" height="18"/><path d="M8 8h8M8 12h8M8 16h6"/>',
14
+ book: '<path d="M6 4h11a1 1 0 011 1v15H7a1 1 0 01-1-1z"/><path d="M17 20a2 2 0 002-2V6a2 2 0 00-2-2"/><path d="M9 8h5"/>',
15
+ check: '<path d="M5 12l4 4L19 6"/>',
16
+ cup: '<path d="M4 8h12v6a4 4 0 01-4 4H8a4 4 0 01-4-4z"/><path d="M16 10h2a2 2 0 010 4h-2M6 4v2M10 4v2M14 4v2"/>',
17
+ wallet: '<rect x="3" y="6" width="18" height="14"/><path d="M3 10h18M17 14h2"/>',
18
+ target: '<circle cx="12" cy="12" r="9"/><circle cx="12" cy="12" r="5"/><circle cx="12" cy="12" r="1.5" fill="currentColor"/>',
19
+ }
20
+
21
+ export type IconName = keyof typeof PATHS
22
+ </script>
23
+
24
+ <script lang="ts">
25
+ interface Props {
26
+ name: IconName
27
+ size?: number
28
+ class?: string
29
+ }
30
+ let { name, size = 16, class: cls = '' }: Props = $props()
31
+ </script>
32
+
33
+ <!-- eslint-disable-next-line svelte/no-at-html-tags -->
34
+ <svg
35
+ viewBox="0 0 24 24"
36
+ width={size}
37
+ height={size}
38
+ fill="none"
39
+ stroke="currentColor"
40
+ stroke-width="2"
41
+ stroke-linecap="square"
42
+ stroke-linejoin="miter"
43
+ class={cls}
44
+ >
45
+ {@html PATHS[name] ?? ''}
46
+ </svg>
@@ -0,0 +1,10 @@
1
+ export declare const PATHS: Record<string, string>;
2
+ export type IconName = keyof typeof PATHS;
3
+ interface Props {
4
+ name: IconName;
5
+ size?: number;
6
+ class?: string;
7
+ }
8
+ declare const Icon: import("svelte").Component<Props, {}, "">;
9
+ type Icon = ReturnType<typeof Icon>;
10
+ export default Icon;
@@ -0,0 +1,53 @@
1
+ <script lang="ts">
2
+ interface Props {
3
+ label?: string
4
+ id?: string
5
+ name?: string
6
+ type?: string
7
+ value?: string
8
+ placeholder?: string
9
+ required?: boolean
10
+ disabled?: boolean
11
+ oninput?: (e: Event & { currentTarget: HTMLInputElement }) => void
12
+ }
13
+ let {
14
+ label,
15
+ id,
16
+ name,
17
+ type = 'text',
18
+ value = $bindable(''),
19
+ placeholder = '',
20
+ required = false,
21
+ disabled = false,
22
+ oninput,
23
+ }: Props = $props()
24
+ </script>
25
+
26
+ {#if label}
27
+ <label class="hub-field" for={id}>
28
+ <span class="lbl">{label}</span>
29
+ <input
30
+ class="hub-input"
31
+ {id}
32
+ {name}
33
+ {type}
34
+ bind:value
35
+ {placeholder}
36
+ {required}
37
+ {disabled}
38
+ {oninput}
39
+ />
40
+ </label>
41
+ {:else}
42
+ <input
43
+ class="hub-input"
44
+ {id}
45
+ {name}
46
+ {type}
47
+ bind:value
48
+ {placeholder}
49
+ {required}
50
+ {disabled}
51
+ {oninput}
52
+ />
53
+ {/if}
@@ -0,0 +1,16 @@
1
+ interface Props {
2
+ label?: string;
3
+ id?: string;
4
+ name?: string;
5
+ type?: string;
6
+ value?: string;
7
+ placeholder?: string;
8
+ required?: boolean;
9
+ disabled?: boolean;
10
+ oninput?: (e: Event & {
11
+ currentTarget: HTMLInputElement;
12
+ }) => void;
13
+ }
14
+ declare const Input: import("svelte").Component<Props, {}, "value">;
15
+ type Input = ReturnType<typeof Input>;
16
+ export default Input;
@@ -0,0 +1,61 @@
1
+ <script lang="ts">
2
+ import { tick, untrack } from 'svelte'
3
+
4
+ interface LogLine { id: number; t: string; lvl: string; svc: string; msg: string }
5
+
6
+ interface Props {
7
+ live?: boolean
8
+ initialLines?: Omit<LogLine, 'id'>[]
9
+ }
10
+
11
+ const TEMPLATES = [
12
+ { lvl: 'info', svc: '[movies-api]', msg: 'GET /movies?status=to_watch — 3 rows · 4ms' },
13
+ { lvl: 'ok', svc: '[hub]', msg: 'GET /api/auth/session — 8ms' },
14
+ { lvl: 'info', svc: '[hub]', msg: 'session refresh — user=rafael' },
15
+ { lvl: 'warn', svc: '[caddy]', msg: 'tls internal renewing hub.home' },
16
+ { lvl: 'err', svc: '[tasks-api]', msg: 'EADDRINUSE :3004 — retrying in 2s' },
17
+ { lvl: 'info', svc: '[notes-api]', msg: 'slow query · 182ms · SELECT * FROM notes' },
18
+ { lvl: 'ok', svc: '[meals-api]', msg: 'POST /meals — created id=m_a4f1 · 6ms' },
19
+ { lvl: 'info', svc: '[movies-api]', msg: 'drizzle migrated 0002 · runtime 12ms' },
20
+ ]
21
+
22
+ function pad(n: number) { return String(n).padStart(2, '0') }
23
+ function nowStr() {
24
+ const d = new Date()
25
+ return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`
26
+ }
27
+ function timeAgo(s: number) {
28
+ const d = new Date(Date.now() - s * 1000)
29
+ return `${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`
30
+ }
31
+
32
+ let { live = true, initialLines }: Props = $props()
33
+
34
+ const seed = untrack(() => initialLines ?? TEMPLATES)
35
+ let counter = $state(seed.length)
36
+ let lines = $state<LogLine[]>(seed.map((t, i) => ({ ...t, t: timeAgo(i * 4), id: i })))
37
+
38
+ let el: HTMLDivElement | undefined
39
+
40
+ $effect(() => {
41
+ if (!live) return
42
+ const interval = setInterval(async () => {
43
+ const pick = TEMPLATES[Math.floor(Math.random() * TEMPLATES.length)]
44
+ lines = [...lines.slice(-30), { ...pick, t: nowStr(), id: counter++ }]
45
+ await tick()
46
+ if (el) el.scrollTop = el.scrollHeight
47
+ }, 1800)
48
+ return () => clearInterval(interval)
49
+ })
50
+ </script>
51
+
52
+ <div class="hub-logs" bind:this={el}>
53
+ {#each lines as line (line.id)}
54
+ <div class="ln">
55
+ <span class="t">{line.t}</span>
56
+ <span class="lvl {line.lvl}">{line.lvl.toUpperCase()}</span>
57
+ <span class="svc">{line.svc}</span>
58
+ <span>{line.msg}</span>
59
+ </div>
60
+ {/each}
61
+ </div>
@@ -0,0 +1,14 @@
1
+ interface LogLine {
2
+ id: number;
3
+ t: string;
4
+ lvl: string;
5
+ svc: string;
6
+ msg: string;
7
+ }
8
+ interface Props {
9
+ live?: boolean;
10
+ initialLines?: Omit<LogLine, 'id'>[];
11
+ }
12
+ declare const LogStream: import("svelte").Component<Props, {}, "">;
13
+ type LogStream = ReturnType<typeof LogStream>;
14
+ export default LogStream;
@@ -0,0 +1,20 @@
1
+ <script lang="ts">
2
+ interface Props {
3
+ label: string
4
+ value: string | number
5
+ suffix?: string
6
+ delta?: string
7
+ dir?: 'up' | 'down'
8
+ }
9
+ let { label, value, suffix, delta, dir = 'up' }: Props = $props()
10
+ </script>
11
+
12
+ <div class="hub-metric">
13
+ <div class="label">{label}</div>
14
+ <div class="val">
15
+ {value}{#if suffix}<span class="small">{suffix}</span>{/if}
16
+ </div>
17
+ {#if delta}
18
+ <div class="delta {dir}">{dir === 'up' ? '↑' : '↓'} {delta}</div>
19
+ {/if}
20
+ </div>
@@ -0,0 +1,10 @@
1
+ interface Props {
2
+ label: string;
3
+ value: string | number;
4
+ suffix?: string;
5
+ delta?: string;
6
+ dir?: 'up' | 'down';
7
+ }
8
+ declare const MetricTile: import("svelte").Component<Props, {}, "">;
9
+ type MetricTile = ReturnType<typeof MetricTile>;
10
+ export default MetricTile;
@@ -0,0 +1,15 @@
1
+ <script lang="ts">
2
+ interface Props {
3
+ size?: number
4
+ color?: string
5
+ }
6
+ let { size = 22, color = 'var(--hs-primary)' }: Props = $props()
7
+ </script>
8
+
9
+ <svg viewBox="0 0 103 89" width={size} height={size} fill={color}>
10
+ <path
11
+ fill-rule="evenodd"
12
+ clip-rule="evenodd"
13
+ d="M51.5 0L0 89H103L51.5 0ZM23.8643 80.151H87.6468L71.6884 52.5724L23.8643 80.151ZM65.5911 42.0354L60.7383 33.649L46.1956 42.0354H65.5911ZM56.14 25.7024L51.5 17.6837L42.2125 33.7339L56.14 25.7024ZM32.0977 51.2138L20.2949 71.6111L55.6656 51.2138H32.0977Z"
14
+ />
15
+ </svg>
@@ -0,0 +1,7 @@
1
+ interface Props {
2
+ size?: number;
3
+ color?: string;
4
+ }
5
+ declare const PassocaMark: import("svelte").Component<Props, {}, "">;
6
+ type PassocaMark = ReturnType<typeof PassocaMark>;
7
+ export default PassocaMark;
@@ -0,0 +1,44 @@
1
+ <script lang="ts">
2
+ import Badge from './Badge.svelte'
3
+ import Sparkline from './Sparkline.svelte'
4
+
5
+ interface Props {
6
+ name: string
7
+ host: string
8
+ status?: 'up' | 'deg' | 'down'
9
+ latency?: string
10
+ spark?: number[]
11
+ onclick?: () => void
12
+ }
13
+ let {
14
+ name,
15
+ host,
16
+ status = 'up',
17
+ latency = '',
18
+ spark = [4, 8, 6, 10, 7, 12, 9, 14, 11, 16, 13, 10, 12],
19
+ onclick,
20
+ }: Props = $props()
21
+
22
+ const sparkColor = $derived(
23
+ status === 'deg' ? 'var(--hs-yellow)'
24
+ : status === 'down' ? 'var(--hs-red)'
25
+ : 'var(--hs-primary)'
26
+ )
27
+ </script>
28
+
29
+ <div class="hub-svc" role="button" tabindex="0" {onclick} onkeydown={(e) => e.key === 'Enter' && onclick?.()}>
30
+ <div class="head">
31
+ <div>
32
+ <div class="name">{name}</div>
33
+ <div class="host">{host}</div>
34
+ </div>
35
+ </div>
36
+ <div class="status">
37
+ <Badge tone={status}>{status}</Badge>
38
+ <div class="latency">{latency}</div>
39
+ </div>
40
+ <div class="footer">
41
+ <Sparkline data={spark} color={sparkColor} />
42
+ <div class="latency">▸ open</div>
43
+ </div>
44
+ </div>
@@ -0,0 +1,11 @@
1
+ interface Props {
2
+ name: string;
3
+ host: string;
4
+ status?: 'up' | 'deg' | 'down';
5
+ latency?: string;
6
+ spark?: number[];
7
+ onclick?: () => void;
8
+ }
9
+ declare const ServiceCard: import("svelte").Component<Props, {}, "">;
10
+ type ServiceCard = ReturnType<typeof ServiceCard>;
11
+ export default ServiceCard;
@@ -0,0 +1,49 @@
1
+ <script lang="ts">
2
+ import Icon, { type IconName } from './Icon.svelte'
3
+
4
+ type Status = 'up' | 'deg' | 'down'
5
+ interface SideItem { id: string; label: string; icon: IconName; status?: Status }
6
+ interface SideGroup { section: string; items: SideItem[] }
7
+
8
+ interface Props {
9
+ active?: string
10
+ onSelect?: (id: string) => void
11
+ groups?: SideGroup[]
12
+ }
13
+
14
+ const DEFAULT_GROUPS: SideGroup[] = [
15
+ { section: 'platform', items: [
16
+ { id: 'hub', label: 'Hub', icon: 'grid', status: 'up' },
17
+ { id: 'auth', label: 'Auth', icon: 'user', status: 'up' },
18
+ { id: 'caddy', label: 'Caddy', icon: 'settings', status: 'up' },
19
+ ]},
20
+ { section: 'services', items: [
21
+ { id: 'movies', label: 'Movies', icon: 'film', status: 'up' },
22
+ { id: 'notes', label: 'Notes', icon: 'note', status: 'up' },
23
+ { id: 'tasks', label: 'Tasks', icon: 'check', status: 'up' },
24
+ ]},
25
+ ]
26
+
27
+ let { active = 'hub', onSelect, groups = DEFAULT_GROUPS }: Props = $props()
28
+ </script>
29
+
30
+ <aside class="hub-side">
31
+ {#each groups as g}
32
+ <div class="section">{g.section}</div>
33
+ {#each g.items as item}
34
+ <div
35
+ class="item {item.id === active ? 'active' : ''}"
36
+ role="button"
37
+ tabindex="0"
38
+ onclick={() => onSelect?.(item.id)}
39
+ onkeydown={(e) => e.key === 'Enter' && onSelect?.(item.id)}
40
+ >
41
+ <Icon name={item.icon} size={13} />
42
+ <span>{item.label}</span>
43
+ {#if item.status}
44
+ <span class="dot {item.status === 'deg' ? 'warn' : item.status === 'down' ? 'err' : ''}"></span>
45
+ {/if}
46
+ </div>
47
+ {/each}
48
+ {/each}
49
+ </aside>
@@ -0,0 +1,20 @@
1
+ import { type IconName } from './Icon.svelte';
2
+ type Status = 'up' | 'deg' | 'down';
3
+ interface SideItem {
4
+ id: string;
5
+ label: string;
6
+ icon: IconName;
7
+ status?: Status;
8
+ }
9
+ interface SideGroup {
10
+ section: string;
11
+ items: SideItem[];
12
+ }
13
+ interface Props {
14
+ active?: string;
15
+ onSelect?: (id: string) => void;
16
+ groups?: SideGroup[];
17
+ }
18
+ declare const Sidebar: import("svelte").Component<Props, {}, "">;
19
+ type Sidebar = ReturnType<typeof Sidebar>;
20
+ export default Sidebar;