-
Notifications
You must be signed in to change notification settings - Fork 50
Add JSX support for component examples in admin docs #3460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 2025-10
Are you sure you want to change the base?
Conversation
We detected some changes in |
b035f0b
to
fa365db
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving to unblock this. The example isn't super broken but we should fix in a follow up.
Avatar: Error handling example
parse-error.ts:95 Uncaught SyntaxError: /Inline Babel script: Unexpected token, expected "," (5:3)
3 | initials="CS"
4 | alt="Customer support"
> 5 | />;
| ^
6 | {
7 | /* Will display "CS" initials when image fails */
Background
Admin component examples were previously written in HTML format using custom elements (e.g.,
<s-number-field>
). This PR adds support for writing examples in JSX format, which allow us to showcase interaction with the components, and javascript-only attributes. This will also enable us to do type checking on examples in the future.Solution
Added JSX preview support to the documentation build system:
Build System Changes (
build-docs.mjs
):jsxWrapper()
function that generates HTML with Preact runtime, Babel standalone transpiler, and necessary polyfillsreturn
statement, while supporting complete function bodies with hookscreateTemplate()
to accept ajsx
flag that determines whether to use JSX or HTML wrapperpreview-jsx
language type alongside existingpreview
typeComponent Example Updates:
NumberField
default example from HTML to JSX format.html
to.jsx
step={5}
instead ofstep="5"
)Demos
Screen.Recording.2025-10-02.at.12.52.54.PM.mov
Screen.Recording.2025-10-02.at.11.57.53.AM.mov
🎩
Checklist