Repository navigation
docs(useSyntaxTheme): add hook docs and a keyword color example block - #11236
Conversation
Hook docs for `useSyntaxTheme`, so `astryx hook useSyntaxTheme` and `astryx search` return it, and a `useSyntaxTheme — Keyword color` example block: the word const painted with the keyword color of the GitHub Light syntax theme.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
Changes are still needed: the new useSyntaxTheme page and example are picked up by astryx hook, astryx search and astryx template, but three small fixes remain.
- The example draws nothing under right-to-left, because
<text x="0">inheritsdirection: rtlandconstrenders left of its 120 px SVG, where it is clipped; adddirection="ltr"to the<text>inuseSyntaxThemeHookUsage.tsx. - The hook doc's
moderow (useSyntaxTheme.doc.mjsline 27, and the dense text at line 73) presents followingprefers-color-schemeas the hook's contract, whilecomponent:SyntaxThemeFR2 says the hook follows the nearest Theme's mode and lists the operating-system read as a known gap, so please say that under a forced<Theme mode>the colors can differ from the code around them. - Line 5 of
useSyntaxThemeHookUsage.tsxis longer than Prettier's 80 columns, so the Lint workflow's changed-file formatting check will fail; runpnpm exec prettier --writeon the file.
One smaller point: data-syntax-keyword only serves the test, but astryx template useSyntaxThemeHookUsage copies it into every app, so the test can select svg[role="img"] text instead.
|
/approve-spec c859461 |
…ract Right-to-left layout clipped the sample word. The doc now says a forced Theme mode can disagree with nearby code, because the hook still reads the operating-system color scheme.
PR Analysis Report🔎 Preview ·
|
|
/approve-spec cc085b2 |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet, so a maintainer needs to add the ci:run label, which takes effect on the next push, a close and reopen, or marking the pull request ready.
The useSyntaxTheme hook doc and the keyword color example match what the hook does, and the three earlier points are fixed: the example keeps const inside its frame on right-to-left pages, the mode description names the forced-mode limit, and the import is formatted.
Claims and files checked
- Changeset:
astryx hook useSyntaxThemereturns the new hook doc. Verified: hook discovery findspackages/core/src/theme/syntax/useSyntaxTheme.doc.mjs, and the base has no doc for the hook. - Changeset:
astryx searchreturns the hook. Verified: search gathers hooks through the same discovery and reads the doc's keywords and usage. - Changeset: the example paints
constin GitHub Light's keyword color. Verified:useSyntaxThemeHookUsage.tsx:22readstoken('keyword')undergithubLight, whose keyword is#cf222e. - Description: before this change the hook had no doc page and no runnable example. Verified: the base has no hook doc and no block that names the hook.
- Description:
astryx template useSyntaxThemeHookUsagecopies the example. Verified: block templates are looked up by their file name. - Description: the hook returns null without a SyntaxTheme, and otherwise the theme name, mode and token colors. Verified:
SyntaxTheme.tsx:98-150. - Description: the test expects GitHub Light's keyword fill. Verified:
use-syntax-theme-hook-usage.test.tsx:51; it runs once CI runs. - Description: documentation only, with the generated route entries included and no runtime, API or visual change. Verified.
.changeset/hook-doc-use-syntax-theme.md: clearapps/sandbox/scripts/next-export-routes.json: clearinternal/shadcn-registry/routes.lock.json: clearpackages/cli/api/template/use-syntax-theme-hook-usage.test.tsx: clearpackages/cli/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.doc.mjs: clearpackages/cli/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.tsx: clearpackages/core/src/theme/syntax/useSyntaxTheme.doc.mjs: clear
…merge The useSyntaxTheme doc now records defineSyntaxTheme and presets, so their fallback entries open it, and the docs index has one more entry, so the icon-set search reports 397 results. Regenerated with vitest -u.
|
/approve-spec c6e70e6 |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet. The pull request is still a draft from a fork, so CI runs once it is marked ready for review and carries the ci:run label, which a maintainer adds.
The useSyntaxTheme hook doc and the keyword color example match what the hook does. astryx hook, astryx search and astryx template now find them, the example takes its color from the hook, and const stays inside its frame on right-to-left pages. The regenerated resolution fixture and search goldens match what the CLI now produces.
Claims and files checked
- Changeset: a docs patch for the core and CLI packages. Verified: the changeset check passes, and both packages have changed files.
- Changeset and description:
astryx hook useSyntaxThemereturns the new hook doc. Verified: it prints the page on this head; on main it answers "No hook named". - Changeset and description:
astryx searchreturns the hook. Verified: a search foruseSyntaxThemereturns the hook and the example block on this head, and neither on main. - Changeset and description: the example paints
constin GitHub Light's keyword color. Verified:useSyntaxThemeHookUsage.tsx:22readstoken('keyword')undergithubLight(keyword#cf222e), and the rendered fill isrgb(207, 34, 46). - Description: before this change the hook had no doc page and no runnable example. Verified: main's docs data has no entry for the hook, and the example-coverage report lists it as missing both.
- Description: the hook now has a docsite page. Verified: the docs data generator emits the hook entry on this head, and the preview deployment succeeded.
- Description:
astryx template useSyntaxThemeHookUsagecopies the example. Verified: it resolves the block and prints its source on this head (a path argument writes it into the project); on main the template is unknown. - Description: the hook returns null without a SyntaxTheme, and otherwise the theme name, mode and token colors. Verified:
SyntaxTheme.tsx:98-150. - Description: the doc sits next to the syntax theme, and the block names the hook as its example target. Verified:
packages/core/src/theme/syntax/useSyntaxTheme.doc.mjsanduseSyntaxThemeHookUsage.doc.mjs:6. - Description: the test expects GitHub Light's keyword fill. Verified:
use-syntax-theme-hook-usage.test.tsx:51, and the test passes. - Description: documentation only, with every generated file included and no runtime, API or visual change. Verified: the route lock, sandbox route list, resolution fixture and search goldens match their checks, and the public API surface is unchanged.
- Description: no internal context. Verified: no internal names or new links in the changes, commits, title or body.
.changeset/hook-doc-use-syntax-theme.md: clearapps/sandbox/scripts/next-export-routes.json: clearinternal/shadcn-registry/routes.lock.json: clearpackages/cli/api/component/__fixtures__/resolutions/modules.txt: clearpackages/cli/api/template/use-syntax-theme-hook-usage.test.tsx: clearpackages/cli/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.doc.mjs: clearpackages/cli/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.tsx: clearpackages/cli/test/__golden__/no-icon-set/search-icon-set.json: clearpackages/cli/test/__golden__/no-icon-set/search-icon-set.txt: clearpackages/core/src/theme/syntax/useSyntaxTheme.doc.mjs: clear
Part of #11207
Reader impact
A builder cannot find
useSyntaxTheme:astryx hookdoes not return it, and the hook has no docsite page or runnable example. After this change the hook has a page,astryx hookandastryx searchreturn it, andastryx template useSyntaxThemeHookUsagecopies the example.Source of truth
useSyntaxThemeinpackages/core/src/theme/syntax/SyntaxTheme.tsxreturns null without a SyntaxTheme, and otherwise the theme name, mode, and token colors.architecture:knowledge-contractsINV28.Correction
Adds a HookDoc next to the syntax theme, and
blocks/components/SyntaxTheme/useSyntaxThemeHookUsage(exampleFor: 'useSyntaxTheme'). The block paints const withtoken('keyword')inside GitHub Light.Evidence
use-syntax-theme-hook-usage.test.tsxexpects the keyword fill to be the GitHub Light keyword color.Scope
Components: SyntaxTheme, useSyntaxTheme
Testing
vitest run packages/cli/api/template/use-syntax-theme-hook-usage.test.tsx