feat: synchronize CodeGroup tab selection across page and persist preference#342
Open
rogeriochaves wants to merge 1 commit intowevm:mainfrom
Open
feat: synchronize CodeGroup tab selection across page and persist preference#342rogeriochaves wants to merge 1 commit intowevm:mainfrom
rogeriochaves wants to merge 1 commit intowevm:mainfrom
Conversation
…ference Adds state management to CodeGroup component to synchronize tab selection across all code groups on the same page and persist user preference to localStorage. When a user selects a language tab (e.g., TypeScript, JavaScript), all other code groups on the page automatically switch to the same language, and the preference is saved. When the user returns to the documentation, their preferred language is automatically selected. Key features: - Synchronizes tab selection across all CodeGroup instances on the page - Persists selection to localStorage for future visits - Cross-tab synchronization using storage events - Same-page synchronization using custom events - Graceful error handling for SSR and private browsing mode - Only switches to tabs that exist in each code group This significantly improves UX for users who consistently prefer one language, eliminating the need to manually switch tabs on every code example.
|
@rogeriochaves is attempting to deploy a commit to the Wevm Team on Vercel. A member of the Team first needs to authorize it. |
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.
Hey there, this is also another feature we are currently using on Scenario that I think should benefit other vocs user:
https://scenario.langwatch.ai/
===
Adds state management to CodeGroup component to synchronize tab selection across all code groups on the same page and persist user preference to localStorage.
When a user selects a language tab (e.g., TypeScript, JavaScript), all other code groups on the page automatically switch to the same language, and the preference is saved. When the user returns to the documentation, their preferred language is automatically selected.
Key features:
This significantly improves UX for users who consistently prefer one language, eliminating the need to manually switch tabs on every code example.
It also allows listening to external components changing the global language, e.g. this select we have on top: