Repository navigation
Add eight general-purpose learning blocks (architecture, charts, role-play and more) - #358
Merged
Merged
Conversation
New ```canvas renderers any course can use: architecture, chart, guess-reveal, scale-picker, log-explorer, command-explainer, role-play and self-check-cards. Each has a zod schema, cross-checks, pure model functions, a theme-aware component in BeatFrame, a spec and tests. - architecture: a system diagram written as data (parts, arrows, nested groups) with the design lab's icons; tap for details, drag to move, Copy code writes x and y back; left to right, or top to bottom when the panel is narrow. - chart: pie, bar or line, view only or guess then reveal. - Registered in PORTABLE_CANVAS_RENDERERS, InteractiveCanvas (schema and checks before render) and the publish check's renderer list. - docs/interactive-learning-blocks.md and the /zz-learning-blocks dev page; a test keeps every example valid. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What this adds
Eight new portable canvas renderers that any course can use, not only tech courses. Authors write each one as a
```canvasfence with plain YAML or JSON. The chapter is stored in the database as text, so every block is stored as code, never as a picture.architecturechartguess-revealscale-pickerlog-explorercommand-explainerrole-playself-check-cardsThe step-by-step diagram we also discussed is not added: a
```flowfence with apacket:line already steps through with Back and Next.The architecture canvas, in more detail
nodes,edgesandgroups. Groups can sit inside groups, for example a VPC that contains subnets. A typical diagram is 1 to 2 KB of text, and it can be searched and edited.Glyphset, so diagrams and labs look the same. There are 17 part types plusexternal.xandyfilled in, ready to paste into the chapter.How it fits the existing code
flip-deckpattern:models/<name>.tsholds the zod schema with.passthrough(), acheck<Name>()function with plain-English problems, and pure state functions.primitives/<name>.tsxholds the component, insideBeatFrame.primitives/<name>.spec.mdholds the spec.frontend/tests/unit/canvas/<name>.test.tsholds the tests.PORTABLE_CANVAS_RENDERERSinmodels/portable.ts, which also re-exports each schema.InteractiveCanvasswitch. Each new case runs the schema, then the cross-checks, before it renders.PORTABLE_CANVAS_RENDERER_NAMESinserver/src/shared/mdx/canvas-tags.ts, synced tofrontend/src/shared, so publishing accepts the new names.packages/learning-ui/package.jsongets export entries for the 16 new files.<animate>(the traffic dots reuseFlowPulse), 44px targets, polite live regions,prefers-reduced-motion, and amber (never red) for a wrong answer.Docs and preview
docs/interactive-learning-blocks.md: an author guide with a copyable example for each renderer./zz-learning-blocks: a dev page with no login, like/zz-diagram-gallery. Every example goes through the real chapter pipeline.learning-blocks-docs.test.ts: parses every example in the guide and on the dev page with the real schema and checks, so the docs cannot drift from the code.Testing
pnpm vitest runpasses 202 files, 5,124 tests (3 skipped).tsc --noEmitreports 0 errors. ESLint is clean on the new frontend files.canvas-tagscases.tsc --noEmitreports 0 errors afterprisma generate.sync-shared:checkreports the copy is in sync./zz-learning-blocks):Not tested, or open
courses:check) validates the renderer name,titleandlimits, but not the full data schema. The schemas live inpackages/learning-ui, which the server does not import. Bad data is caught in the reader and shows the quiet fallback. Moving the schemas intoserver/src/sharedwould let publishing refuse bad data too. That could be a follow-up.remark-learning-log.test.tsfails locally with "Invalid environment configuration", because it needs a server.env. It is not related to this change.🤖 Generated with Claude Code