Skip to content

feat(web): code-block styling and copy button on install commands - #7

Merged
codewizdave merged 1 commit into
mainfrom
feat/install-command-with-copy
Jul 29, 2026
Merged

feat(web): code-block styling and copy button on install commands#7
codewizdave merged 1 commit into
mainfrom
feat/install-command-with-copy

Conversation

@martyy-code

Copy link
Copy Markdown
Contributor

Summary

Install commands on every component detail page now render in a code-block-styled container (rounded, bordered, header strip with file-type label and a working Copy button), matching the visual rhythm of the existing Code tab.

Before:

npx shadcn@latest add deessejs/ui/ds-button

(Raw <pre> inside the section flow, no border, no copy affordance.)

After:

┌─ bash ──────────────────────────────────── [ Copy ] ─┐
│ npx shadcn@latest add deessejs/ui/ds-button          │
└──────────────────────────────────────────────────────┘

Click Copy → 1.5s feedback "Copied", then back to "Copy". Plain-text fallback works even if navigator.clipboard is unavailable.

What's in this PR

New component

apps/web/components/command-block/{command-block,index}.tsx — a small client component that renders one bash command with a header strip and a copy button.

Implementation notes:

  • Plain <pre><code>, not Shiki. The previous InstallCommand used <CodeBlock lang="bash" />. Shiki only highlights languages it has loaded at createHighlighter({ langs }), and apps/web/lib/shiki.ts does not currently preload bash. Going through CodeBlock would have thrown ShikiError: Language "bash" not found on every detail page render — a regression I had to ship as PR fix(build): add @workspace/registry to transpilePackages #6 commit 2. Routing around Shiki avoids the runtime trap and keeps the visual idiom intact.
  • copyLabel(state) callback prop lets future i18n or test harness inject custom labels. Default: "Copy" / "Copied" in English.
  • Silent catch on navigator.clipboard.writeText. The API rejects in non-secure contexts (http on a non-localhost origin). Selection-and-copy by the user still works in that fallback path.

Edit

apps/web/components/install-command/install-command.tsx — the four <CodeBlock ... lang="bash" /> calls become <CommandBlock ... />. JSX structure otherwise unchanged.

CI expectations

The change is showcase-only (apps/web/). No impact on:

  • registry.json, registry/base-nova/** — drift job unchanged
  • Build pipeline (registry tsc + apps/web prebuild) — CommandBlock is consumed directly, no Shiki dependency added or removed
  • Existing Code tab in apps/web/app/components/[category_id]/[component_id]/page.tsx — still uses <CodeBlock> for lang="tsx". Different visual idiom by design.

The 6 CI jobs should stay green. Typecheck should validate the new client component.

🤖 Generated with Claude Code

Each bash install command (visible + inside <details>) is now
rendered through a new <CommandBlock> client component that:

- Wraps the command in a rounded, bordered container with a muted
  bg-muted/30 header strip and a real (functional) copy button.
  The header label defaults to "bash" but is overridable.
- Renders the command as a plain <pre><code> without going
  through Shiki. Shiki would have required the bash grammar to
  be preloaded in apps/web/lib/shiki.ts, which the project does
  not currently do — going through Shiki would have thrown
  ShikiError on every detail page render. Plain <pre> avoids
  that surface entirely and keeps the visual idiom intact.
- copy state is local: navigator.clipboard.writeText with a
  silent catch (clipboard API can fail in non-secure contexts,
  e.g. http on a non-localhost origin; the user can still
  select-and-copy manually).
- copyLabel prop lets future i18n or test code inject custom
  "Copy"/"Copied" strings; default is English.

InstallCommand swaps its 4 <CodeBlock ... lang="bash" /> calls
for <CommandBlock ... />. Otherwise the JSX structure is
unchanged.

Verification:
- typecheck exits 0
- visual shape matches the existing Code tab in the detail page
  (same border + rounded + label + copy header), reinforcing the
  visual idiom without depending on Shiki for shell languages.

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ui-web Ready Ready Preview, Comment Jul 29, 2026 12:10pm

@codewizdave
codewizdave merged commit bc33eec into main Jul 29, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants