Skip to content

Feat/playground layout - #301

Merged
WebEferen merged 7 commits into
octanejs:mainfrom
mrdiyorbek-juraev:feat/playground-layout
Jul 27, 2026
Merged

WebEferen merged 7 commits into
octanejs:mainfrom
mrdiyorbek-juraev:feat/playground-layout

Conversation

@mrdiyorbek-juraev

@mrdiyorbek-juraev mrdiyorbek-juraev commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Rebuilds the playground shell as a persistent sidebar beside a stage, with the URL deciding which demo is on screen so any example can be linked to, reloaded into and shared.
  • Adds a Source view that shows the .tsrx behind each demo.
  • Demos every component @octanejs/shadcn ships — coverage was 39 of 44.

Why

The playground was a flat row of buttons over a single @switch stage, with the active demo held in useState:

  • The button row does not scale. Seven entries is already near the limit; every new binding or language demo makes it worse.
  • Nothing was linkable. No route meant you could not share "look at this Suspense case", reload into it, or use browser back.
  • The source was invisible. For a .tsrx playground that is the main thing worth showing, and it was the one thing you could not see.
  • Four component families were dead weight — context menu, hover card, menubar and navigation menu were vendored into the app and never rendered by it.

Changes

Shell

  • src/catalog.ts — the single place a demo is declared. The nav, the router and the source view all read from it, so adding a demo touches one file. Sources come from Vite's ?raw, so the Source tab shows the file on disk rather than a copy that can rot.
  • src/lib/hash-route.ts — the URL is the single source of truth: navigation writes location.hash and the hashchange listener writes state back, so there is no second copy to keep in sync and back/forward work for free. A hash rather than a path because this is a static Vite app, where a path route would need a server rewrite to survive a reload. Routes are a bare demo id, not group/id, so regrouping the catalog never breaks a shared link.
  • src/components/DemoNav.tsrx — built on the vendored shadcn Sidebar, so the playground dogfoods what it ships: the rail, the mobile Sheet, Cmd/Ctrl+B and the collapse cookie all come from the component instead of hand-written CSS. Adding the Sidebar deleted most of the custom nav styling.
  • src/components/DemoStage.tsrx — adds only a Result/Source control. Each demo already renders its own heading and blurb, so a title here would show it twice.
  • playground.css — the removed layout rules were replaced by what the Sidebar does not own.

Coverage

  • Cards for context menu, hover card, menubar and navigation menu, each driving the real interaction (right-click, click, click, hover) rather than rendering a static shell.
  • Sidebar stays uncarded on purpose: the playground's own navigation is that component, so a second SidebarProvider nested in the gallery would compete with the shell for the same Cmd/Ctrl+B binding and collapse cookie. A card explains that instead of faking a second instance.

No changeset: octane-playground is private.

Validation

  • pnpm format:check — clean
  • pnpm typecheck — exit 0
  • pnpm test — not run. The playground has no tests and belongs to no vitest project, so the suite covers none of this diff; the root invocation is also unusable in this checkout (it recurses into fixture node_modules).
  • targeted: pnpm --filter octane-playground build plus a headless-Chromium smoke pass against the production build:
