Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,53 @@ concurrency:
jobs:
# Branch protection asks for this job by name: renaming it takes it out of the merge gate.
web:
# Keep the existing protected check authoritative for both frameworks.
needs: svelte
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Svelte consumer passed
env:
SVELTE_RESULT: ${{ needs.svelte.result }}
run: test "$SVELTE_RESULT" = success
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci
- run: node --test scripts/block-metadata.test.mjs
- run: node --test scripts/block-metadata.test.mjs scripts/build-svelte-registry.test.mjs
# the documentation and the registry are generated: the types of what renders them depend on them
- run: npm run docs
- name: The registry is as committed
# registry.json is written by scripts/build-registry.mjs and is what shadcn add reads from
# GitHub; a component added without rebuilding it would be missing from the registry.
run: git diff --exit-code registry.json
run: git diff --exit-code registry.json registry/svelte/registry.json
- run: npm run typecheck
- run: npm run build

svelte:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: tests/svelte/package-lock.json
- run: node scripts/build-svelte-registry.mjs
- run: npm ci
working-directory: tests/svelte
- run: npm run install:registry
working-directory: tests/svelte
- run: npm run check && npm run build
working-directory: tests/svelte
- run: npx playwright install --with-deps chromium
working-directory: tests/svelte
- run: npm test
working-directory: tests/svelte
- uses: actions/upload-artifact@v4
if: always()
with:
name: svelte-browser-results
path: tests/svelte/test-results/
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
},
"type": "module",
"scripts": {
"docs": "node scripts/build-docs.mjs && node scripts/build-registry.mjs",
"docs": "node scripts/build-docs.mjs && node scripts/build-registry.mjs && node scripts/build-svelte-registry.mjs",
"dev": "npm run docs && vite",
"build": "npm run docs && vite build",
"typecheck": "tsc -b",
"preview": "vite preview"
"preview": "vite preview",
"test:svelte-registry": "node --test scripts/build-svelte-registry.test.mjs"
},
"dependencies": {
"@base-ui/react": "^1.8.0",
Expand Down
129 changes: 129 additions & 0 deletions registry/svelte/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Svelte registry

Solid Glass is a React design system, not SolidJS. This additive registry delivers
native Svelte 5 **AskCard and DotLoader** through **shadcn-svelte**, while leaving
every React component, registry name and URL intact. Other components and blocks
are not part of this Svelte release.

## Install

Start with a Tailwind CSS 4 / Svelte 5 project initialized with shadcn-svelte.
After this branch is released to the site:

```sh
npx shadcn-svelte@latest add https://deeplethe.github.io/solid-glass/r/svelte/ask-card.json
npx shadcn-svelte@latest add https://deeplethe.github.io/solid-glass/r/svelte/dot-loader.json
```

Each item installs the shared `src/solid-glass.css` too. Import it **after** the
Tailwind and shadcn-svelte styles in the application's global stylesheet (adjust
the relative path to that file):

```css
@import "tailwindcss";
@import "tw-animate-css";
@import "./solid-glass.css";
```

Keep all imports before ordinary CSS rules. Remove the competing `:root` /
`.dark` color definitions generated by shadcn-svelte, so they do not override
the material. Keep any intentional application overrides after the imports.
Toggle `.dark` on `html` for dark mode. The theme falls back to system fonts if Geist is not installed. Do not
copy the React-only `shadcn/tailwind.css` import from the shared CSS's comment.

```svelte
<script lang="ts">
import AskCard from "$lib/components/ui/ask-card/ask-card.svelte"
let chosen = $state<string>()
</script>

<AskCard
question="Which route?"
options={["First", "Second"]}
{chosen}
onAnswer={chosen === undefined ? (value) => { chosen = value } : undefined}
/>
```

`class` replaces React's `className`. AskCard retains the existing `onAnswer`
callback contract: omit it for an answered card, and pass `chosen` to identify
the answer. The answer buttons remain focusable but inert. DotLoader retains
`dotClassName`; supply an accessible status label in its surrounding context.
`examples/decision.svelte` is a copyable interactive example.

## Architecture and scope

