silva-ui 1.2.0 → 1.3.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.
@@ -0,0 +1,16 @@
1
+ /**
2
+ * A semantic size token calibrated at a 1000px-wide viewport.
3
+ *
4
+ * `$2.4` resolves to `24px` at 1000px, `12px` at 500px, and `48px` at
5
+ * 2000px. The value stays linear rather than stepping between breakpoints.
6
+ */
7
+ export type ProjectionToken = `$${number}`;
8
+ /** True when a value is a valid non-negative projection token such as `$24`. */
9
+ export declare function isProjectionToken(value: unknown): value is ProjectionToken;
10
+ /**
11
+ * Resolves `$n` to a viewport-relative CSS value.
12
+ *
13
+ * `n` is one tenth of the token's pixel size at the 1000px reference viewport.
14
+ * Since one viewport-width unit is 10px there, `$n` is equivalently `n vw`.
15
+ */
16
+ export declare function projectionTokenToCss(token: ProjectionToken): string;
@@ -1,3 +1,4 @@
1
+ import type { ProjectionToken } from './projection';
1
2
  export declare const tokens: {
2
3
  space: {
3
4
  none: string;
@@ -949,3 +950,12 @@ export declare const sprinkles: ((props: {
949
950
  properties: Set<"alignItems" | "alignSelf" | "backgroundColor" | "bg" | "borderColor" | "borderRadius" | "borderStyle" | "borderWidth" | "bottom" | "color" | "cursor" | "display" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontSize" | "fontWeight" | "gap" | "h" | "height" | "justifyContent" | "left" | "letterSpacing" | "lineHeight" | "m" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "mb" | "minHeight" | "minWidth" | "ml" | "mr" | "mt" | "mx" | "my" | "objectFit" | "opacity" | "overflow" | "overflowX" | "overflowY" | "p" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "pb" | "pl" | "pointerEvents" | "position" | "pr" | "pt" | "px" | "py" | "right" | "textAlign" | "textDecoration" | "textTransform" | "top" | "userSelect" | "visibility" | "w" | "whiteSpace" | "width" | "wordBreak" | "zIndex">;
950
951
  };
951
952
  export type Sprinkles = Parameters<typeof sprinkles>[0];
953
+ /**
954
+ * Sprinkles properties that also accept a fluid projection token such as
955
+ * `$2.4`. The numeric part is one tenth of its pixel value at the 1000px reference viewport.
956
+ */
957
+ export type ProjectionProperty = 'gap' | 'paddingTop' | 'paddingBottom' | 'paddingLeft' | 'paddingRight' | 'marginTop' | 'marginBottom' | 'marginLeft' | 'marginRight' | 'width' | 'height' | 'minWidth' | 'minHeight' | 'maxWidth' | 'maxHeight' | 'fontSize' | 'borderRadius' | 'top' | 'right' | 'bottom' | 'left' | 'p' | 'px' | 'py' | 'pt' | 'pb' | 'pl' | 'pr' | 'm' | 'mx' | 'my' | 'mt' | 'mb' | 'ml' | 'mr' | 'w' | 'h';
958
+ /** Sprinkles extended with dynamic, linearly projected numeric size tokens. */
959
+ export type ProjectionSprinkles = Omit<Sprinkles, ProjectionProperty> & {
960
+ [Property in ProjectionProperty]?: Sprinkles[Property] | ProjectionToken;
961
+ };
@@ -4,11 +4,11 @@
4
4
  * We keep JSX/framework types minimal and use `children?: any`
5
5
  * so the library works with Hono JSX, Preact, or plain string rendering.
6
6
  */
7
- import type { Sprinkles } from './sprinkles.css';
7
+ import type { ProjectionSprinkles, Sprinkles } from './sprinkles.css';
8
8
  import type { AnimationName } from './visuals.css';
9
9
  import type { GradientName } from './gradients';
10
10
  /** Props common to every silva-ui primitive. */
11
- export type BaseProps = Omit<Sprinkles, 'backgroundColor' | 'color'> & {
11
+ export type BaseProps = Omit<ProjectionSprinkles, 'backgroundColor' | 'color'> & {
12
12
  /** Named gradients work with `backgroundColor` and `color` in addition to theme color tokens. */
13
13
  backgroundColor?: Sprinkles['backgroundColor'] | GradientName;
14
14
  color?: Sprinkles['color'] | GradientName;
@@ -3,7 +3,9 @@ import { type Sprinkles } from './sprinkles.css';
3
3
  * Split a props object into sprinkles props and the remaining "rest" props.
4
4
  *
5
5
  * This lets components accept both sprinkles tokens *and* arbitrary HTML
6
- * attributes without manually destructuring every sprinkles key.
6
+ * attributes without manually destructuring every sprinkles key. Projection
7
+ * tokens are converted to inline fluid CSS because `$n` is intentionally an
8
+ * open numeric scale, rather than a generated list of atomic classes.
7
9
  */
8
10
  export declare function splitSprinklesProps<T extends Record<string, unknown>>(props: T): {
9
11
  sprinklesProps: Sprinkles;
@@ -1,5 +1,7 @@
1
1
  export { sprinkles, tokens } from './core/sprinkles.css';
2
- export type { Sprinkles } from './core/sprinkles.css';
2
+ export type { ProjectionProperty, ProjectionSprinkles, Sprinkles } from './core/sprinkles.css';
3
+ export { isProjectionToken, projectionTokenToCss } from './core/projection';
4
+ export type { ProjectionToken } from './core/projection';
3
5
  export { cls, splitSprinklesProps, toSprinklesClass } from './core/utils';
4
6
  export { gradientToCss } from './core/gradient';
5
7
  export type { Gradient, GradientColor } from './core/gradient';
package/package.json CHANGED
@@ -1,73 +1,74 @@
1
1
  {
2
2
  "name": "silva-ui",
3
- "version": "1.2.0",
3
+ "version": "1.3.1",
4
4
  "description": "A Hono JSX UI component library with framework-neutral styling and Tamagui-inspired theming.",
5
5
  "main": "./dist/library/silva-ui.js",
6
6
  "module": "./dist/library/silva-ui.js",
7
7
  "types": "./dist/types/index.d.ts",
8
8
  "style": "./dist/library/silva-ui.css",
9
9
  "exports": {
10
- ".": {
11
- "types": "./dist/types/index.d.ts",
12
- "import": "./dist/library/silva-ui.js",
13
- "default": "./dist/library/silva-ui.js"
14
- },
15
- "./style.css": {
16
- "types": "./style.css.d.ts",
17
- "default": "./dist/library/silva-ui.css"
18
- }
10
+ ".": {
11
+ "types": "./dist/types/index.d.ts",
12
+ "import": "./dist/library/silva-ui.js",
13
+ "default": "./dist/library/silva-ui.js"
14
+ },
15
+ "./style.css": {
16
+ "types": "./style.css.d.ts",
17
+ "default": "./dist/library/silva-ui.css"
18
+ }
19
19
  },
20
20
  "sideEffects": [
21
- "**/*.css"
21
+ "**/*.css"
22
22
  ],
23
23
  "files": [
24
- "dist/library",
25
- "dist/types",
26
- "style.css.d.ts",
27
- "README.md",
28
- "LICENSE"
24
+ "dist/library",
25
+ "dist/types",
26
+ "style.css.d.ts",
27
+ "README.md",
28
+ "LICENSE"
29
29
  ],
30
30
  "scripts": {
31
- "dev": "vite",
32
- "build": "vite build",
33
- "build:library": "vite build --config vite.library.config.ts",
34
- "build:types": "tsc -p tsconfig.types.json",
35
- "build:package": "npm run build:library && npm run build:types",
36
- "profile:library": "vite build --config vite.library.config.ts --profile",
37
- "pack:check": "npm run build:package && npm pack --dry-run",
38
- "preview": "vite preview",
39
- "typecheck": "tsc --noEmit"
31
+ "dev": "vite",
32
+ "build": "vite build",
33
+ "build:previews": "vite build --config vite.previews.config.ts",
34
+ "build:library": "vite build --config vite.library.config.ts",
35
+ "build:types": "tsc -p tsconfig.types.json",
36
+ "build:package": "npm run build:library && npm run build:types",
37
+ "profile:library": "vite build --config vite.library.config.ts --profile",
38
+ "pack:check": "npm run build:package && npm pack --dry-run",
39
+ "preview": "vite preview",
40
+ "typecheck": "tsc --noEmit"
40
41
  },
41
42
  "keywords": [
42
- "ui",
43
- "ui-components",
44
- "component-library",
45
- "design-system",
46
- "hono",
47
- "hono-jsx",
48
- "jsx",
49
- "typescript",
50
- "vanilla-extract",
51
- "sprinkles",
52
- "theming",
53
- "accessible"
43
+ "ui",
44
+ "ui-components",
45
+ "component-library",
46
+ "design-system",
47
+ "hono",
48
+ "hono-jsx",
49
+ "jsx",
50
+ "typescript",
51
+ "vanilla-extract",
52
+ "sprinkles",
53
+ "theming",
54
+ "accessible"
54
55
  ],
55
56
  "author": "BlackSilva",
56
57
  "license": "MIT",
57
58
  "type": "module",
58
59
  "peerDependencies": {
59
- "hono": "^4.13.13"
60
+ "hono": "^4.13.13"
60
61
  },
61
62
  "devDependencies": {
62
- "@vanilla-extract/vite-plugin": "^5.2.6",
63
- "@vanilla-extract/css": "^1.21.3",
64
- "@vanilla-extract/sprinkles": "^1.7.1",
65
- "hono": "^4.13.13",
66
- "typescript": "^7.0.2",
67
- "vite": "^8.3.4"
63
+ "@vanilla-extract/css": "^1.21.3",
64
+ "@vanilla-extract/sprinkles": "^1.7.1",
65
+ "@vanilla-extract/vite-plugin": "^5.2.6",
66
+ "hono": "^4.13.13",
67
+ "typescript": "^7.0.2",
68
+ "vite": "^8.3.4"
68
69
  },
69
70
  "repository": {
70
- "type": "git",
71
- "url": "git+https://github.com/black-silva/silva-ui.git"
71
+ "type": "git",
72
+ "url": "git+https://github.com/black-silva/silva-ui.git"
72
73
  }
73
74
  }
@@ -1,51 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
5
- <title>Silva UI live previews</title>
6
- <style>
7
- :root{--bg:#f8fafc;--card:#fff;--text:#172033;--muted:#64748b;--line:#dbe4ee;--primary:#0f766e;--primary-ink:#fff;--danger:#b42318;--shadow:0 8px 22px rgba(15,23,42,.07)}*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--text);font:14px/1.45 system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}.shell{min-height:100vh;padding:20px}.demo{max-width:760px;margin:auto;background:var(--card);border:1px solid var(--line);border-radius:16px;padding:22px;box-shadow:var(--shadow)}h1,h2,h3,p{margin:0}h2{font-size:18px}h3{font-size:16px}.muted{color:var(--muted)}.small{font-size:12px}.stack{display:grid;gap:14px}.row{display:flex;gap:10px;align-items:center;flex-wrap:wrap}.between{justify-content:space-between}.panel{padding:16px;border:1px solid var(--line);border-radius:12px;background:#fff}.subtle{background:#f1f5f9}.button{border:1px solid var(--primary);background:var(--primary);color:var(--primary-ink);border-radius:9px;padding:8px 12px;font:inherit;font-weight:650;cursor:pointer}.button.outline{background:#fff;color:var(--primary)}.button.ghost{background:transparent;color:var(--primary);border-color:transparent}.field{display:grid;gap:6px;font-weight:600}.input,textarea,select{font:inherit;color:var(--text);width:100%;border:1px solid #b9c7d6;border-radius:8px;padding:9px;background:#fff}textarea{min-height:76px;resize:vertical}.checkbox,.radio{display:flex;gap:8px;align-items:center;font-weight:400}.progress{height:9px;overflow:hidden;background:#e2e8f0;border-radius:999px}.progress span{display:block;height:100%;width:56%;background:var(--primary);border-radius:inherit}.avatar{display:grid;place-items:center;width:52px;height:52px;border-radius:50%;background:#cbd5e1;color:#334155;font-weight:700}.avatar.photo{background:linear-gradient(135deg,#f59e0b,#e879f9,#22c55e);color:#fff}.list{border:1px solid var(--line);border-radius:10px;overflow:hidden}.list .item{padding:12px;display:flex;gap:10px;align-items:center;border-bottom:1px solid var(--line)}.list .item:last-child{border:0}.dot{width:9px;height:9px;border-radius:50%;background:#22c55e}.spinner{width:28px;height:28px;border:3px solid #cbd5e1;border-top-color:var(--primary);border-radius:50%;animation:spin .8s linear infinite}@keyframes spin{to{transform:rotate(1turn)}}.loader{height:5px;background:#dbeafe;border-radius:99px;overflow:hidden}.loader:after{content:"";display:block;width:42%;height:100%;background:var(--primary);animation:slide 1.2s ease-in-out infinite}@keyframes slide{0%{transform:translateX(-110%)}100%{transform:translateX(340%)}}.tabs{display:flex;gap:4px;border-bottom:1px solid var(--line)}.tab{border:0;background:transparent;padding:9px 10px;color:var(--muted);cursor:pointer}.tab.active{color:var(--primary);border-bottom:2px solid var(--primary);font-weight:700}.tabpanel{padding-top:14px}.dialog-backdrop{background:rgba(15,23,42,.08);border-radius:10px;padding:18px}.dialog{max-width:420px;margin:auto;padding:18px;background:#fff;border:1px solid var(--line);border-radius:12px;box-shadow:var(--shadow)}.xgroup{display:inline-flex}.xgroup .button{border-radius:0}.xgroup .button:first-child{border-radius:9px 0 0 9px}.xgroup .button:last-child{border-radius:0 9px 9px 0}.sep{height:1px;background:var(--line);border:0;width:100%}.theme{background:#12201f;color:#e5fffb;border-color:#275750}.theme .panel{background:#1d302f;color:#e5fffb;border-color:#3a615d}.theme .muted{color:#a4c5c1}.toast{border-left:4px solid #22c55e}.notice{padding:10px 12px;border-radius:9px;background:#ecfdf5;color:#065f46}.swatches{display:flex;gap:8px}.swatch{padding:15px 10px;border-radius:8px;color:#fff;font-size:12px;font-weight:700}.a{background:#0f766e}.b{background:#14b8a6}.c{background:#0f172a}.server{background:#0f172a;color:#d1fae5;border-radius:10px;padding:14px;font:12px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace}.server b{color:#5eead4}@media(max-width:440px){.shell{padding:10px}.demo{padding:15px}}
8
- </style></head>
9
- <body><main class="shell"><section class="demo" id="app"></section></main>
10
- <script>
11
- const example = location.hash.slice(1) || new URLSearchParams(location.search).get('example') || 'default';
12
- const app = document.querySelector('#app');
13
- const button=(label,kind='')=>`<button class="button ${kind}" type="button">${label}</button>`;
14
- const card=(content,extra='')=>`<div class="panel ${extra}">${content}</div>`;
15
- const title=(name,sub='Interactive visual result')=>`<div class="stack"><div><h2>${name}</h2><p class="muted small">${sub}</p></div>`;
16
- const end='</div>';
17
- const previews={
18
- 'display-1':()=>title('Card')+card(`<div class="stack"><div class="row between"><div><h3>Storage</h3><p class="muted">18 GB of 50 GB used</p></div></div><div class="progress"><span style="width:36%"></span></div><div>${button('Manage storage','outline')}</div></div>`)+end,
19
- 'display-2':()=>title('Avatar and image')+`<div class="row"><div class="avatar photo">BS</div><div class="stack"><div class="panel subtle" style="width:210px;height:80px;display:grid;place-items:center;color:#475569">Product banner</div><p class="muted small">Image with fallback avatar</p></div></div>`+end,
20
- 'display-3':()=>title('List item')+`<div class="list"><div class="item"><div class="avatar" style="width:32px;height:32px">BS</div><div><b>BlackSilva</b><div class="muted small">Owner</div></div></div></div>`+end,
21
- 'display-4':()=>title('Loading states')+`<div class="row"><div class="spinner"></div><div class="stack" style="flex:1"><span class="muted small">Saving your changes</span><div class="loader"></div></div></div>`+end,
22
- 'forms-1':()=>title('Subscribe form')+`<form class="stack" onsubmit="event.preventDefault();this.querySelector('.notice').hidden=false"><label class="field">Email address<input class="input" type="email" placeholder="you@example.com" required></label><p class="muted small">We will only send product updates.</p>${button('Subscribe')}<p class="notice" hidden>Subscribed locally for this preview.</p></form>`+end,
23
- 'forms-2':()=>title('Message field')+`<label class="field">Message<textarea placeholder="Tell us what you need."></textarea></label>`+end,
24
- 'forms-3':()=>title('Choice controls')+`<div class="stack"><label class="checkbox"><input type="checkbox"> I agree to the terms</label><label class="checkbox"><input type="checkbox" checked> Enable alerts</label><div class="row"><label class="radio"><input type="radio" name="plan"> Starter</label><label class="radio"><input type="radio" name="plan" checked> Pro</label></div><div class="progress"><span style="width:72%"></span></div></div>`+end,
25
- 'forms-4':()=>title('Button variants')+`<div class="row">${button('Save changes')}${button('Preview','outline')}${button('Cancel','ghost')}</div>`+end,
26
- 'overlay-1':()=>title('Dialog')+`<div class="dialog-backdrop"><div class="dialog stack"><div><h3>Delete project?</h3><p class="muted">This cannot be undone.</p></div><div class="row" style="justify-content:flex-end">${button('Cancel','outline')}${button('Delete')}</div></div></div>`+end,
27
- 'overlay-2':()=>title('Tabs')+`<div class="tabs"><button class="tab active">Profile</button><button class="tab">Security</button></div><div class="tabpanel">Profile content</div>`+end,
28
- 'layout-1':()=>title('Box')+card('Content','subtle')+end,
29
- 'layout-2':()=>title('Stack layout')+card(`<div class="stack"><h3>Account settings</h3><div class="row between"><span>Email alerts</span><label><input type="checkbox" checked aria-label="Email alerts"></label></div></div>`)+end,
30
- 'layout-3':()=>title('XGroup')+`<div class="xgroup">${button('Day','outline')}${button('Week','outline')}${button('Month','outline')}</div>`+end,
31
- 'layout-4':()=>title('Separator')+`<div class="stack"><span>Content above</span><hr class="sep"><span>Content below</span></div>`+end,
32
- 'sprinkles-1':()=>title('Sprinkles surface')+card(`<h3>Build once, compose anywhere</h3><p class="muted">Spacing, colour and border-radius tokens are applied together.</p>`)+end,
33
- 'sprinkles-2':()=>title('Responsive layout')+`<div class="row"><div class="panel subtle" style="flex:1">Main content</div><div class="panel" style="flex:1">Sidebar</div></div>`+end,
34
- 'typography-1':()=>title('Text styles')+`<div class="stack"><strong>Strong emphasis</strong><p class="muted">Supporting copy</p></div>`+end,
35
- 'typography-2':()=>title('Headings')+`<div class="stack"><h1 style="font-size:26px">Build faster</h1><h3>A short, readable description.</h3><p class="muted">Clear hierarchy without custom CSS.</p></div>`+end,
36
- 'typography-3':()=>title('Paragraph')+`<p class="muted">A readable paragraph with semantic colour and comfortable line height.</p>`+end,
37
- 'intro-1':()=>title('Quick start')+card(`<div class="stack"><h3>Welcome to Silva UI</h3><p class="muted">Theme-aware components ready for composition.</p>${button('Get started')}</div>`)+end,
38
- 'install-1':()=>title('Style import','Bundled stylesheet ready')+`<div class="server"><b>✓</b> Silva UI styles loaded successfully</div>`+end,
39
- 'install-2':()=>title('Hono JSX app','Server-rendered component output')+`<div class="server"><b>GET /</b> 200 OK<br>&lt;main&gt;Silva UI is ready.&lt;/main&gt;</div>`+end,
40
- 'recipes-1':()=>title('Settings row')+card(`<div class="row between"><div><b>Email notifications</b><div class="muted small">Receive a summary of account activity.</div></div><input type="checkbox" checked aria-label="Email notifications"></div>`)+end,
41
- 'recipes-2':()=>title('Empty state')+card(`<div class="stack" style="text-align:center;justify-items:center"><h3>No projects yet</h3><p class="muted">Create your first project to get started.</p>${button('Create project')}</div>`)+end,
42
- 'recipes-3':()=>title('Toast')+`<div class="panel toast"><b>Changes saved</b><div class="muted">Your profile is up to date.</div></div>`+end,
43
- 'recipes-4':()=>title('Theme preview')+`<div class="row"><div class="panel">light</div><div class="panel theme">dark</div><div class="panel" style="border-color:#14b8a6;color:#0f766e">emerald</div></div>`+end,
44
- 'theming-1':()=>title('Built-in dark theme')+card(`<p>Semantic tokens follow the active theme.</p>`,'theme')+end,
45
- 'theming-2':()=>title('Nested theme scopes')+card(`<div class="panel" style="background:#0f766e;color:#fff;border:0">This nested section uses emerald tokens.</div>`,'theme')+end,
46
- 'theming-3':()=>title('Custom theme definition')+`<div class="swatches"><div class="swatch a">primary</div><div class="swatch b">accent</div><div class="swatch c">surface</div></div>`+end,
47
- 'default':()=>title('Silva UI example')+card(`<div class="stack"><h3>Live component preview</h3><p class="muted">This is the rendered visual result of the example.</p>${button('Try action')}</div>`)+end
48
- };
49
- app.innerHTML=(previews[example]||previews.default)();
50
- app.addEventListener('click',(event)=>{const tab=event.target.closest('.tab');if(tab){tab.parentElement.querySelectorAll('.tab').forEach(x=>x.classList.remove('active'));tab.classList.add('active');document.querySelector('.tabpanel').textContent=tab.textContent+' content';}});
51
- </script></body></html>