diff --git a/.claude/settings.json b/.claude/settings.json index 697be98fc..386da5629 100644 --- a/.claude/settings.json +++ b/.claude/settings.json @@ -12,29 +12,6 @@ } ] } - ], - "PostToolUse": [ - { - "matcher": "Edit|Write|MultiEdit|NotebookEdit", - "hooks": [ - { - "type": "command", - "command": "node \"$CLAUDE_PROJECT_DIR/scripts/agent/claude.mts\" post-tool", - "timeout": 120 - } - ] - } - ], - "Stop": [ - { - "hooks": [ - { - "type": "command", - "command": "node \"$CLAUDE_PROJECT_DIR/scripts/agent/claude.mts\" stop", - "timeout": 300 - } - ] - } ] } } diff --git a/.codex/hooks.json b/.codex/hooks.json index a9c072efe..1aed79d86 100644 --- a/.codex/hooks.json +++ b/.codex/hooks.json @@ -12,31 +12,6 @@ } ] } - ], - "PostToolUse": [ - { - "matcher": "^(apply_patch|Edit|Write)$", - "hooks": [ - { - "type": "command", - "command": "node \"$(git rev-parse --show-cdup)scripts/agent/codex.mts\" post-tool", - "statusMessage": "Formatting and checking the edited files", - "timeout": 120 - } - ] - } - ], - "Stop": [ - { - "hooks": [ - { - "type": "command", - "command": "node \"$(git rev-parse --show-cdup)scripts/agent/codex.mts\" stop", - "statusMessage": "Checking every changed file", - "timeout": 300 - } - ] - } ] } } diff --git a/.githooks/commit-msg b/.githooks/commit-msg deleted file mode 100755 index 7c2326863..000000000 --- a/.githooks/commit-msg +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env node -// Git runs this file; the checks live in scripts/policy/gitHooks.mts, shared -// with every agent harness. Plain JavaScript because git executes it directly. -const childProcess = require('node:child_process'); -const path = require('node:path'); - -const entry = path.join(__dirname, '..', 'scripts/policy/gitHooks.mts'); -const hookArguments = ['commit-msg', ...process.argv.slice(2)]; -const result = childProcess.spawnSync(process.execPath, [entry, ...hookArguments], { - stdio: 'inherit', -}); -process.exitCode = result.status ?? 1; diff --git a/.githooks/pre-commit b/.githooks/pre-commit deleted file mode 100755 index 81a8e3eb5..000000000 --- a/.githooks/pre-commit +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env node -// Git runs this file; the checks live in scripts/policy/gitHooks.mts, shared -// with every agent harness. Plain JavaScript because git executes it directly. -const childProcess = require('node:child_process'); -const path = require('node:path'); - -const entry = path.join(__dirname, '..', 'scripts/policy/gitHooks.mts'); -const hookArguments = ['pre-commit', ...process.argv.slice(2)]; -const result = childProcess.spawnSync(process.execPath, [entry, ...hookArguments], { - stdio: 'inherit', -}); -process.exitCode = result.status ?? 1; diff --git a/.githooks/pre-push b/.githooks/pre-push deleted file mode 100755 index 6bf1ccd31..000000000 --- a/.githooks/pre-push +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env node -// Git runs this file; the checks live in scripts/policy/gitHooks.mts, shared -// with every agent harness. Plain JavaScript because git executes it directly. -const childProcess = require('node:child_process'); -const path = require('node:path'); - -const entry = path.join(__dirname, '..', 'scripts/policy/gitHooks.mts'); -const hookArguments = ['pre-push', ...process.argv.slice(2)]; -const result = childProcess.spawnSync(process.execPath, [entry, ...hookArguments], { - stdio: 'inherit', -}); -process.exitCode = result.status ?? 1; diff --git a/.github/workflows/candidate.yml b/.github/workflows/candidate.yml index bc5ce1a91..ec62b0caa 100644 --- a/.github/workflows/candidate.yml +++ b/.github/workflows/candidate.yml @@ -172,6 +172,11 @@ jobs: - run: npm ci - run: npm --prefix studio ci - run: npm run build + - name: Run Linux release preflight + run: | + sudo chown root:root node_modules/electron/dist/chrome-sandbox + sudo chmod 4755 node_modules/electron/dist/chrome-sandbox + xvfb-run --auto-servernum npm run check:linux - run: npx electron-builder --linux --publish never - name: Install and test Debian package # Refresh the package index first: the runner image's index named archive files that diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index eb55e728a..f1e29f3bd 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -26,10 +26,18 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 + with: + fetch-depth: 0 - uses: actions/setup-node@v6 with: node-version-file: .nvmrc cache: npm + - name: Check pull request commit messages + if: github.event_name == 'pull_request' + env: + BASE_SHA: ${{ github.event.pull_request.base.sha }} + HEAD_SHA: ${{ github.event.pull_request.head.sha }} + run: node scripts/policy/checkCommitRange.mts "$BASE_SHA" "$HEAD_SHA" - run: npm ci - run: npm --prefix studio ci - run: npm run format:check diff --git a/.pi/extensions/stacki-policy/index.ts b/.pi/extensions/stacki-policy/index.ts index 39cbed1d0..fa5323584 100644 --- a/.pi/extensions/stacki-policy/index.ts +++ b/.pi/extensions/stacki-policy/index.ts @@ -2,10 +2,7 @@ // Claude Code and Codex hooks enforce (scripts/agent/hook.mts), from the same // functions. Pi loads project extensions after the project is trusted. // -// tool_call refuses gate-skipping commands; asks before gate-file edits -// tool_result formats and checks each file a write or edit touched -// agent_before_settle checks every changed file; a failure continues the run -// with the findings, at most stopContinuationsMax times +// The tool-call guard asks before gate-file edits. GitHub runs the code checks. // // Pi's event payloads come from outside this repository, so they are read as // unknown and parsed field by field (AGENTS.md §2). The Pi package is not a @@ -14,15 +11,13 @@ import path from 'node:path'; import { commandVerdict, pathVerdict, repositoryPath, type Verdict } from '../../../scripts/agent/core.mts'; import { field } from '../../../scripts/agent/payload.mts'; -import { checkChanged, checkFiles, repositoryRoot } from '../../../scripts/policy/checks.mts'; -import { POLICY_LIMITS } from '../../../scripts/policy/limits.mts'; +import { repositoryRoot } from '../../../scripts/policy/checks.mts'; interface PiContext { readonly cwd: string; readonly hasUI: boolean; readonly ui: { confirm(title: string, message: string): Promise; - notify(message: string, type?: 'info' | 'warning' | 'error'): void; }; } @@ -37,7 +32,6 @@ const POLICY_EDIT_APPROVAL = 'STACKI_ALLOW_POLICY_EDITS'; export default function stackiPolicy(pi: PiApi): void { const root = repositoryRoot(); - let refusals = 0; pi.on('tool_call', async (event, context) => { const verdict = toolVerdict(root, event, context.cwd); @@ -56,46 +50,6 @@ export default function stackiPolicy(pi: PiApi): void { } return { block: true, reason: verdict.reason }; }); - - pi.on('tool_result', (event, context) => { - const file = editedFile(root, event, context.cwd); - if (file === undefined) { - return undefined; - } - const outcome = checkFiles(root, [file], { format: 'write' }); - if (outcome.kind === 'pass') { - return undefined; - } - const existing: unknown = Reflect.get(asObject(event), 'content'); - const content: readonly unknown[] = Array.isArray(existing) ? existing : []; - const text = truncate(`The edit left findings:\n\n${outcome.report}`); - return { content: [...content, { type: 'text', text }], isError: true }; - }); - - pi.on('agent_before_settle', (event, context) => { - const outcome = checkChanged(root); - if (outcome.kind === 'pass') { - refusals = 0; - return undefined; - } - refusals += 1; - if (refusals > POLICY_LIMITS.stopContinuationsMax) { - refusals = 0; - context.ui.notify('stacki: stopped with failing checks; run `npm run check:changed`.', 'warning'); - return undefined; - } - const existing: unknown = Reflect.get(asObject(event), 'entries'); - const entries: readonly unknown[] = Array.isArray(existing) ? existing : []; - const heading = - `The changes do not pass the repository checks yet (attempt ${refusals} of ` + `${POLICY_LIMITS.stopContinuationsMax}). Fix these, then finish:`; - const message = { - type: 'custom_message', - customType: 'stacki-policy', - content: truncate(`${heading}\n\n${outcome.report}`), - display: true, - }; - return { entries: [...entries, message], continue: true }; - }); } function toolVerdict(root: string, event: unknown, cwd: string): Verdict { @@ -124,8 +78,3 @@ function editedFile(root: string, event: unknown, cwd: string): string | undefin function asObject(value: unknown): object { return typeof value === 'object' && value !== null ? value : {}; } - -function truncate(text: string): string { - const limit = POLICY_LIMITS.feedbackCharsMax; - return text.length <= limit ? text : `${text.slice(0, limit)}\n… (truncated)`; -} diff --git a/AGENTS.md b/AGENTS.md index ac2be6505..25eb4d945 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -77,17 +77,12 @@ the same checks run for people and for every coding agent (Claude Code, Codex, Pi). `docs/enforcement.md` maps each rule to the check that holds it and lists the rules that remain for review. -- Agent hooks format and check each file you edit, and check every changed - file before you finish. Fix what they report; do not work around them. -- `npm run check:changed` runs the finish check by hand. Run it before you - say you are done. -- `npm run check:local` runs fast repository-wide checks before `npm run dev`. - All Desktop compiler targets and test source paths also run at agent finish, - because config changes and deleted files can break unchanged callers. -- Git hooks check staged files, commit messages, and pushes. Never skip them - (`--no-verify`); the agent hooks refuse it, and CI runs the same checks. -- Pushes run the full clean-build and regression gate locally so passing - TypeScript alone cannot send a known test failure to GitHub. +- GitHub Actions runs required checks for pull requests and pushes to + `main`. Wait for the checks on the current commit and fix failures before + merging. This keeps builds and tests off the contributor's machine and + checks every supported operating system. +- Run local checks only when the user asks. Commits, pushes, development + launches, and agent sessions can proceed without starting the test suite. - The files that define the gates (this file, lint and compiler configs, `scripts/{eslintPlugin,policy,agent}/`, hook configs, `shared/core/limits.ts`) change only with a human's approval. @@ -538,7 +533,7 @@ installs; their cost is amplified through everything built on them. `docs/contracts.md` before changing page trees, scans, preload methods, IPC channels, or renderer bridge modules. Values from IPC, disk, browser messages, drag data, and `JSON.parse` stay `unknown` until the matching shared or feature -boundary parser accepts them. Generated or edited code must pass +boundary parser accepts them. GitHub Actions runs the equivalent of `env -u ELECTRON_RUN_AS_NODE npm test`, which includes strict TypeScript, ESLint, production builds, contract tests, and the complete regression suite. @@ -554,10 +549,9 @@ ESLint, production builds, contract tests, and the complete regression suite. - Where a state machine exists, property-based tests (e.g. fast-check) hunt the transitions you didn't think of. A fuzzer proves the presence of bugs, never their absence — the mental model and its assertions come first. -- When a GitHub release or publishing workflow fails, reproduce the cause locally and add or - improve a regression test whenever possible before pushing again. This prevents the same - failure from recurring only in GitHub. Follow [publishing failure handling](docs/releases.md). - If local reproduction is impractical, document why and the verification that remains remote. +- When a GitHub release or publishing workflow fails, use the GitHub logs to + identify the cause and add or improve a regression test where possible. + Verify the fix on GitHub. Follow [publishing failure handling](docs/releases.md). ## Definition of done (checklist) @@ -579,7 +573,7 @@ ESLint, production builds, contract tests, and the complete regression suite. - [ ] Comments are sentences that say why; test files open with goal and methodology - [ ] New dependencies carry a written justification -- [ ] `npm run check:changed` passes (`tsc`, ESLint, Prettier, policy scan) +- [ ] GitHub Actions passes for the current pull request commit ## Code display diff --git a/README.md b/README.md index f71614784..fb100d790 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ MIT licensed — fork it, build on it, ship your own version. - **Git & GitHub** — the branch chip in the title bar shows the current branch and dirty state. From its dropdown you can switch branches, create branches, commit, push, or publish a brand-new repo to GitHub (via the `gh` CLI). - **Tell an AI what's selected** — **⇧⌘C** copies whatever the canvas has selected as the trail of `file:line-range` pointers that leads to it: the page, each component drilled into on the way down, then the node itself. Paste that into Claude Code or any AI chat that can read the project and it knows exactly which markup you mean. - **Code fallback** — pages with markup too complex for the visual model open in a code editor instead, still with live preview. -- **New project** — "Start from Lumos" or "Start from Astro" creates a named site with the framework's own scaffolder and installs its dependencies for you. +- **New project.** Choose "Start from Lumos", "Start from shadcn", or "Start from Astro". Stacki creates the site and installs its dependencies. A new shadcn site opens on Style Gallery and includes a Component Gallery page. Set Astro’s `site` option to your public URL before deploying so the sitemap, canonical links, and social image URLs use that domain. ## Running in development diff --git a/docs/enforcement.md b/docs/enforcement.md index c42089be5..04d00e457 100644 --- a/docs/enforcement.md +++ b/docs/enforcement.md @@ -1,33 +1,28 @@ # Enforcement AGENTS.md states the rules; this page says which machine holds each one, so a reader can tell a -rule that cannot be broken from one that relies on review. Everything below runs the same way for -a person, for Claude Code, for Codex, and for Pi, because every gate calls the same code. +rule that cannot be broken from one that relies on review. GitHub Actions verifies the +same repository rules for people and coding agents. ## Gates | Gate | When | What runs | Can it be skipped? | |---|---|---|---| | Agent pre-tool | Before an agent runs a command or edits a file | `scripts/agent/core.mts` verdicts | No: refusals come from the harness | -| Agent post-tool | After an agent edits a file | Prettier (writes), policy scan, ESLint on the file | No | -| Agent stop | When an agent tries to finish | Changed-file formatting, scan and lint; all Desktop compiler targets and test source paths | After 3 refusals for the same findings the session may end, and the human is told; new findings start a new round | -| `pre-commit` | `git commit` | Prettier check, scan, ESLint on staged files | `--no-verify`, which agent hooks refuse | -| `commit-msg` | `git commit` | Typed subject ≤ 72 characters, blank line, body | As above | -| Local development | `npm run dev` or `npm run check:local` | All Desktop compiler targets, full lint, formatting, policy, test source paths, Studio static checks | Run directly at any time | -| `pre-push` | `git push` | Full CI gate: clean builds, Desktop and Studio static checks and tests; a pushed version tag (`refs/tags/v…`) then runs the Linux preflight. Skipped only when every pushed tree already passed the full gate here (a marker keyed by tree hash and gate version, `scripts/gate/gateMarker.ts`) or a tag names a commit on `origin/main` that `Check` passed; `npm run check:local` (and the static Linux preflight for a tag) still runs | As above | -| Release (`npm run release:ship`) | Every release | The bump is a GitHub commit made from origin's files (version lines only, read back; subject fixed at 37 characters), so no local hook runs on it; the tag is created only when `Check` and `Candidate` are green on that exact SHA (`promote.mts` proves it again before publishing). The pre-push gate's job moves to CI on the exact commit | None: `release.yml` refuses to publish without both proofs | +| Commit messages | Every pull request | Typed subject ≤ 72 characters, blank line, body | GitHub Actions reports failures in the policy job | +| Local development checks | On request with `npm run check:local` | Desktop compiler targets, lint, formatting, policy, test source paths, Studio static checks | Optional | +| Release (`npm run release:ship`) | Every release | GitHub creates the version bump. The release tag requires green `Check` and `Candidate` runs on the exact commit | None: `release.yml` refuses to publish without both proofs | | Quarantine (`scripts/gate/quarantine.json`) | Every gate run | A listed suite's failure is reported and tolerated only with an owner, a reason, two red run URLs and an expiry at most 7 days after it was added; an expired, invalid or protected (correctness, safety, data-write) entry fails the gate (`scripts/gate/quarantine.ts`) | Renewing an entry needs a new commit with a new reason | | CI (`npm test -- --shard=k/4`) | Every pull request and push to `main` | Builds, `tsc` (app and scripts), ESLint, Prettier, scan, every test: a desktop static-checks job (`npm test -- --checks=desktop`), a Studio verify job (`--checks=studio`, 25-minute limit) and four test shards per platform, together exactly `npm test` (`scripts/gate/testShard.ts`); `test ()` passes only when all six did | **No**, once `main` requires the `Check` workflow | -The adapters are thin: `.claude/settings.json` and `.codex/hooks.json` call -`scripts/agent/{claude,codex}.mts`; `.pi/extensions/stacki-policy/` imports the same modules. Git -hooks live in `.githooks/` and are installed by `npm install` (`scripts/policy/installGitHooks.mts`). +Claude Code, Codex, and Pi use a pre-tool guard for changes to protected files. +Commits, pushes, and development launches proceed without running repository checks. +GitHub Actions runs the required checks on the pull request. Commands for people and agents: -- `npm run check:changed` — what the stop hook runs. Use it before you finish. -- `npm run check:local` — fast, repository-wide checks before starting development. - `npm run dev` runs these automatically before building and launching the app. +- `npm run check:changed` — optional checks for changed files. +- `npm run check:local` — optional repository-wide checks. - `npm run typecheck` — checks the root, scripts, contracts, Electron, preload and preview compiler configurations with separate incremental caches. The broad root program alone cannot catch differences in the build targets' library and module settings. @@ -45,12 +40,6 @@ Commands for people and agents: whole-tree static checks, so it is no substitute for `check:changed` or the full gate (`scripts/gate/gatePlan.ts`). -The push hook compiles the test runner and runs the full gate (unless the marker or green-tag proof above holds), with live output and a 30-minute -limit per command. It clears `ELECTRON_RUN_AS_NODE` for its children so agent terminals do not -silently run browser probes as Node programs. A failed build or test stops the push. This costs -several minutes, but catches local regressions before GitHub starts a release. CI still checks -clean dependency installation and all three operating systems; local checks cover the host OS. - ### The gate files Some files define the gates themselves: `AGENTS.md`, `CLAUDE.md`, `eslint.config.mjs`, the @@ -134,7 +123,7 @@ an allow (`withRootAsDot` in `scripts/agent/core.mts`; issue #78). | 17 | Dependencies justified | scan: `dependency-record` (`docs/dependencies.md` ↔ `package.json`) | | 17 | One lockfile | scan: `one-lockfile` | | 17 | Scripts are TypeScript | scan: `no-shell-script` | -| 17 | Descriptive commit messages | hook: `commit-msg` | +| 17 | Descriptive commit messages | CI: pull request commit message check | | — | No `@ts-nocheck`; `@ts-expect-error` says why | scan: `no-ts-nocheck`; lint: `ban-ts-comment` | | — | Code display: code in the UI is syntax highlighted | test: `test/renderer/ui/codeDisplayRule.test.js` (source scan with named allowlists); `test/renderer/ui/codeBlock.test.js` for each site; review for code that looks like a label | | — | Dropdowns: the custom dropdown, never a native `` and `createElement('select')`) in `src/` via `eslint.config.mjs`, and in `studio/src/` and `studio/demo/` via `studio/eslint.config.ts`, which loads the vendored rule file | diff --git a/docs/releases.md b/docs/releases.md index 27b468f43..44b372b4a 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -14,16 +14,9 @@ These are separate publication paths. A successful `Check` run publishes nothing `.github/workflows/release-post.yml` once the desktop release is public. See [create-stacki publication](./create-stacki.md) for authentication and registry verification. -Run the fast checks and complete regression suite locally before pushing. Also run Studio's -`npm run verify` and `npm run test:browser` against a disposable fixture workspace before tagging: -the Desktop regression gate does not run that separate Studio browser scenario. - -Pushing a version tag runs the Linux preflight automatically: the `pre-push` hook runs it after the -full gate has rebuilt `dist/`, and a failure stops the tag reaching GitHub, so no release build -starts. The release scripts push the bump commit and the tag in one atomic push, so after a failure -neither reached GitHub and the tag exists only locally: fix the finding, delete the local tag, and -run again; never move a pushed tag. Run `npm run check:linux` by hand (about 30 seconds) to find problems before -tagging. It checks, on a Mac, the ways the Linux release job has failed: +Wait for Check and Candidate on GitHub before tagging. Candidate runs the separate Studio browser +scenario and the Linux release preflight. A failure blocks publication of that commit. The preflight +covers common Linux release failures: - relative imports and package or workflow paths match their files' case exactly (macOS ignores case, Linux does not), and no two tracked paths differ only in case; diff --git a/docs/tasks/heroui-starter.html b/docs/tasks/heroui-starter.html new file mode 100644 index 000000000..b1156e7f4 --- /dev/null +++ b/docs/tasks/heroui-starter.html @@ -0,0 +1,400 @@ + + + + + + Stacki HeroUI starter tasks + + + +
+
+