- `src/solid-glass.css` remains the sole material source. The Svelte builder
embeds it verbatim; no duplicated tokens or versioned npm package is needed.
- `registry/svelte/` owns native `.svelte` source. Never install TSX via the
Svelte CLI. The `$UTILS$` import marker is intentionally resolved by that CLI
from the consuming project's configured utils alias; these are registry
templates, not files to copy directly. Future interactive ports should use Bits UI / shadcn-svelte
primitives, not a React runtime wrapper.
- `public/r/svelte/` is an additive URL namespace, generated after the existing
React build (which clears `public/r`). `SOLID_GLASS_ORIGIN` configures dependency
URLs for a preview server. URLs are not published until the site is released.
- This registry covers **AskCard and DotLoader only**. It does not promise
parity for stock shadcn-svelte components: shared data-slot names are not
enough. The current stylesheet also relies on Base UI state attributes,
DOM structure and Tailwind class names; Bits UI checked/open/active states,
progress tracks, focus, disabled and portal behavior need dedicated audits.
- No root workspace migration or published npm packages are necessary for a
source registry. Extract a shared package only when a second consumer needs
an independently versioned build or runtime API.

## Development

```sh
npm run docs
npm run test:svelte-registry
npm run typecheck
npm run build
```

These commands preserve the React build and test registry generation. The
isolated consumer in `tests/svelte` also installs the built registry through the
real shadcn-svelte CLI, typechecks and builds the installed Svelte source, and
runs browser checks. Its dependencies are separate from the React site.

### Compatibility boundary

AskCard uses native buttons, not Base UI or Bits UI. Its `data-slot="ask-card"`,
`glass-panel`, `glass-chosen`, focus outline, answered/selected classes and DOM
structure match the React component. DotLoader uses the same three spans,
160 ms stagger and canonical reduced-motion rule. Neither port needs framework
state-attribute translation. Keep the controlled `chosen`/`onAnswer` contract:
`chosen` alone highlights a choice; removing `onAnswer` makes the card inert.

Do not treat the shared stylesheet as a supported drop-in theme for arbitrary
shadcn-svelte widgets. Base UI and Bits UI differ in state attributes, portal
markup and track structure. Future checkbox, tabs, menu, dialog and progress
ports must each add a native consumer fixture and state/keyboard/theme tests
before their registry entries are published.

Run the consumer with Node 22 (the CI version) after `npm run docs`:

```sh
cd tests/svelte
npm ci
npm run install:registry
npm run check
npm run build
npx playwright install chromium
npm test
```

The fixture deliberately uses nondefault UI and utils aliases. Browser tests run
against its production build, covering both themes, keyboard choice/focus,
answered-state inertness, reset, small-screen wrapping and reduced motion.

If installed component files are excluded by `.gitignore`, Tailwind 4 will not
scan them automatically. Register their actual directory with `@source` in your
app stylesheet (after the imports), for example:

```css
@source "./lib/components/ui/**/*.svelte";
```

The fixture explicitly registers its gitignored custom UI directory and asserts
rendered padding, rounding, gaps and dot sizes to catch missing utility output.
44 changes: 44 additions & 0 deletions registry/svelte/ask-card/ask-card.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<script lang="ts">
import { cn } from "$UTILS$.js"

let {
question,
options = [],
onAnswer,
chosen,
eyebrow = "Needs your decision",
class: className,
}: {
question: string
options?: string[]
onAnswer?: (option: string) => void
chosen?: string
eyebrow?: string
class?: string
} = $props()

const answered = $derived(!onAnswer)
</script>

<div data-slot="ask-card" class={cn("glass-panel rounded-md px-3.5 py-3", className)}>
<p class="text-[11.5px] text-status-interrupted">{eyebrow}</p>
<p class="mt-1 text-[14px] leading-relaxed whitespace-pre-wrap">{question}</p>
{#if options.length > 0}
<div class="mt-2.5 flex flex-wrap gap-1.5">
{#each options as option, index (index)}
<!-- Keep the answered choice focusable so answering does not drop focus to the page. -->
<button
type="button"
aria-disabled={answered || undefined}
aria-current={option === chosen || undefined}
onclick={() => onAnswer?.(option)}
class={cn(
"h-7 rounded-sm px-2.5 text-[12.5px] transition-colors outline-none",
answered && option !== chosen ? "cursor-default text-muted-foreground/70" : "glass-chosen text-foreground/90",
answered ? "cursor-default" : "hover:bg-foreground/[0.12] hover:text-foreground"
)}
>{option}</button>
{/each}
</div>
{/if}
</div>
14 changes: 14 additions & 0 deletions registry/svelte/dot-loader/dot-loader.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<script lang="ts">
import { cn } from "$UTILS$.js"

let { class: className, dotClassName }: { class?: string; dotClassName?: string } = $props()
</script>

<span class={cn("flex items-center gap-[2px]", className)}>
{#each [0, 1, 2] as index (index)}
<span
style:animation-delay={`${index * 160}ms`}
class={cn("size-[3px] animate-dot-flash rounded-full bg-status-running", dotClassName)}
></span>
{/each}
</span>
19 changes: 19 additions & 0 deletions registry/svelte/examples/decision.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<script lang="ts">
import AskCard from "$lib/components/ui/ask-card/ask-card.svelte"
import DotLoader from "$lib/components/ui/dot-loader/dot-loader.svelte"

let chosen = $state<string>()
</script>

<main class="min-h-screen bg-background p-6 text-foreground">
<div class="mx-auto max-w-lg space-y-4">
<AskCard
question="Which example should run next?"
options={["Search", "Summarize"]}
{chosen}
onAnswer={chosen === undefined ? (option) => { chosen = option } : undefined}
/>
<button type="button" class="glass-chosen rounded-sm px-2 py-1" onclick={() => { chosen = undefined }}>Reset</button>
<div role="status" class="flex items-center gap-2"><DotLoader /><span>Working</span></div>
</div>
</main>
50 changes: 50 additions & 0 deletions registry/svelte/registry.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"$schema": "https://shadcn-svelte.com/schema/registry.json",
"name": "solid-glass-svelte",
"homepage": "https://deeplethe.github.io/solid-glass",
"items": [
{
"name": "solid-glass",
"type": "registry:file",
"title": "Solid Glass material for Svelte",
"description": "Canonical material for Svelte AskCard and DotLoader. Import after Tailwind; stock shadcn-svelte widgets are not covered.",
"files": [
{
"path": "src/solid-glass.css",
"type": "registry:file",
"target": "~/src/solid-glass.css"
}
]
},
{
"name": "ask-card",
"type": "registry:ui",
"title": "Ask Card",
"registryDependencies": [
"https://deeplethe.github.io/solid-glass/r/svelte/solid-glass.json"
],
"files": [
{
"path": "registry/svelte/ask-card/ask-card.svelte",
"type": "registry:ui",
"target": "ask-card/ask-card.svelte"
}
]
},
{
"name": "dot-loader",
"type": "registry:ui",
"title": "Dot Loader",
"registryDependencies": [
"https://deeplethe.github.io/solid-glass/r/svelte/solid-glass.json"
],
"files": [
{
"path": "registry/svelte/dot-loader/dot-loader.svelte",
"type": "registry:ui",
"target": "dot-loader/dot-loader.svelte"
}
]
}
]
}
45 changes: 45 additions & 0 deletions scripts/build-svelte-registry.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Svelte is an additive source registry, not another copy of the material.
* Keep the existing React registry addresses and build unchanged. The shared
* CSS is bundled into this registry from its canonical source on every build.
*/
import { mkdirSync, readFileSync, writeFileSync } from "node:fs"
import { fileURLToPath } from "node:url"
import { dirname, join } from "node:path"

const root = join(dirname(fileURLToPath(import.meta.url)), "..")
const origin = (process.env.SOLID_GLASS_ORIGIN ?? "https://deeplethe.github.io/solid-glass").replace(/\/$/, "")
const out = join(root, "public/r/svelte")
const items = [
{
name: "solid-glass",
type: "registry:file",
title: "Solid Glass material for Svelte",
description: "Canonical material for Svelte AskCard and DotLoader. Import after Tailwind; stock shadcn-svelte widgets are not covered.",
files: [{ path: "src/solid-glass.css", type: "registry:file", target: "~/src/solid-glass.css" }],
},
...["ask-card", "dot-loader"].map((name) => ({
name,
type: "registry:ui",
title: name === "ask-card" ? "Ask Card" : "Dot Loader",
registryDependencies: [`${origin}/r/svelte/solid-glass.json`],
files: [{ path: `registry/svelte/${name}/${name}.svelte`, type: "registry:ui", target: `${name}/${name}.svelte` }],
})),
]

const registry = {
$schema: "https://shadcn-svelte.com/schema/registry.json",
name: "solid-glass-svelte",
homepage: origin,
items,
}
writeFileSync(join(root, "registry/svelte/registry.json"), JSON.stringify(registry, null, 2) + "\n")
mkdirSync(out, { recursive: true })
for (const item of items) {
writeFileSync(join(out, `${item.name}.json`), JSON.stringify({
$schema: "https://shadcn-svelte.com/schema/registry-item.json",
...item,
files: item.files.map((file) => ({ ...file, content: readFileSync(join(root, file.path), "utf8") })),
}, null, 2) + "\n")
}
console.log(`svelte registry: ${items.length} items -> public/r/svelte/`)
Loading