-
-
Notifications
You must be signed in to change notification settings - Fork 96
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
Add Theme Color Selector for Dynamic Component Previews - Merge conflicts resolved #252
Conversation
…older option in theme color selector
…ponent to author's url
…view component to author's url" This reverts commit 4923c6e.
I don't know why it is saying this branch must not contain merge commits, I have not merged anything onto my branch. I have rebased the changes to my branch. All the conflicts are resolved. I have to close the previous one due to same issue. |
I have also moved the router configuration into separate file |
I have fixed the css of Select Color Dropdown, See:
theme-selector-css.mp4 |
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.
LGTM, thanks for the work 🙏
Add Theme Color Selector for Dynamic Component Previews
Demo Video on YouTube
Overview
This pull request introduces a new feature to the Flutter Shadcn UI documentation: a theme color selector. Users can now dynamically update the preview of all components by selecting a different theme color from a dropdown menu. Additionally, the Flutter Playground code has been updated to accept the
themeColor
query parameter and dynamically apply the selected theme color.Note: You need to build the Flutter Playground web app and deploy it to preview the current changes. Alternatively, you can use my hosted version with the updated changes at: https://flutter-shadcn-playground.web.app/.
Changes Made
Documentation Updates
Theme Color Selector:
data-theme-color
attribute to dynamically update the component previews.Dynamic Preview Updates:
theme
: Light/Dark mode.themeColor
: The selected theme color.theme
andthemeColor
parameters are preserved in the iframe'ssrc
.Default Behavior:
zinc
) when no color is selected.Flutter Playground Updates
Query Parameter Support:
themeColor
query parameter in the Flutter Playground.theme
(light/dark mode) andthemeColor
parameters are parsed from the URL.Dynamic Theme Application:
Color Scheme Mapping:
getShadColorScheme
function to handle theme color mapping:Preview src link updated:
Example from
button.mdx
:Updated the preview src links to follow the new concise format:
Default Preview
src
:src
links to use a concise format (e.g.,button?style=primary
).defaultPrefix
variable inPreview.astro
to construct the full URL dynamically.Example:
This allows for flexibility in hosting the Flutter Playground locally or using hosted URLs.
Implementation Details
Theme Color Selector:
data-theme
anddata-theme-color
attribute changes usingMutationObserver
.src
dynamically to reflect the selected theme and theme color query parameters.Default Prefix in
Preview.astro
:defaultPrefix
variable to manage the base URL for the Flutter Playground..Persistent State:
localStorage
for persistence across sessions.Flutter Playground Enhancements:
theme
andthemeColor
query parameters.zinc
forthemeColor
).How to Test
Component Previews:
theme
andthemeColor
query parameters.Flutter Playground:
Fallback Behavior:
Thank you for reviewing this pull request! Please let me know if there are additional changes or improvements required.