Stacki HeroUI starter tasks

+

+ Add Start from HeroUI beside Start from shadcn in the Stacki fork. Desktop creates and opens an Astro site. In + Desktop and Studio, users can insert the full public HeroUI React v3 catalog, edit component props and content, and change the light and dark theme in + Variables. The generated site includes a style guide and an interactive component gallery. +

+

+ The heroui_starter branch starts at local main, commit 5d4cd354. This plan records the source audit, + implementation tasks, and verification results. +

+
+ + + +
+

What ships

+
    +
  • + Desktop wizard. Pick a parent folder, enter a site name, see the read-only project path update, and choose npm or pnpm in Stacki's + dropdown. npm is the initial choice. Show creation progress and open the site when setup finishes. A failed creation preserves the wizard inputs for + retry. +
  • +
  • + Components. Provide one useful insertion per documented component shipped in the pinned public React package. Expose meaningful + variants, defaults, and compound content through typed Astro props or slots. Include helpers such as Label and FieldError with the context they need + to work. The catalog covers the free package. HeroUI Pro requires a separate licensing decision. + React component catalog · + Pro licensing +
  • +
  • + Variables. Expose the public theme settings for both modes in project CSS. Include shared settings once where they apply to both + modes. Keep derived values linked to their inputs. Inventory documented component-level overrides as well and record which belong in the theme and + which are per-component styles. +
  • +
  • + Generated pages. Open on Style Guide at / with a link to Example Components at /example-components. Both + pages use the same project CSS. A Light / Dark control on the generated site changes the theme of the page and its overlays. +
  • +
