Skip to content

playground: show the examples as chips grouped by what SQLQuack does - #149

Merged
kvlonge merged 2 commits into
mainfrom
website/example-chips
Nov 7, 2026
Merged

kvlonge merged 2 commits into
mainfrom
website/example-chips

Conversation

@kvlonge

@kvlonge kvlonge commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Website-only change: the playground page, its styles and its test. Nothing under website/wasm/, and no engine or converter changes.

The "Examples…" dropdown is replaced by always-visible example chips above the editor, in three groups that echo the tagline:

Runs it · verified results Catches the mistake · a clear no Says no, clearly · a clear no
Converts and runs: all four pass Syntax error: stops at Parse Translation refused: stops at Translate
Decimal division: all four pass Snowflake rejects it: stops at Check
Unknown column: stops at Check
  • One click loads the example and runs all four stages, as the dropdown did. The chip is marked aria-pressed and highlighted.
  • Stop stage: each chip names where its example stops. The label comes from stops in examples.js, and tests/playground.test.mjs derives every example's actual stop stage: the first of parse, checks and translate that does not pass, or, for examples that translate, a run of the translated SQL against the page's fixture tables and rows in the same DuckDB-WASM build the page serves (duckdb-node-blocking, DuckDB v2.0.0). The test fails if a label drifts. I checked this by mislabelling two chips: the test failed on each.
  • Deep links: ?example=<slug> (converts-and-runs, decimal-division, syntax-error, snowflake-rejects-it, unknown-column, translation-refused) loads and runs that example. A chip click writes the slug with history.replaceState. The earlier keys (?example=refused, etc.) still work, an unknown slug opens the default example quietly, and ?sql= is unchanged. Editing the SQL clears the chip and removes the slug, so a link never names an example the editor no longer holds.
  • Layout and access: the chips are buttons, so Tab and Enter work, with a visible focus outline. They wrap, and the groups stack below 620 px. Colours use the theme variables, so light and dark both work.
  • The six examples and their SQL are unchanged.

Checked locally: npm run -s test:engine (12 pass), npm run build, check_links.py (0 broken). In the browser I clicked through all six chips (URL, pressed chip and stages each matched the label), loaded the new slug, an unknown slug, an old key and ?sql= cold, edited the SQL to clear the chip, and pressed Tab then Enter on a chip. Screenshots were taken at 1280 px and 390 px in light and dark.

The six examples were hidden in a dropdown. They are now buttons above
the editor, in three groups that echo the tagline: "Runs it" (verified
results), "Catches the mistake" and "Says no, clearly" (a clear no).
Each chip names the stage where its example stops; the test derives
each example's actual stop stage from the engine and, for the ones
that translate, a DuckDB-WASM run, and fails when a label drifts.

A click loads and runs the example, marks the chip pressed and puts
?example=<slug> in the address with history.replaceState, so each
example can be shared. A link with a slug, or an earlier example key,
opens that example; an unknown one opens the default. Editing the SQL
clears the chip and the slug.
@kvlonge
kvlonge merged commit 8f8070b into main Nov 7, 2026
2 checks passed
@kvlonge
kvlonge deleted the website/example-chips branch November 9, 2026 21:32

This branch was previously deployed

1 inactive deployment
github-pages — 8f8070b6 Deployed Nov 7, 2026 by kvlonge via Deploy to GitHub Pages #177
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.

1 participant