Repository navigation
Feat/playground layout - #301
Merged
WebEferen merged 7 commits intoJul 27, 2026
Merged
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
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.
… 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.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
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.
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.
5 tasks done
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
.tsrxbehind each demo.@octanejs/shadcnships — coverage was 39 of 44.Why
The playground was a flat row of buttons over a single
@switchstage, with the active demo held inuseState:.tsrxplayground that is the main thing worth showing, and it was the one thing you could not see.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 writeslocation.hashand thehashchangelistener 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, notgroup/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
SidebarProvidernested 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-playgroundisprivate.Validation
pnpm format:check— cleanpnpm typecheck— exit 0pnpm 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 fixturenode_modules).pnpm --filter octane-playground buildplus a headless-Chromium smoke pass against the production build:#/keyed-list,#/suspense#/dynamic, stage swapsexpanded → collapsed(the vendored component's own behaviour).tsrx(export function DynamicDemo() @{)"susp"Risk / follow-ups
Shadcn.tsrxis 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.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
useStatedemo picker with a shadcn Sidebar layout, hash-based routes (#/demo-id), and a centralcatalogthat feeds nav, routing, and a new Result / Source stage (source loaded via Vite?raw).DemoNavadds grouped, searchable navigation and closes the mobile sheet on selection; invalid hashes are replaced in the URL to match the resolved fallback demo.Shadcn.tsrxgains 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.tstypes*?rawimports.Reviewed by Cursor Bugbot for commit f667f41. Bugbot is set up for automated code reviews on this repo. Configure here.