+
+ +
+

What the audit found

+
    +
  • + Stacki already has a folder picker, wizard handoff, request parser, creation logs, and staged generator for shadcn. The wizard opens the returned + path through the normal project flow. Creation handlers share a log channel, so concurrent attempts can interfere unless the channel has one owner. + Welcome screen · + Project handlers · + Staged generator +
  • +
  • + Desktop and Studio discover Astro files and resolve the same insertion recipes. The shadcn gallery exposes editable props and slots on Astro + wrappers and renders interactive controls in React islands. A palette tile has its own preview route, so verify it separately from the interactive + page. + Desktop discovery · + Studio discovery · + Editable gallery pattern · + Tile preview +
  • +
  • + Both editors read authored CSS custom properties. Declarations supplied only by dependencies or declared directly in Tailwind's + @theme are outside the current variable scan. Project-owned declarations in ordinary CSS rules give the editor a source location it can + write back to. CSS variable reader · + Studio variable reader · + Studio variable edits +
  • +
  • + The registry publishes matching @heroui/react@3.2.8 and @heroui/styles@3.2.8. The React tarball contains 73 component + documentation pages. HeroUI requires React 19 and Tailwind 4. Those dependencies belong in the generated site. The pinned package docs and exports + give the implementation a versioned baseline. Release notes · + React manifest · + Styles manifest · + React tarball +
  • +
+
+ +
+

Implementation tasks

+
    +
  1. Pin and build a disposable Astro site
  2. +
  3. Prove the editing workflow on four components
  4. +
  5. Expose and verify the full theme
  6. +
  7. Ship the full component catalog
  8. +
  9. Build the generated style guide and gallery
  10. +
  11. Add the shared starter request
  12. +
  13. Generate and publish the site safely
  14. +
  15. Connect the Desktop wizard
  16. +
  17. Verify the shipped workflow
  18. +
+ +
+

1. Pin and build a disposable Astro site

+

+ Start with the Astro version supported by the checkout's Studio package. Pin compatible versions of Astro, @astrojs/react, React and + React DOM 19, Tailwind 4 and its Vite plugin, and both HeroUI packages at 3.2.8. Record the registry integrity values and check the + resolved React Aria and date peers. Wire the full documented CSS imports through one shared Astro layout. Put the initial theme on + document.documentElement so portalled overlays inherit it. +

+

+ Pass when npm and pnpm each install and resolve the same intentional dependency set, the site builds and serves production output, + and a hydrated Button renders with the expected styles without console or hydration errors. Record the actual installed versions and explain any + additional dependency. HeroUI quick start · + Astro React integration · + Astro Tailwind integration +

+
+ +
+

2. Prove the editing workflow on four components

+

+ Add Button, Card, Text Field, and Modal wrappers to the site. Use them to prove literal props and variants, named slots, a saved field default, and + a portalled control. Add insertion recipes keyed by project-relative Astro paths in .stacki/components.json. Keep compound parts, + controlled state, and callbacks in one React island. Pass serializable values through Astro. Hydrate the controls that need interaction. +

+

+ Pass when both editors discover and insert all four, and the resulting Astro source contains the expected imports, props, and slot + content. Edit a label, slot, and default, then reload and confirm each saved edit. Typing in a live field leaves the source intact. Open the Modal + by keyboard, verify focus containment and themed overlay styles, close it with Escape, and verify focus returns to the trigger. Check the palette + tile separately. Fix any blocker here before expanding the catalog. Recipe contract · + Astro client directives +

+
+ +
+

3. Expose and verify the full theme

+

+ Compare the official theming reference with dist/themes/default/variables.css and dist/themes/shared/theme.css in the + pinned styles tarball. Keep a versioned inventory of shared, light, and dark settings. Cover semantic colors, surfaces, overlays, field and focus + styles, spacing, radii, typography, shadows, and other documented public settings. For each entry, record its selector, expected value or + expression, and where users edit it. +

+

+ Write the public source settings into ordinary project CSS rules. Verify the cascade after the library import and keep Tailwind mappings and + calculated values connected to their inputs. Provide a document-level light/dark control. Preserve an explicit choice across navigation and reload. + Check the actual theme selectors against both editors and against portalled content. +

+

+ Pass when every inventory entry has a disposition and each public theme setting can be changed in the intended mode. Test an accent + color, an overlay color, a radius, a font setting, and a derived hover color. In each editor, compare the CSS before and after a save, then reload + and verify the computed value in the matching mode. Changing a dark declaration leaves the light declaration intact. An alias keeps resolving after + its source value changes. HeroUI theming · + Dark mode · + Styles tarball +

+
+ +
+

4. Ship the full component catalog

+

+ Build a checked-in manifest from the pinned tarball's component documentation slugs. Compare it with the pinned React exports and the official Free + catalog. Record discrepancies with their source and rationale. Map every component to an Astro wrapper, insertion recipe, gallery demo, and test + case. Check for duplicate names, missing files, invalid slots, cyclic references, and recipe limits. +

+

+ Develop and verify by component family. Give overlays, selections, date controls, and forms early coverage. In particular, test Select inside a + Modal, two independent instances of a controlled collection, a date range encoded as serializable inputs, and validation with the correct accessible + label and error. Use context-aware demos for components that depend on a form, group, or trigger. +

+

+ Pass when the manifest, Components panel, and gallery agree with the pinned public inventory. Every recipe parses, inserts, builds, + and renders. Representative interactions per family work in production output. Changing a saved default takes effect on reload, and preview + interactions leave that default intact. A coverage test reports missing or unexpected entries when the package pin changes. + shadcn inventory pattern · + Recipe parsing and limits · + HeroUI composition +

+
+ +
+

5. Build the generated style guide and gallery

+

+ Create the shared layout and both Astro routes. Show theme colors, typography, spacing, radii, and representative states on Style Guide. Generate + Example Components from the same manifest as the insertion recipes. Use the editable wrappers in the examples so changes in the inspector affect the + same components users insert on their own pages. Use an accessible theme control and readable category navigation. +

+

+ Pass when both pages appear in the Stacki page tree, navigation and theme switching work in the built site, and representative + cards remain usable on a narrow viewport and with the keyboard. Both pages render after a fresh install. The gallery links and examples cover every + manifest entry. shadcn generated layout and routes +

+
+ +
+

6. Add the shared starter request

+

+ Read the shared contract before editing IPC. Extend project:createStarter with a HeroUI discriminator and shared location fields. Reuse + the site-name, absolute parent-path, and package-manager parsers. Preserve the existing success reply and the legacy omitted-discriminator Lumos + behavior. Keep starter-specific options on their own variants. Update the welcome bridge and handler through the existing request path. +

+

+ Pass when contract tests accept valid HeroUI input for both managers and retain the Lumos and shadcn cases. Reject unknown + starters, unsafe names, missing or relative parent paths, unsupported package managers, over-limit values, and shadcn options on a HeroUI request. + Shared contracts · Starter request parser · + Existing contract tests +

+
+ +
+

7. Generate and publish the site safely

+

+ Write the versioned template into a staging directory under the canonical parent. Reuse existing bounded command and package-manager handling where + the behavior matches. Isolate installation from any parent workspace. Write the app files and tracked .stacki metadata, verify the + selected lockfile and manifest, and create and verify the initial Git commit before publishing. Ignore only generated + .stacki/preview/ within the metadata directory. +

+

+ Claim the destination without overwriting files. Define what happens if publication fails partway through, including how a failed rollback preserves + the files needed for recovery. Stop the subprocess before cleanup. Give creation attempts one owner for the shared log and progress stream and + release that ownership on success and failure. +

+

+ Pass when generator tests cover missing tools, install or Git failure, timeouts, symlink parents and destinations, destination + races, a partial move, failed rollback, retry, and concurrent requests. Test successful creation with both managers under an existing workspace. + Confirm the published directory still installs and builds after relocation and Desktop detects the selected package manager. + Staged creation and publication · + Command runner · + Generator test patterns +

+
+ +
+

8. Connect the Desktop wizard

+

+ Add Start from HeroUI to the Welcome menu and connect it to the folder picker. Reuse the existing site name, path preview, + package-manager Dropdown, and progress patterns. Add translated UI strings. Pass the successful project path to the existing open action. Report the + failed creation step in the wizard with the option to retry. +

+

+ Pass when keyboard users can pick HeroUI, choose a package manager, and create a site. Cancelling the picker leaves the welcome + screen ready for another choice. An invalid name stays editable. An install failure retains the entered name and selected manager. Success opens + Style Guide, and Desktop can reopen the published path through Open from folder. Check the existing Lumos, Astro, and shadcn choices. + Welcome starter actions · + Wizard pattern · Translation guidance +