Check Result
Deep link #/keyed-list, #/suspense resolves to the right demo, nav row marked active
Nav click URL updates to #/dynamic, stage swaps
Cmd/Ctrl+B sidebar expanded → collapsed (the vendored component's own behaviour)
Source tab shows real .tsrx (export function DynamicDemo() @{)
Search "susp" filters the nav 7 → 1
Context menu / menubar / navigation menu / hover card all open on their real interaction
Console + page errors none

Risk / follow-ups

  • The playground has no typecheck script and is in no vitest project, so its only gate is the production build. Worth wiring up, but it may surface pre-existing errors in the gallery, so it is deliberately not in this diff.
  • Shadcn.tsrx is now ~700 lines and 20 cards. Splitting it into per-component routes is the change that would really deliver "play with any example"; it belongs in its own PR.
  • The mobile breakpoint relies on the Sidebar's own Sheet behaviour rather than custom CSS. Verified it stops rendering as a rail at 480px wide, but the Sheet interaction itself is not covered by an automated check.
Screenshot 2026-07-27 at 19 16 21

Note

Low Risk
Changes are confined to the private octane playground; demo route ids shift (e.g. list → keyed-list), which only affects shared hash links.

Overview
Replaces the flat button row and in-memory useState demo picker with a shadcn Sidebar layout, hash-based routes (#/demo-id), and a central catalog that feeds nav, routing, and a new Result / Source stage (source loaded via Vite ?raw).

DemoNav adds grouped, searchable navigation and closes the mobile sheet on selection; invalid hashes are replaced in the URL to match the resolved fallback demo. Shadcn.tsrx gains interactive cards for context menu, hover card, menubar, and navigation menu (with hash links to other demos); sidebar is documented in-shell rather than nested. Playground CSS drops custom nav styling in favor of sidebar-owned chrome plus stage/tab/source styles; tsrx.d.ts types *?raw imports.

Reviewed by Cursor Bugbot for commit f667f41. Bugbot is set up for automated code reviews on this repo. Configure here.

The playground was a flat row of buttons over a single stage, with the active
demo held in `useState`. That does not scale past a handful of entries, nothing
was linkable, and the one thing a .tsrx playground most needs to show — the
source that produces a demo — was not visible at all.

- `catalog.ts` is now the single place a demo is declared. The nav, the router
  and the source view all read from it, so adding a demo touches one file.
  Sources come from Vite's `?raw`, so the Source tab shows the file on disk
  rather than a copy that can rot.
- `lib/hash-route.ts` makes the URL the single source of truth: navigation
  writes `location.hash` and the `hashchange` listener writes state back, so
  there is no second copy to keep in sync and back/forward work for free. A
  hash rather than a path because this is a static Vite app, where a path route
  would need a server rewrite to survive a reload. Routes are a bare demo id,
  not `group/id`, so regrouping the catalog never breaks a shared link.
- The nav is the vendored shadcn Sidebar, so the playground dogfoods what it
  ships: the rail, the mobile Sheet, Cmd/Ctrl+B and the collapse cookie all
  come from the component rather than from hand-written CSS.
- The stage adds only a Result/Source control. Each demo already renders its
  own heading and blurb, so a title here would show it twice.

Verified in headless Chromium against the production build: deep links resolve,
clicking the nav updates the URL, Cmd+B collapses the rail, the Source tab
shows real `.tsrx`, search filters the nav, and the console is clean.
The gallery covered 39 of the 44 components in @octanejs/shadcn. Context menu,
hover card, menubar and navigation menu had no card at all, so four families
were vendored into the app and never exercised by it.

Each now gets a card that drives its real interaction — right-click, click,
hover — rather than rendering a static shell.

Sidebar is the exception and stays uncarded on purpose: the playground's own
navigation IS that component, so a second SidebarProvider nested in the gallery
would compete with the shell for the same Cmd/Ctrl+B binding and collapse
cookie. A card explains that instead of faking a second one.

Verified in headless Chromium against the production build: the context menu
opens on right-click, the menubar and navigation menu on click, the hover card
on hover, and the console stays clean.
@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp July 27, 2026 01:20 Inactive
@vercel

vercel Bot commented Jul 27, 2026 •

Copy link
Copy Markdown

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

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
octane-website Skipped Skipped Jul 27, 2026 4:28pm
octane-website-mcp Skipped Skipped Jul 27, 2026 4:28pm

Request Review

@vercel
vercel Bot temporarily deployed to Preview – octane-website July 27, 2026 01:20 Inactive
MERGE — one conflict, in playground/octane/src/App.tsrx. Upstream's cmdk PR
(octanejs#210) added a Command menu demo to the flat nav this branch replaces. Resolved
to the sidebar shell, but taking it wholesale would have DROPPED the new demo:
the shell reads from catalog.ts, not from the switch statement upstream edited.
Registered it there instead, so the entry survives and gains a source view.

AUDIT — the review flagged the first of these; the rest came from looking for
its siblings.

1. Selecting a demo left the mobile sidebar open. Below the breakpoint the nav
   is a Sheet laid OVER the stage, so a selection that only changed the route
   left the sheet covering the demo it had just selected. It now closes the
   sheet on select, on mobile only.

2. `[data-slot='sidebar-menu-button']` was styled globally, reaching into a
   vendored component's internals from app CSS. No live bug — this app has one
   sidebar — but it would silently restyle any future one. Scoped to
   `.demo-sidebar`.

3. `collapsible="icon"` promises an icon rail, and these entries are text-only,
   so there was no icon to collapse to. It behaved as offcanvas regardless;
   now it says so.

4. An unresolvable route rendered the fallback demo while the URL kept the bad
   id, so sharing the link again propagated a route that does not exist. The
   URL is now rewritten to match what rendered.

Verified against the production build in headless Chromium: the mobile sheet
closes on select, deep links resolve, nav clicks update the URL, Cmd+B
collapses, search filters, the merged cmdk demo renders with its source, and
the console is clean.
Keeps each nav row to a single title line. The summary text stays in the
catalog and still feeds the search filter — it is only no longer rendered.
@vercel
vercel Bot temporarily deployed to Preview – octane-website July 27, 2026 14:21 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp July 27, 2026 14:21 Inactive
Comment thread playground/octane/src/App.tsrx Resolved
… route

The fallback rewrite reused the same navigation as a user click, which assigns
`location.hash` and therefore PUSHES a history entry. On a bare `/` load or a
bad hash that trapped the user: Back returned to the empty or invalid hash, the
correction fired again, and they could never leave the page. Reproduced with
three consecutive Back presses that never escaped `#/counter`.

`useHashRoute` now takes `{ replace: true }`, which swaps the current entry
instead of adding one. Correcting a route is not the same operation as
navigating to one, and only the latter belongs in history.

The `setRoute` inside that branch is load-bearing: `replaceState` emits no
`hashchange`, so without it the state would keep the unresolvable route, the
caller's `route !== demo.id` test would never clear, and it would rewrite the
URL on every render — trading the history trap for an infinite loop. Real
navigations still write the URL and let the listener update state, so the URL
stays the single source of truth where it matters.

Verified against the production build in headless Chromium: a bare load and a
bad hash both normalise and then leave the app on one Back, while a nav click
still pushes so Back walks from #/suspense to #/counter with the stage
following.
@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp July 27, 2026 14:51 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website July 27, 2026 14:51 Inactive

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.

Reviewed by Cursor Bugbot for commit 904f321. Configure here.

@mrdiyorbek-juraev

Copy link
Copy Markdown
Contributor Author

@WebEferen @leonidaz I cleaned up the Octane playground layout a bit so the components are better organized and it's easier to manually test everything as we keep adding more.

Demo summaries were searchable but invisible. The span that displayed them was
removed, so a query could match on words appearing nowhere on the row — an
entry would survive a filter for no reason the user could see.

The dead weight went with it: `.demo-nav-summary` and its active-state rule
matched nothing, and both were scoped under `.demo-sidebar`, a class that is
not on the Sidebar at all — so those rules never applied even while the span
existed. The stacked-menu-button override is gone too; a single title line does
not need it.

`summary` is dropped from the catalog rather than kept as unrendered metadata:
nothing displayed it, and the entry that documented it as "shown in the nav" was
no longer true.

Verified against the production build in headless Chromium: 8 entries render as
single title lines, a term that only ever appeared in a summary now matches
nothing, title search still works, and the console is clean.
@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp July 27, 2026 15:09 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website July 27, 2026 15:09 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp July 27, 2026 16:28 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website July 27, 2026 16:28 Inactive
@WebEferen
WebEferen merged commit e3d8e83 into octanejs:main Jul 27, 2026
28 checks passed
@trueadm trueadm mentioned this pull request Sep 28, 2026
5 tasks done

This branch was previously deployed

2 inactive deployments
Preview – octane-website-mcp — f667f41b Deployed Jul 27, 2026 by vercel[bot]
Preview – octane-website — f667f41b Deployed Jul 27, 2026 by vercel[bot]
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