Repository navigation
feat(theme): refresh API explorer UX and add opt-in modern layout - #1709
Merged
Merged
Conversation
Add a "modern" API page layout, opt-in at three levels: page front matter (api_layout), per spec (plugin option apiLayout), or site-wide (themeConfig.api.layout). The modern layout shows code samples and response examples in the right panel and opens the request form in a "Try it" side panel. The classic layout remains the default. Explorer changes for both layouts: - Remove the artificial 1.2 s request delay; add loading state, disabled send button and Ctrl/Cmd+Enter shortcut - Track request status explicitly instead of comparing against the translated "Fetching..." string (broke in non-English locales) - Show status text, response time and size; style request errors - Keep the last five responses per endpoint in memory (not persisted) - Endpoint bar: highlighted path params, copy URL button, "Try it" link - Fix FormTextInput overriding react-hook-form's onChange, which left values stale until blur - Accessibility: focus rings, reduced-motion support, live region, higher-contrast button and qualifier labels in dark mode - Visual polish: compact language tabs, visible input borders, pill qualifiers, less uppercase text New opt-in theme options: sidebarMethodBadges and hideTableOfContents. The demo gains a Classic/Modern switch in the navbar. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Size Change: +35.9 kB (+1.47%) Total Size: 2.48 MB 📦 View Changed
ℹ️ View Unchanged
|
|
Visit the preview URL for this PR (updated for commit 2cac646): (expires Mon, 16 Nov 2026 19:09:55 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: bf293780ee827f578864d92193b8c2866acd459f |
📸 Visual Diff ReportSnapshot comparison against https://docusaurus-openapi.tryingpan.dev/
✅ No visual regressions detected. Updated at 2026-11-09T19:15:37.611Z · run 42680165340 |
Restore the original icon-card language tabs in the classic layout so the two layouts stay distinct. The compact pill tabs now apply only inside the modern layout wrapper (.openapi-explorer--modern). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Keep the classic layout visually identical to main for section headers, explorer card headers, required/deprecated/nullable labels, schema type labels, and MIME/schema tabs. The polished variants now apply only under .openapi-layout--modern (added by ApiItem/Layout) and inside the Try it panel. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
- Show Send and "Try it" only when a request can be sent (shared useCanSendRequest hook), and apply the same rule to Ctrl/Cmd+Enter. - Guard against double submits for the whole request, including event streams, and add a Cancel button that aborts the request. - Trim the trailing slash of the server URL, and report clipboard failures through a shared copyToClipboard helper. - Add api_layout front matter to schema pages. - Show the page's api_layout in the demo layout picker. - Clear the request history when the page that shows it unmounts. - Share colorForMethod, renderPath and statusTone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The explorer refresh now applies only to the opt-in modern layout. Sites that do not set `layout: "modern"` render and behave as before. - Restore the classic Request, Response and MethodEndpoint from main, and move the refreshed versions to Request/Modern, Response/Modern and MethodEndpoint/Modern. The Try it drawer uses the modern ones, and MethodEndpoint selects by layout. - Scope the refreshed styles (endpoint bar, request and response panels, form fields, input and code font sizes, dark-mode qualifier colors) to `:is(.openapi-layout--modern, .openapi-try-it)`. - Keep the classic FormTextInput change handling and CopyButton as on main. - Classic Request keeps two invisible safeguards: it ignores a second submit while a request runs, and aborts the request on unmount. - useApiLayout returns the default outside a doc page, so MethodEndpoint still works on standalone pages. - Modern layout: wrap long endpoint paths on narrow screens instead of cutting them off. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This reverts commit cb6612b. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
sserrata
added a commit
to tmeghe/docusaurus-openapi-docs
that referenced
this pull request
Nov 20, 2026
Resolve yarn.lock conflict and mock the modern MethodEndpoint layout in the QUERY badge test after PaloAltoNetworks#1709. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This branch was successfully 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
Adds an opt-in modern API page layout with a refreshed API explorer. The classic layout stays the default and is unchanged: sites that do not opt in render and behave exactly as on
main, with no config change.Modern layout (opt-in)
api_layout: modernapiLayout: "modern"(written into front matter)themeConfig.api.layout: "modern"main): compact pill-style language tabs, normal-case section and card headers, pill-stylerequired/deprecated/nullablelabels, monospace type labels, and lowercase monospace MIME tabs. The styles are scoped under.openapi-layout--modernand the Try it panel.ApiLayoutContext(from@theme/ApiExplorer/useApiLayout) lets a site add a reader-facing switch. The demo uses it for a Classic | Modern switch in the navbar.Explorer improvements (modern layout)
"Fetching..."string, which broke in non-English locales.FormTextInputreplaced react-hook-form'sonChange, so field values updated only on blur.prefers-reduced-motion, a live region for responses, and higher-contrast send button and qualifier labels in dark mode.Classic layout
The classic Request, Response, and endpoint bar keep the
maincode (Request/index.tsx,Response/index.tsx, the classic branch ofMethodEndpoint), and all refreshed styles are scoped to:is(.openapi-layout--modern, .openapi-try-it). The only classic changes are two invisible safeguards: a second submit while a request runs is ignored, and a running request is aborted when the page unmounts.Other new opt-in theme options
sidebarMethodBadges: sidebar HTTP method badges. The selectors use:where()(zero specificity), so existing site CSS always wins.hideTableOfContents: hides the desktop TOC on API and schema pages.All new options are documented in the plugin README.
Test plan
yarn test: 662/662 pass (new tests: request history, client modules,api_layoutfront matter for API and schema pages)tsc --noEmitfor plugin and themedocusaurus build)mainand this branch withmain's demo config (an upgrade with no config change). Desktop, mobile, and dark mode screenshots show 0 different pixels, the page HTML is identical, and the explorer send flow gives identical panel HTML on API, webhook, schema, info, and/tests/pages.Note:
yarn lintfails onmaintoo, because of thecypress/globalsESLint environment. It is not related to this PR.🤖 Generated with Claude Code