+
+
+ +
+

9. Verify the shipped workflow

+
    +
  • + Create sites through Desktop with npm and pnpm in clean directories. Include a parent path with spaces. Confirm each project opens, both routes + build, Git captures the generated source, and a failed install can be retried without inheriting a partial site. +
  • +
  • + Run astro-studio check-project <project-directory> using the installed Studio CLI against each generated project. Fix missing + component paths, invalid slots, and cycles together. Open the Desktop-hosted Studio and a standalone Studio draft and verify that each saves to the + expected workspace. Studio modes and project check +
  • +
  • + In Desktop and Studio, exercise palette discovery, insertion, inspector edits, named slots, undo and redo, a saved default after reload, and two + independent interactive instances. Reopen the saved project and compare the authored Astro and CSS with what the preview shows. +
  • +
  • + Compare light and dark in the built site and in interactive preview. Verify focus, Escape, and computed overlay styles on a portalled control. + Confirm a Variables edit targets the matching declaration and leaves unrelated source intact. Check the palette tile for the intended theme. +
  • +
  • + Run npm run check:changed and env -u ELECTRON_RUN_AS_NODE npm test for the implementation. Record results for supported + macOS, Windows, and Linux jobs, the package managers exercised, the catalog coverage result, and any checks that still need a run. Use the normal + repository hooks. Repository checks · Enforcement +
  • +
+

+ The starter is ready when a user can create and reopen a HeroUI site, insert every catalog entry, use its interactions in preview, and save theme + changes in both editors. The four-component fixture is the first evidence for that workflow. +

+
+ +
+

Pilot results

+
    +
  • + On macOS with Node 22.23.5, a disposable Astro 7.3.8 project with HeroUI 3.2.8 built with both npm and pnpm. The production page rendered Button, + Card, Text Field, and Modal. Reloading restored the authored field default. Modal used the active theme, held focus while open, and returned focus + to its trigger after Escape. +
  • +
  • + Desktop and standalone Studio discovered the pilot's Astro wrapper and inserted its configured props and slot text. Desktop saved a dark variable to + the project. Standalone Studio saved the same kind of edit to its draft and preserved the source project. +
  • +
+
+ +
+

Generated starter results on macOS

+
    +
  • + The built Desktop app created npm and pnpm sites through Start from HeroUI and opened Style Guide in the canvas. Desktop discovered all 73 wrappers + in each site and saved a dark overlay variable without changing the light declaration. +
  • +
  • + npm and pnpm sites built after publication and a locked reinstall. Each kept its selected lockfile, recorded matching direct dependency versions, + and contained one initial Git commit. Both passed astro-studio check-project. +
  • +
  • + Both production galleries contained all 73 audited examples and their projects had 73 insertion recipes. In Chromium, the gallery hydrated 56 + islands. Tabs changed selection, dark mode persisted after a reload, Select worked inside Modal, and Escape restored focus to the trigger. The + gallery fit a 390-pixel viewport. +
  • +
  • + The generated site's Astro React integration requires Node.js 22.23.4 or later. The project manifest and generated README record that minimum. +
  • +
  • + Standalone Studio opened a generated project's interactive preview and changed the HeroUI Pin item toggle from unpressed to pressed. Vite served the + linked React and HeroUI modules while refusing requests for the original project's manifest. The starter prebundles React DOM's client entry so + Astro can import its named exports in development. +
  • +
  • + Studio's source-editing mode discovered all 73 wrappers, inserted a HeroUI Button from the palette, and saved a dark overlay variable to the + original site. The generated gallery also responded to a click on its hydrated Pin item toggle. +
  • +
+
+ +
+

Audited catalog baseline

+

+ These 73 slugs come from package/docs/components/ in the @heroui/react@3.2.8 tarball. Task 4 reconciles them with the + exports and proves an insertion for each component. Pinned React tarball +

+
+

+ accordion, alert, alert-dialog, autocomplete, avatar, avatar-group, + badge, breadcrumbs, button, button-group, calendar, card, + checkbox, checkbox-group, chip, close-button, color-area, color-field, + color-picker, color-slider, color-swatch, color-swatch-picker, combo-box, + date-field, date-picker, date-range-picker, description, disclosure, + disclosure-group, drawer, dropdown, error-message, field-error, + fieldset, form, input, input-group, input-otp, kbd, + label, link, list-box, meter, modal, number-field, + pagination, popover, progress-bar, progress-circle, radio-group, + range-calendar, scroll-shadow, search-field, select, separator, sheet, + skeleton, slider, spinner, surface, switch, table, tabs, + tag-group, text-area, text-field, time-field, toast, toggle-button, + toggle-button-group, toolbar, tooltip, typography. +

+
+
+
+ + diff --git a/docs/tasks/shadcn-starter.html b/docs/tasks/shadcn-starter.html new file mode 100644 index 000000000..1a8025a1a --- /dev/null +++ b/docs/tasks/shadcn-starter.html @@ -0,0 +1,330 @@ + + + + + + Stacki shadcn starter tasks + + + +
+
+

Stacki shadcn starter tasks

+

+ Add a standalone shadcn Astro starter to Stacki. After creation, the site opens on Style Guide with Example Components in its navigation. The + generated theme is editable through Variables, and each advertised starter component is insertable through Components. +

+

This plan records the implementation order and acceptance checks for shadcn-starter. The implementation uses shadcn CLI 4.23.0.

+
+ +
+

Product decisions

+
+
Welcome and project type
+
+ Keep Lumos as the main action. Add Start from shadcn beside Start from Astro in its dropdown. Use the Lumos folder picker and wizard flow. Astro is + fixed, and the starter creates one standalone site. +
+
Project fields
+
+ Show Site name, a read-only Project path that updates with the name, and Stacki's existing Package manager dropdown. npm is the initial selection. +
+
Base and icon library
+
+ Use visible single-select cards with monochrome SVG marks, full labels, and keyboard focus for both fields. Base UI is selected initially, with + React Aria and Radix UI available. Icon choices are Lucide, Tabler Icons, Hugeicons, Phosphor Icons, and Remix Icon. Lucide is selected initially. + Use the shadcn mark next to Start from shadcn in the welcome menu. +
+
Preset and switches
+
+ Use Nova with the Neutral palette when the optional preset code is blank. A valid pasted code loads its theme and selects its icon library. A + subsequent icon choice overrides that one field. Base, pointer cursor on buttons, and RTL support come from their own controls. Both switches start + off. Enabling RTL support adds a reading direction control to the generated previews. A new preview still opens left to right. An invalid code gets + an inline error. +
+
After Create site
+
+ Show progress and open the live preview after setup succeeds. On failure, show the failed step and preserve the wizard input. The editor integration + uses the starter, project CSS, and the existing Components and Variables tabs. +
+
+

+ Marketplace apps add optional editor tools. Lumos Fluid Builder is independent of the Lumos starter. Marketplace packaging, UI SDK, monorepo + generation, and a built-in copy of the shadcn theme configurator are outside this contribution. Stacki Apps guide +

+
+
+

What the audit found

+
    +
  • + Stacki runs the Lumos generator, then applies project defaults, installs dependencies, and handles Git. The welcome wrapper passes one alternative + action to a shared split button that already supports several. Starter runner · + Project creation handlers · + Welcome split button +
  • +
  • + The earlier official shadcn Astro run on Base UI and Nova produced a buildable site with React, Tailwind, a Button, a lockfile, and an initial + commit. The CLI manages install and Git during creation. The remaining bases, icon overrides, and cross-platform manager behavior need verification. + Official Astro setup · CLI options +
  • +
  • + Stacki reads authored CSS custom properties from source, including :root and .dark. The palette scans Astro files. shadcn + generates React source and keeps CLI configuration in the root components.json. Stacki stores its insertion recipes in + .stacki/components.json. Variable reader · + Desktop discovery · + Studio discovery · + Project metadata +
  • +
+
+
+

Tasks in implementation order

+
+

1. Verify the official CLI in disposable sites

+

+ Record the CLI version used for the contribution and make Astro and standalone generation explicit. Prove the effective package manager and lockfile + for every manager exposed in the wizard, including a destination under a parent with different package-manager metadata. Check what the CLI installs + and commits. Document the tested invocation so implementation can reuse it. +

+

+ Use shadcn's preset tools to validate and resolve the optional code. For icon overrides, test the supported migrate icons command + before installing the starter's component list. Verify it updates the generated config, imports, and dependencies without changing the selected + theme. Use the resolved icon library for later additions. Address any unsupported icon mappings before exposing the corresponding choice. +

+

+ Done when all three bases and five icon libraries have evidence from generated output. Cover the blank and custom presets, one + conflicting icon override, pointer on and off, and RTL on and off. Check the generated CSS, config, and lockfile as well as a successful Astro + build. Use a targeted matrix that covers each option and the interactions above. shadcn CLI · + RTL conventions +

+
+
+

2. Define the starter request and defaults

+

+ Read the shared contracts first. Model Lumos and shadcn requests as distinct variants and keep the shared package-manager and name rules. Validate + base, icon library, preset code, path, and switches at the boundary. Share the option defaults between the renderer and main process. Separate an + untouched preset-derived icon from an explicit user selection so a preset change updates the right field. +

+

+ Done when focused contract tests accept every supported option and reject malformed requests, unknown values, oversized input, + option-like values, and invalid codes. Existing Lumos requests still work. Stacki contracts · + IPC payloads · Welcome bridge +

+
+
+

3. Create and open the site safely

+

+ Reuse Stacki's subprocess, progress, tool-path, and project-default helpers where their behavior fits. Pass an argument list to the official CLI. + Check required tools before writing. Confirm the CLI selected the requested manager before proceeding. Account for its own install and Git steps, + preserve a coherent initial history of the finished site, and keep Git configuration and remotes local to the generated project. +

+

+ Give each attempt an owned work location and refuse to replace existing files or links. Put the finished site at the requested path only after + generation, theme setup, and starter content succeed. Verify relocatability for each manager before relying on a staged install. Bound subprocess + duration and output. Wait for the attempt to stop writing before offering retry, and keep stale logs out of the next attempt. Preserve the existing + Cancel behavior while creation runs. +

+

+ Done when success returns a valid Astro path with the chosen lockfile and final starter files. Missing tools, timeout, invalid + preset, a concurrent attempt, and a destination created during setup produce a clear outcome without overwriting user files. Confirm a failed + install neither opens an incomplete site nor leaves the final path marked successful. + Starter process runner · + Existing project finalization · + Starter tests +

+
+
+

4. Add the welcome action and wizard

+

+ Pass multiple alternatives to the existing welcome split button. Open the parent-folder picker first. Reuse the existing wizard fields, custom + Package manager dropdown, logs, and translations. Use labelled, keyboard-accessible single-select groups for Base and Icon library, plus the + existing switch style for pointer and RTL. Link to shadcn Create beside the optional preset field. +

+

+ Done when keyboard and mouse users can open the new flow, cancel the folder picker, edit options, and submit once. Verify the + default and preset icon selection, an explicit icon override, both switches, validation feedback, progress, retry, and opening after success. Lumos + and plain Astro retain their existing flows. Welcome screen · + Existing wizard · + Welcome tests +

+
+
+

5. Verify light and dark theme variables

+

+ Keep shadcn's theme in the generated site's global stylesheet under src. Use the authored :root and + .dark declarations for editable values. Preserve Tailwind's @theme inline aliases. Confirm each color token supplied by + the selected theme appears under the correct scope in Variables, including background, foreground, primary, accent, chart, and sidebar colors when + present. +

+

+ Done when Desktop and Studio edit the same light and dark token independently, save only the intended declaration, and update the + computed color on the page in the matching mode. Verify the saved values after reopen and exercise an outdated edit. If current Stacki misses a + declaration, fix the shared reader or the generated CSS at the source. + shadcn theme tokens · + Studio variable operations +

+
+
+

6. Prove palette insertion with Button

+

+ Keep the official React Button and add a thin, project-owned Astro wrapper. Expose an editable label and supported variant. Set useful insertion + defaults in .stacki/components.json and use normal Astro props and slots. Keep Stacki markup out of Astro files. +

+

+ Done when Button appears in Components in Desktop and Studio. Insert it into a test page, change label and variant, then check + preview, saved source, undo and redo, and reopen. Confirm the generated shadcn source stays intact during instance edits. Repeat on all three bases + before expanding the catalogue. Stacki component guide · + Recipe validation +

+
+
+

7. Build Style Guide and Example Components

+

+ Make Style Guide the homepage. Show semantic colors, typography, radius, and the selected icons alongside working controls. Use Example Components + for a composed interface with realistic sample data. Use shadcn's Toggle Group for theme selection in the shared Astro layout and for LTR or RTL + selection when the project enables RTL support. Remember each choice across navigation. Use the generated project's theme and registry components on + both pages. shadcn Create preview reference +

+

+ Done when a fresh install opens on Style Guide, both links work in the canvas, and the pages build as normal routes. Change a theme + token and see it update in both. Check keyboard and focus behavior in a Dialog or another overlay, and verify that Tabs respond and retain saved + defaults after reopen. Test RTL layout and overlay placement with Arabic content. + Astro hydration +

+
+
+

8. Verify every component shipped in the starter

+

+ Install every registry:ui entry supported by the selected base and let shadcn resolve its dependencies. The 4.23.0 registry contains 65 + Base UI entries, 64 Radix UI entries, and 62 React Aria entries. Add the three documented compositions for Data Table, Date Picker, and Typography. + Keep compound React widgets in one island where their parts share state. Use Astro wrappers and recipes for Components, and preserve the generated + CSS variables and Tailwind theme aliases. +

+

+ Done when the installed inventory and searchable Components entries match for every base. Test insertion of each advertised entry + in Desktop and Studio, verify its default content and rendered output, and exercise interactive examples in the canvas. Run the installed + astro-studio check-project <project-directory> on generated fixtures to catch missing paths, invalid slots, or cycles. + Official component catalogue · + Studio insertion tests · + Studio preview checks +

+
+
+

9. Run contribution checks

+

+ Read the repository instructions for the touched areas. Use the existing gates and hooks. Run npm run check:changed and + env -u ELECTRON_RUN_AS_NODE npm test for the completed feature. Run the generated site's astro build through its chosen + package manager. Run the existing Desktop and Studio browser checks that cover the changed paths. Create a fresh site through the actual welcome + flow and record the exact base, preset, icon library, manager, and switches used. +

+

+ Done when the tested checkout can create a site, open both pages, edit theme values, and insert the shipped components. Record any + combinations still unverified before asking for review. Keep unrelated Builder changes, policy files, and generated preview output out of the + contribution. Repository instructions · Checks and hooks +

+
+
+
+

Initial starter verification on macOS

+
    +
  • + The Desktop wizard created a real site from a custom preset under a symlinked parent folder. It applied the selected base, icon override, pointer + and RTL settings and opened Style Guide. +
  • +
  • + Generated Base UI, Radix UI and React Aria sites built successfully. npm and pnpm kept their own lockfiles when launched under a parent configured + for the other manager. +
  • +
  • + All six starter components saved through the Desktop and Studio palettes. A Button label and variant edit updated the Desktop canvas and Astro + source. Light and dark color declarations saved independently in Studio. +
  • +
  • + Both starter pages rendered with working navigation and theme switching. Browser checks exercised Tabs and an Arabic RTL Dialog with focus return. +
  • +
  • + The full repository run reported an EmDash dialog layout failure that also reproduced on unchanged commit b36a2d02. The phone preview's + skeleton timing failure also reproduced on that commit and passed an isolated branch rerun. +
  • +
+
+
+

Full catalog verification on macOS

+
    +
  • + The Desktop wizard kept all eight choice labels inside their cards at the standard width and in a narrow right-to-left window. Pointer and arrow-key + selection worked. The menu mark and choice card marks used monochrome SVG artwork. +
  • +
  • + A fresh Radix UI project completed through the Desktop wizard with npm, Tabler Icons, and RTL support enabled. A fresh React Aria project also + completed with pnpm, Phosphor Icons, and RTL support enabled. +
  • +
  • + Desktop discovered 68 Base UI, 67 Radix UI, and 65 React Aria entries. Each total includes Data Table, Date Picker, and Typography. Each project + passed + astro-studio check-project. A temporary route rendered all entries together for each base and passed astro check, + astro build, and browser hydration checks. +
  • +
  • + Both preview pages opened in LTR on fresh visits. The LTR and RTL choices persisted across routes and reloads when RTL support was enabled. The + dialog followed the selected direction and returned focus on Escape. The light, dark, and system choices updated the shared theme tokens. +
  • +
+
+
+ + diff --git a/electron/handlers/projectHandlers.ts b/electron/handlers/projectHandlers.ts index 8936820fa..790c6be9d 100644 --- a/electron/handlers/projectHandlers.ts +++ b/electron/handlers/projectHandlers.ts @@ -9,6 +9,8 @@ import * as fs from 'fs'; import * as os from 'os'; import { writeNewProjectDefaults } from '../project/newProjectDefaults'; import { createStarter, newSiteDirectory, runCreateCommand, startSiteHistory, STARTERS } from '../project/starter'; +import { createHeroUIStarter } from '../project/herouiStarter'; +import { createShadcnStarter, inspectShadcnPreset } from '../project/shadcnStarter'; import { isWin } from '../lib/mainHelpers'; import { ensureToolPath, run } from '../lib/nodeTools'; import { isAstroProject } from '../project/projectFiles'; @@ -20,12 +22,34 @@ import { folderOpenChoice, siteFolderChoice } from '../project/folderOpen'; import { checkAstroCopyTarget, createAstroCopy } from '../project/astroCopyWrite'; import { ASTRO_COPY_LIMITS, type AstroCopyInstall, type AstroCopyReply, type SiteFolderChoice } from '../../shared/ipc/astroCopy'; import { err, ok } from '../../shared/core/result'; +import type { IpcPayloads } from '../../shared/ipc/ipcPayloads'; +import type { IpcResults } from '../../shared/ipc/ipcResults'; + +type CreationChannel = 'project:createAstro' | 'project:createStarter' | 'project:createAstroCopy'; +type RegisterCreation = (channel: Channel, create: (request: IpcPayloads[Channel]) => Promise) => void; export function registerProjectHandlers(host: Pick): void { + // Every creation wizard reads the same log and progress channels. Refuse concurrent runs + // before they can emit output or touch the chosen folder. + let creating = false; + const registerCreation: RegisterCreation = (channel, create) => { + host.ipcMain.handle(channel, async (_event, request) => { + if (creating) { + throw new Error(translateMain('error.project.creationBusy')); + } + creating = true; + try { + return await create(request); + } finally { + creating = false; + host.send('progress', PROGRESS_CLEARED); + } + }); + }; registerProjectOpenDialogHandlers(host); - registerProjectCreateAstroHandlers(host); - registerProjectCreateStarterHandlers(host); - registerAstroCopyHandlers(host); + registerProjectCreateAstroHandlers(host, registerCreation); + registerProjectCreateStarterHandlers(host, registerCreation); + registerAstroCopyHandlers(host, registerCreation); } function registerProjectOpenDialogHandlers({ ipcMain, showOpenDialog }: Pick): void { @@ -49,14 +73,17 @@ function registerProjectOpenDialogHandlers({ ipcMain, showOpenDialog }: Pick): void { +function registerProjectCreateAstroHandlers( + { ipcMain, send, showOpenDialog }: Pick, + registerCreation: RegisterCreation, +): void { // Runs the real `npm create astro@latest`, answering the questions the CLI // would ask interactively with the choices collected in the app's wizard. // Output is streamed to the renderer so the user sees the same progress the // terminal would show. The wizard names the site, so its folder is made here, // empty, and create-astro runs in it with "." as the target rather than // guessing a name. - ipcMain.handle('project:createAstro', async (_event, options) => { + registerCreation('project:createAstro', async (options) => { const { parentPath, name, template = 'basics', install = true, git = true, ai = false, packageManager = 'npm' } = options || {}; const directory = newSiteDirectory(parentPath, name); ensureToolPath(); // npm is a Node shim — same PATH problem as astro @@ -104,18 +131,30 @@ function registerProjectCreateAstroHandlers({ ipcMain, send, showOpenDialog }: P }); } -function registerProjectCreateStarterHandlers({ ipcMain, send }: Pick): void { - // Starting from a starter. The scaffolder, the first commit and the package's - // name are in ./starter.js; what is here is the install that follows and the - // log the wizard reads. - ipcMain.handle('project:createStarter', async (_event, { starter = 'lumos', parentPath, name, packageManager = 'npm' }) => { +function registerProjectCreateStarterHandlers({ ipcMain, send }: Pick, registerCreation: RegisterCreation): void { + ipcMain.handle('project:inspectShadcnPreset', (_event, { preset }) => { + ensureToolPath(); + return inspectShadcnPreset(preset); + }); + // The staged generators finish installation and history before they publish the + // project. Lumos installs and starts its history in the resulting folder. + registerCreation('project:createStarter', async (request) => { ensureToolPath(); // npm and git are both on the PATH the Dock does not have + const onLog = (text: string): void => send('create:log', text); + if (request.starter === 'heroui') { + return { ok: true, ...(await createHeroUIStarter(request, onLog)) }; + } + if (request.starter === 'shadcn') { + send('progress', { message: 'Creating the shadcn site…' }); + return { ok: true, ...(await createShadcnStarter(request, onLog)) }; + } + const { starter = 'lumos', parentPath, name, packageManager = 'npm' } = request; await requirePackageManager(packageManager); const result = await createStarter({ starter, parentPath, name, - onLog: (text) => send('create:log', text), + onLog, }); const label = STARTERS[starter]?.label ?? starter; await finishNewSite({ send }, result.projectPath, { @@ -128,7 +167,10 @@ function registerProjectCreateStarterHandlers({ ipcMain, send }: Pick): void { +function registerAstroCopyHandlers( + { ipcMain, send, showOpenDialog }: Pick, + registerCreation: RegisterCreation, +): void { // The Welcome screen's "Open from folder": an Astro project opens, a plain website is offered an // Astro copy (shared/ipc/astroCopy.ts), and anything else is said to be neither. ipcMain.handle('project:openSiteDialog', async (): Promise => { @@ -149,7 +191,7 @@ function registerAstroCopyHandlers({ ipcMain, send, showOpenDialog }: Pick => { + registerCreation('project:createAstroCopy', async (input): Promise => { const request = normalizedRequest(input); ensureToolPath(); // npm and git are both on the PATH the Dock does not have const manager = detectPackageManager(request.sourcePath); @@ -168,7 +210,6 @@ function registerAstroCopyHandlers({ ipcMain, send, showOpenDialog }: Pick): void { + const withProject = async (projectPath: string, operation: (root: string) => ShadcnSettingsReply | Promise) => { + try { + const root = realpathSync(projectPath); + host.assertInProject(path.join(root, 'components.json')); + return await operation(root); + } catch (error: unknown) { + return err({ message: error instanceof Error ? error.message : String(error) }); + } + }; + host.ipcMain.handle('project:readShadcnSettings', (_event, { projectPath }) => withProject(projectPath, readShadcnSettings)); + host.ipcMain.handle('project:changeShadcnSetting', (_event, { projectPath, setting, enabled }) => + withProject(projectPath, (root) => changeShadcnSetting(root, { setting, enabled })), + ); +} diff --git a/electron/main.ts b/electron/main.ts index bb3df6b19..c783ff9a5 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -103,6 +103,7 @@ import { allowLoopbackFraming } from './app/previewFraming'; import { registerPageTemplateHandlers } from './handlers/pageTemplateHandlers'; import { registerPreviewHandlers } from './handlers/previewHandlers'; import { registerProjectHandlers } from './handlers/projectHandlers'; +import { registerShadcnSettingsHandlers } from './handlers/shadcnSettingsHandlers'; import { registerProjectScanHandlers } from './handlers/projectScanHandlers'; import { registerStyleSourceHandlers } from './handlers/styleSourceHandlers'; import { registerAppPageFilesHandlers } from './handlers/appPageFilesHandlers'; @@ -1393,6 +1394,7 @@ registerPageTemplateHandlers( ); registerPreviewHandlers(host); registerProjectHandlers(host); +registerShadcnSettingsHandlers(host); registerProjectMetadataHandlers(host); registerInstructionHandlers(host); registerAgentHandlers(host); diff --git a/electron/preload/frameInteraction.ts b/electron/preload/frameInteraction.ts index d10438abf..db281cd8a 100644 --- a/electron/preload/frameInteraction.ts +++ b/electron/preload/frameInteraction.ts @@ -56,11 +56,10 @@ export function setCanvasInteraction(next: CanvasInteraction): void { // The canvas's cursor. Select mode shows the editor's arrow everywhere. Interact // mode shows the same arrow, never the I-beam over words: it is still the editor, -// and a page's text is selected and edited as in select mode. What acts on a -// click shows the pointer, so it is plain what will navigate or run: links, -// buttons, , labels, form controls, and whatever the page itself gives a -// cursor (`cursor: pointer` on a card). Fields typed into keep their I-beam, -// since interact mode lets them take focus and keystrokes. +// and a page's text is selected and edited as in select mode. Links, summaries, +// labels and form controls get click affordances. Buttons use the site's cursor +// so a project can switch its pointer styling off. Fields typed into keep their +// I-beam because interact mode lets them take focus and keystrokes. // // Interact mode's rules have no specificity (`:where`) and no !important, so a // cursor the page sets on an element wins over them; the arrow on is @@ -74,8 +73,8 @@ export function setCanvasInteraction(next: CanvasInteraction): void { const DESIGN_CURSOR_CSS = ['*, *::before, *::after { cursor: default !important; }', 'iframe, embed, object { pointer-events: none !important; }'].join('\n'); const INTERACT_CURSOR_CSS = [ ':where(html) { cursor: default; }', - ':where(a[href], area[href], button, summary, label, select, [role="button"], [role="link"], [onclick]) { cursor: pointer; }', - ':where(input:is([type="button" i], [type="submit" i], [type="reset" i], [type="checkbox" i], [type="radio" i], [type="file" i], [type="image" i], [type="color" i], [type="range" i])) { cursor: pointer; }', + ':where(a[href], area[href], summary, label, select, [role="link"], [onclick]):where(:not(button, [role="button"])) { cursor: pointer; }', + ':where(input:is([type="button" i], [type="submit" i], [type="reset" i], [type="checkbox" i], [type="radio" i], [type="file" i], [type="image" i], [type="color" i], [type="range" i]):not([role="button"])) { cursor: pointer; }', ':where(textarea, input:not([type="button" i], [type="submit" i], [type="reset" i], [type="checkbox" i], [type="radio" i], [type="file" i], [type="image" i], [type="color" i], [type="range" i], [type="hidden" i]), [contenteditable]:not([contenteditable="false" i])) { cursor: text; }', ].join('\n'); diff --git a/electron/preload/preloadBridge.ts b/electron/preload/preloadBridge.ts index 4b5f15c80..8984086dd 100644 --- a/electron/preload/preloadBridge.ts +++ b/electron/preload/preloadBridge.ts @@ -164,6 +164,9 @@ function projectBridge() { inspectFolder: invoke('project:inspectFolder'), takeOpenedFolders: invoke('project:takeOpenedFolders'), createStarter: invoke('project:createStarter'), + readShadcnSettings: invoke('project:readShadcnSettings'), + changeShadcnSetting: invoke('project:changeShadcnSetting'), + inspectShadcnPreset: invoke('project:inspectShadcnPreset'), scanProject: invoke('project:scan'), listProjectClasses: invoke('project:classes'), watchProject: invoke('watch:start'), diff --git a/electron/project/herouiCatalogActions.ts b/electron/project/herouiCatalogActions.ts new file mode 100644 index 000000000..9140bbb1b --- /dev/null +++ b/electron/project/herouiCatalogActions.ts @@ -0,0 +1,380 @@ +import { HEROUI_SIZES, type HeroUICatalogEntry } from './herouiCatalogTypes'; + +const STATE_IMPORT = 'import { useState } from "react";'; +const PLACEMENTS = ['bottom', 'top', 'left', 'right'] as const; + +export const HEROUI_ACTIONS: readonly HeroUICatalogEntry[] = [ + { + slug: 'button', + name: 'Button', + category: 'Buttons', + imports: ['Button'], + props: { + label: 'Save changes', + variant: ['primary', 'secondary', 'tertiary', 'outline', 'ghost', 'danger', 'danger-soft'], + size: HEROUI_SIZES, + type: ['button', 'submit', 'reset'], + isDisabled: false, + }, + hydrate: true, + markup: '', + }, + { + slug: 'button-group', + name: 'ButtonGroup', + category: 'Buttons', + imports: ['Button', 'ButtonGroup'], + props: { label: 'Text zoom', variant: ['secondary', 'primary', 'tertiary', 'ghost', 'danger'], size: HEROUI_SIZES }, + hydrate: true, + extraImports: STATE_IMPORT, + setup: 'const [zoom, setZoom] = useState(100);', + markup: `
+ + + +

Preview text size.

`, + }, + { + slug: 'close-button', + name: 'CloseButton', + category: 'Buttons', + imports: ['Button', 'CloseButton'], + props: { label: 'Dismiss update', isDisabled: false }, + slots: { message: 'Your changes are saved.' }, + hydrate: true, + extraImports: STATE_IMPORT, + setup: 'const [visible, setVisible] = useState(true);', + markup: `visible ?
+

{message}

setVisible(false)} /> +
: `, + }, + { + slug: 'toggle-button', + name: 'ToggleButton', + category: 'Buttons', + imports: ['ToggleButton'], + props: { label: 'Pin item', defaultSelected: false, size: HEROUI_SIZES }, + hydrate: true, + markup: '{label}', + }, + { + slug: 'toggle-button-group', + name: 'ToggleButtonGroup', + category: 'Buttons', + imports: ['ToggleButton', 'ToggleButtonGroup'], + props: { label: 'Text alignment', initialAlignment: ['left', 'center', 'right'], size: HEROUI_SIZES }, + hydrate: true, + markup: ` + Left + Center + Right + `, + }, + { + slug: 'accordion', + name: 'Accordion', + category: 'Navigation', + imports: ['Accordion'], + props: { heading: 'How do I change my plan?', secondHeading: 'When will the change take effect?', allowsMultipleExpanded: false }, + slots: { answer: 'Choose a plan in your billing settings.', secondAnswer: 'The new plan starts on your next billing date.' }, + hydrate: true, + markup: ` + + {heading} + {answer} + + + {secondHeading} + {secondAnswer} + + `, + }, + { + slug: 'breadcrumbs', + name: 'Breadcrumbs', + category: 'Navigation', + imports: ['Breadcrumbs'], + props: { homeLabel: 'Style Guide', homeHref: '/', parentLabel: 'Example Components', parentHref: '/example-components', currentLabel: 'Navigation' }, + markup: ` + {homeLabel} + {parentLabel} + {currentLabel} + `, + }, + { + slug: 'disclosure', + name: 'Disclosure', + category: 'Navigation', + imports: ['Disclosure'], + props: { heading: 'Shipping details', defaultExpanded: true }, + slots: { details: 'Orders ship within two business days.' }, + hydrate: true, + markup: ` + {heading} + {details} + `, + }, + { + slug: 'disclosure-group', + name: 'DisclosureGroup', + category: 'Navigation', + imports: ['Disclosure', 'DisclosureGroup'], + props: { firstHeading: 'Pickup', secondHeading: 'Delivery', allowsMultipleExpanded: false }, + slots: { pickup: 'Collect your order at the front desk.', delivery: 'Choose a delivery window at checkout.' }, + hydrate: true, + markup: ` + + {firstHeading} + {pickup} + + + {secondHeading} + {delivery} + + `, + }, + { + slug: 'link', + name: 'Link', + category: 'Navigation', + imports: ['Link'], + props: { label: 'Back to Style Guide', href: '/', showIcon: true }, + markup: '{label}{showIcon && }', + }, + { + slug: 'pagination', + name: 'Pagination', + category: 'Navigation', + imports: ['Pagination'], + props: { initialPage: ['first', 'second', 'third'], label: 'Search results' }, + hydrate: true, + extraImports: STATE_IMPORT, + setup: `const pages = ["first", "second", "third"] as const; + const [page, setPage] = useState(pages.indexOf(initialPage));`, + markup: ` + Showing {page * 10 + 1} to {(page + 1) * 10} of 30 results + + setPage((value) => value - 1)}>Previous page + {pages.map((key, index) => setPage(index)}>{index + 1})} + setPage((value) => value + 1)}>Next page + + `, + }, + { + slug: 'tabs', + name: 'Tabs', + category: 'Navigation', + imports: ['Tabs'], + props: { label: 'Project views', initialTab: ['overview', 'activity'], firstTab: 'Overview', secondTab: 'Activity' }, + slots: { overview: 'Two milestones are due this month.', activity: 'Nora updated the release checklist.' }, + hydrate: true, + markup: ` + + {firstTab} + {secondTab} + + {overview} + {activity} + `, + }, + { + slug: 'alert-dialog', + name: 'AlertDialog', + category: 'Overlays', + imports: ['AlertDialog', 'Button'], + props: { trigger: 'Remove invitation', heading: 'Remove this invitation?', confirmLabel: 'Remove', variant: ['opaque', 'blur', 'transparent'] }, + slots: { body: 'The recipient will no longer be able to use this invitation.' }, + hydrate: true, + extraImports: STATE_IMPORT, + setup: 'const [removed, setRemoved] = useState(false);', + markup: `
+ + + + {heading} + {body} + + + + + + + {removed &&

Invitation removed.

} +
`, + }, + { + slug: 'drawer', + name: 'Drawer', + category: 'Overlays', + imports: ['Button', 'Drawer'], + props: { trigger: 'Open filters', heading: 'Product filters', placement: ['right', 'bottom', 'top', 'left'] }, + slots: { body: 'Choose a category on the results page to narrow the list.' }, + hydrate: true, + markup: ` + + + + {heading} + {body} + + + `, + }, + { + slug: 'modal', + name: 'Modal', + category: 'Overlays', + imports: ['Button', 'Modal'], + props: { + trigger: 'Edit project', + heading: 'Project settings', + size: ['md', 'xs', 'sm', 'lg', 'cover', 'full'], + variant: ['blur', 'opaque', 'transparent'], + }, + slots: { body: 'Choose the priority for this project.', footer: 'Done' }, + hydrate: true, + extraImports: 'import { Example as PrioritySelect } from "./Select";', + markup: ` + + + + {heading} +
{body}
+ +
+
`, + }, + { + slug: 'popover', + name: 'Popover', + category: 'Overlays', + imports: ['Button', 'Popover'], + props: { trigger: 'Team access', heading: 'Who can view this?', placement: PLACEMENTS }, + slots: { body: 'Anyone on your team can view this project.' }, + hydrate: true, + markup: ` + + + {heading}

{body}

+
+
`, + }, + { + slug: 'sheet', + name: 'Sheet', + category: 'Overlays', + imports: ['Button', 'Sheet'], + props: { trigger: 'Open delivery options', heading: 'Delivery options', placement: PLACEMENTS, isDetached: false }, + slots: { body: 'Standard delivery takes three to five business days.' }, + hydrate: true, + markup: ` + + + + {heading} + {body} + + + `, + }, + { + slug: 'toast', + name: 'Toast', + category: 'Overlays', + imports: ['Button', 'Toast', 'ToastQueue'], + props: { + label: 'Show notification', + title: 'Report exported', + description: 'Your file is ready to download.', + variant: ['success', 'default', 'accent', 'warning', 'danger'], + }, + hydrate: true, + extraImports: STATE_IMPORT, + setup: 'const [queue] = useState(() => new ToastQueue({ maxVisibleToasts: 1 }));', + markup: `<> + + + `, + }, + { + slug: 'tooltip', + name: 'Tooltip', + category: 'Overlays', + imports: ['Button', 'Tooltip'], + props: { label: 'Keyboard shortcut', placement: ['top', 'bottom', 'left', 'right'] }, + slots: { tip: 'Press Escape to close an open dialog.' }, + hydrate: true, + markup: ` + + {tip} + `, + }, + { + slug: 'dropdown', + name: 'Dropdown', + category: 'Collections', + imports: ['Button', 'Dropdown', 'Label'], + props: { label: 'Sort results', initialSort: ['recent', 'name'], recentLabel: 'Most recent', nameLabel: 'Name' }, + hydrate: true, + extraImports: STATE_IMPORT, + setup: 'const [sort, setSort] = useState(initialSort);', + markup: `
+ + + setSort(String(key))}> + + + + +

Sorted by {sort === "recent" ? recentLabel : nameLabel}

+
`, + }, + { + slug: 'list-box', + name: 'ListBox', + category: 'Collections', + imports: ['Description', 'Label', 'ListBox'], + props: { label: 'Export format', initialFormat: ['pdf', 'csv'], pdfLabel: 'PDF', csvLabel: 'CSV' }, + hydrate: true, + markup: ` + Print-ready document + Spreadsheet data + `, + }, + { + slug: 'tag-group', + name: 'TagGroup', + category: 'Collections', + imports: ['Label', 'Tag', 'TagGroup'], + props: { label: 'Project tags', firstTag: 'Design', secondTag: 'Review', thirdTag: 'Release' }, + hydrate: true, + extraImports: STATE_IMPORT, + setup: `const [tags, setTags] = useState([ + { id: "design", label: firstTag }, + { id: "review", label: secondTag }, + { id: "release", label: thirdTag }, + ]);`, + markup: ` setTags((current) => current.filter((tag) => !keys.has(tag.id)))}> + + "No tags"}> + {tags.map((tag) => {tag.label})} + + `, + }, + { + slug: 'toolbar', + name: 'Toolbar', + category: 'Layout', + imports: ['Separator', 'ToggleButton', 'ToggleButtonGroup', 'Toolbar'], + props: { label: 'Editor settings', firstLabel: 'Bold', secondLabel: 'Italic', thirdLabel: 'Wrap' }, + hydrate: true, + markup: ` + + {firstLabel} + {secondLabel} + + + {thirdLabel} + `, + }, +]; diff --git a/electron/project/herouiCatalogDisplay.ts b/electron/project/herouiCatalogDisplay.ts new file mode 100644 index 000000000..5ee726e69 --- /dev/null +++ b/electron/project/herouiCatalogDisplay.ts @@ -0,0 +1,243 @@ +import { HEROUI_COLORS, HEROUI_SIZES, HEROUI_SURFACES, type HeroUICatalogEntry } from './herouiCatalogTypes'; + +export const HEROUI_DISPLAY: readonly HeroUICatalogEntry[] = [ + { + slug: 'alert', + name: 'Alert', + category: 'Feedback', + imports: ['Alert'], + props: { heading: 'Connection interrupted', status: ['warning', 'default', 'accent', 'success', 'danger'] }, + slots: { details: 'Your draft is saved. Reconnect to publish changes.' }, + markup: ` + + {heading}{details} + `, + }, + { + slug: 'meter', + name: 'Meter', + category: 'Feedback', + imports: ['Label', 'Meter'], + props: { label: 'Storage used', value: 64 }, + markup: ` + + `, + }, + { + slug: 'progress-bar', + name: 'ProgressBar', + category: 'Feedback', + imports: ['Label', 'ProgressBar'], + props: { label: 'Uploading photos', value: 65, color: HEROUI_COLORS, size: HEROUI_SIZES, isIndeterminate: false }, + markup: ` + + `, + }, + { + slug: 'progress-circle', + name: 'ProgressCircle', + category: 'Feedback', + imports: ['ProgressCircle'], + props: { label: 'Profile complete', value: 75, color: HEROUI_COLORS, size: HEROUI_SIZES, isIndeterminate: false }, + markup: `
+ + + + +
`, + }, + { + slug: 'skeleton', + name: 'Skeleton', + category: 'Feedback', + imports: ['Skeleton'], + props: { label: 'Loading account', isLoading: true }, + slots: { body: 'Your account details are available.' }, + markup: `
+ {isLoading ? <>{label}
: body} +
`, + }, + { + slug: 'spinner', + name: 'Spinner', + category: 'Feedback', + imports: ['Spinner'], + props: { label: 'Checking connection', size: ['md', 'sm', 'lg', 'xl'], color: ['accent', 'current', 'success', 'warning', 'danger'] }, + markup: '
', + }, + { + slug: 'card', + name: 'Card', + category: 'Layout', + imports: ['Card'], + props: { heading: 'Release checklist', description: 'Three tasks remain', variant: HEROUI_SURFACES }, + slots: { body: 'Review copy, test the build, and prepare the release notes.', footer: 'Due Friday' }, + markup: ` + {heading}{description} + {body} + {footer} + `, + }, + { + slug: 'separator', + name: 'Separator', + category: 'Layout', + imports: ['Separator'], + props: { orientation: ['horizontal', 'vertical'] }, + slots: { before: 'Order total', after: 'Shipping calculated at checkout' }, + markup: `
+

{before}

+ +

{after}

+
`, + }, + { + slug: 'surface', + name: 'Surface', + category: 'Layout', + imports: ['Surface', 'Typography'], + props: { heading: 'Billing address', variant: ['secondary', 'default', 'tertiary', 'transparent'] }, + slots: { body: 'The address on your next invoice.' }, + markup: ` + {heading} + {body} + `, + }, + { + slug: 'avatar', + name: 'Avatar', + category: 'Media', + imports: ['Avatar'], + props: { name: 'Jules Davis', initials: 'JD', image: '', size: HEROUI_SIZES, color: HEROUI_COLORS, variant: ['soft', 'default'] }, + hydrate: true, + markup: `
+ + {name} +
`, + }, + { + slug: 'avatar-group', + name: 'AvatarGroup', + category: 'Media', + imports: ['Avatar', 'AvatarGroup'], + props: { label: 'Design team', firstInitials: 'NK', secondInitials: 'JL', thirdInitials: 'AM', size: HEROUI_SIZES }, + markup: ` + {firstInitials} + {secondInitials} + {thirdInitials} + `, + }, + { + slug: 'badge', + name: 'Badge', + category: 'Data display', + imports: ['Avatar', 'Badge'], + props: { + initials: 'JD', + label: 'Unread messages', + count: 3, + color: ['danger', 'default', 'accent', 'success', 'warning'], + placement: ['top-right', 'top-left', 'bottom-right', 'bottom-left'], + }, + markup: ` + {initials} + {count} + `, + }, + { + slug: 'chip', + name: 'Chip', + category: 'Data display', + imports: ['Chip'], + props: { + label: 'Published', + color: ['success', 'default', 'accent', 'warning', 'danger'], + variant: ['soft', 'primary', 'secondary', 'tertiary'], + size: HEROUI_SIZES, + }, + markup: '{label}', + }, + { + slug: 'table', + name: 'Table', + category: 'Data display', + imports: ['Table'], + props: { label: 'Release schedule', variant: ['primary', 'secondary'], firstRelease: 'Website', secondRelease: 'Design kit' }, + slots: { footer: 'All dates are shown in UTC.' }, + hydrate: true, + markup: ` + + + ReleaseDate + + {firstRelease}May 12 + {secondRelease}May 19 + + + + {footer} +
`, + }, + { + slug: 'kbd', + name: 'Kbd', + category: 'Typography', + imports: ['Kbd'], + props: { modifier: ['ctrl', 'command', 'shift', 'alt'], shortcut: 'K', label: 'Open search' }, + markup: + '
{shortcut}{label}
', + }, + { + slug: 'typography', + name: 'Typography', + category: 'Typography', + imports: ['Typography'], + props: { type: ['h4', 'h3', 'h2', 'h1', 'h5', 'h6', 'body', 'body-sm', 'body-xs', 'code'], color: ['default', 'muted'] }, + slots: { content: 'Design system updates' }, + markup: '{content}', + }, + { + slug: 'scroll-shadow', + name: 'ScrollShadow', + category: 'Utilities', + imports: ['ScrollShadow'], + props: { label: 'Release notes', size: 24 }, + slots: { introduction: 'Scroll to read the full release notes.' }, + hydrate: true, + markup: ` +
+

{introduction}

+

Project members can now edit their notification preferences.

+

Archived projects appear in search results when you enable the archive filter.

+

CSV exports now use your workspace time zone.

+
+
`, + }, + { + slug: 'slider', + name: 'Slider', + category: 'Controls', + imports: ['Label', 'Slider'], + props: { label: 'Volume', defaultValue: 40 }, + hydrate: true, + markup: ` + + + `, + }, + { + slug: 'switch', + name: 'Switch', + category: 'Controls', + imports: ['Description', 'Label', 'Switch'], + props: { label: 'Email reminders', defaultSelected: true, size: HEROUI_SIZES }, + slots: { hint: 'Get a reminder before each deadline.' }, + hydrate: true, + markup: ` + + {hint} + `, + }, +]; diff --git a/electron/project/herouiCatalogFields.ts b/electron/project/herouiCatalogFields.ts new file mode 100644 index 000000000..b552959e1 --- /dev/null +++ b/electron/project/herouiCatalogFields.ts @@ -0,0 +1,227 @@ +import type { HeroUICatalogEntry } from './herouiCatalogTypes'; + +const ID_IMPORT = 'import { useId } from "react";'; +const STATE_IMPORT = 'import { useState } from "react";'; +const FIELD_VARIANTS = ['primary', 'secondary'] as const; + +export const HEROUI_FIELDS: readonly HeroUICatalogEntry[] = [ + { + slug: 'checkbox', + name: 'Checkbox', + category: 'Forms', + imports: ['Checkbox', 'Description'], + props: { label: 'Keep me signed in', defaultSelected: false, variant: FIELD_VARIANTS }, + slots: { hint: 'Only use this on a device you trust.' }, + hydrate: true, + markup: ` + {label} + {hint} + `, + }, + { + slug: 'checkbox-group', + name: 'CheckboxGroup', + category: 'Forms', + imports: ['Checkbox', 'CheckboxGroup', 'Description', 'Label'], + props: { label: 'Notifications', firstOption: 'Product updates', secondOption: 'Weekly summary', initialSelection: ['updates', 'summary'] }, + slots: { hint: 'Choose the emails you want to receive.' }, + hydrate: true, + markup: ` + {hint} + {firstOption} + {secondOption} + `, + }, + { + slug: 'description', + name: 'Description', + category: 'Forms', + imports: ['Description', 'Input', 'Label', 'TextField'], + props: { label: 'Display name', defaultValue: 'Jules' }, + slots: { hint: 'This name appears beside your comments.' }, + hydrate: true, + markup: ` + {hint} + `, + }, + { + slug: 'error-message', + name: 'ErrorMessage', + category: 'Forms', + imports: ['ErrorMessage', 'Label', 'Tag', 'TagGroup'], + props: { label: 'Topics', firstTopic: 'Design', secondTopic: 'Engineering', initialTopic: ['none', 'design', 'engineering'] }, + slots: { message: 'Choose at least one topic.' }, + hydrate: true, + extraImports: STATE_IMPORT, + setup: 'const [hasSelection, setHasSelection] = useState(initialTopic !== "none");', + markup: ` setHasSelection(keys === "all" || keys.size > 0)}> + + + {firstTopic} + {secondTopic} + + {!hasSelection && message} + `, + }, + { + slug: 'field-error', + name: 'FieldError', + category: 'Forms', + imports: ['FieldError', 'Input', 'Label', 'TextField'], + props: { label: 'Username', defaultValue: 'jr', minimumLength: 3 }, + slots: { message: 'Enter at least three characters.' }, + hydrate: true, + extraImports: STATE_IMPORT, + setup: `const [value, setValue] = useState(defaultValue); + const invalid = value.length < minimumLength;`, + markup: ` + {message} + `, + }, + { + slug: 'fieldset', + name: 'Fieldset', + category: 'Forms', + imports: ['Fieldset', 'Input', 'Label', 'TextField'], + props: { legend: 'Shipping address', city: 'Lisbon', postalCode: '1100' }, + hydrate: true, + markup: `
+ {legend} + + + + +
`, + }, + { + slug: 'form', + name: 'Form', + category: 'Forms', + imports: ['Button', 'FieldError', 'Form', 'Input', 'Label', 'TextField'], + props: { label: 'Email address', submitLabel: 'Subscribe', defaultValue: '' }, + slots: { confirmation: 'You’re on the list.' }, + hydrate: true, + extraImports: STATE_IMPORT, + setup: 'const [submitted, setSubmitted] = useState(false);', + markup: `
{ event.preventDefault(); setSubmitted(true); }} onReset={() => setSubmitted(false)}> + setSubmitted(false)}> + + +
+ {submitted &&

{confirmation}

} +
`, + }, + { + slug: 'input', + name: 'Input', + category: 'Forms', + imports: ['Input'], + props: { + label: 'Workspace name', + placeholder: 'Enter a workspace name', + defaultValue: 'Design team', + type: ['text', 'email', 'password', 'url'], + variant: FIELD_VARIANTS, + }, + hydrate: true, + markup: '', + }, + { + slug: 'input-group', + name: 'InputGroup', + category: 'Forms', + imports: ['InputGroup', 'Label', 'TextField'], + props: { label: 'Workspace address', defaultValue: 'design', variant: FIELD_VARIANTS }, + slots: { suffix: '.example.com' }, + hydrate: true, + markup: ` + + {suffix} + `, + }, + { + slug: 'input-otp', + name: 'InputOTP', + category: 'Forms', + imports: ['InputOTP', 'REGEXP_ONLY_DIGITS'], + props: { label: 'Verification code', defaultValue: '', variant: FIELD_VARIANTS }, + hydrate: true, + markup: ` + + + + `, + }, + { + slug: 'label', + name: 'Label', + category: 'Forms', + imports: ['Input', 'Label'], + props: { label: 'Account name', defaultValue: 'River Studio' }, + hydrate: true, + extraImports: ID_IMPORT, + setup: 'const id = useId();', + markup: `
+ +
`, + }, + { + slug: 'number-field', + name: 'NumberField', + category: 'Forms', + imports: ['Label', 'NumberField'], + props: { label: 'Seats', defaultValue: 2, variant: FIELD_VARIANTS }, + hydrate: true, + markup: ` + + + `, + }, + { + slug: 'radio-group', + name: 'RadioGroup', + category: 'Forms', + imports: ['Description', 'Label', 'Radio', 'RadioGroup'], + props: { label: 'Delivery speed', initialSpeed: ['standard', 'express'], firstOption: 'Standard', secondOption: 'Express' }, + slots: { hint: 'Choose when you need the package.' }, + hydrate: true, + markup: ` + {hint} + {firstOption} + {secondOption} + `, + }, + { + slug: 'search-field', + name: 'SearchField', + category: 'Forms', + imports: ['Label', 'SearchField'], + props: { label: 'Find a project', defaultValue: '', placeholder: 'Search projects', variant: FIELD_VARIANTS }, + hydrate: true, + markup: ` + + `, + }, + { + slug: 'text-area', + name: 'TextArea', + category: 'Forms', + imports: ['TextArea'], + props: { label: 'Release summary', defaultValue: 'Updated billing and account settings.', rows: 3, variant: FIELD_VARIANTS }, + hydrate: true, + markup: '