-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
feat(v2): update swizzle command to suggest component/theme #3021
Conversation
Deploy preview for docusaurus-2 ready! Built with commit 3aad5f3 |
That looks like a nice improvement. What about making the message clearer like "this is the list of available themes you can swizzle" or something? |
yes, that looks fine thanks |
Thanks @anshulrgoyal that looks like a first version. Here are a few suggestions to improve:
|
I wonder if also the theme should not explicitly define the component list to swizzle. Because currently, some theme components are considered "implementation details", and we don't necessarily want to encourage the users to swizzle those, as this would implicitly expand the api surface of a theme. What about exploring the idea of defining, at the theme level, a list of swizzle suggestions? We could allow the user to swizzle values out of the suggestions, with a flag like --danger or something, so that they know that they are swizzling internal comp, and they may have to handle breaking changes |
I will add a tree-like listing for components and idea of theme defining swizzle component is nice but It would be a breaking change :), we can let user export a list of swizzle component. |
Or we can let the theme define a list of dangerous component |
Something like this works @slorber? |
thanks that looks better
Not sure what you mean by breaking changes? it's just a list of suggestions displayed, it should not forbid the user to swizzle a component that is internal, just not suggest to swizzle it. This feature should not affect current swizzle behavior. Anyway even if we did forbid the user to swizzle with the cli, he would still be able to copy the files manually if he really wants to, and that would work.
I'd rather have the opposite instead. By default comps are considered as internal code, unless we explicitly add them to the list, is less risky than having them being recommended for swizzling by default. Devs will likely forget to add comps to that list. If this happens, it's not a big deal, the comp won't be suggested in the list but the swizzle command on this comp will still work anyway. |
Maybe we should add a method like isSwizzleRecommendation(compName: string): boolean or something, and let the theme decide if it wants to do a allow/denylist or whatever? I think the classic theme should rather be an allow list to avoid recommending to swizzle impl details, but for other smaller themes we might as well want to suggest all comps by default, and avoid annoying the user to manually craft a list of allowed comps to swizzle |
I thought u meant to not allow swizzle of certain component in a theme. |
I am more inclined to list of allowed component because it will give more control to |
@slorber something like this? |
const components=[ // 'AnnouncementBar',
// 'BlogListPage',
// 'BlogListPaginator',
// 'BlogPostItem',
// 'BlogPostPage',
// 'BlogPostPaginator',
// 'BlogTagsListPage',
// 'BlogTagsPostsPage',
'CodeBlock',
// 'DocItem',
// 'DocPage',
// 'DocPaginator',
'DocSidebar',
'Footer',
// 'Heading',
// 'Layout',
// 'MDXComponents',
// 'Navbar',
'NotFound',
'SearchBar',
// 'TabItem',
// 'Tabs',
// 'ThemeContext',
// 'ThemeProvider',
// 'Toggle',
// 'UserPreferencesContext',
// 'UserPreferencesProvider',
// 'hooks/useAnnouncementBar',
// 'hooks/useHideableNavbar',
// 'hooks/useLocationHash',
// 'hooks/useLockBodyScroll',
// 'hooks/useLogo',
// 'hooks/usePrismTheme',
// 'hooks/useScrollPosition',
// 'hooks/useTOCHighlight',
// 'hooks/useTabGroupChoice',
'hooks/useTheme',
// 'hooks/useThemeContext',
// 'hooks/useUserPreferencesContext',
// 'hooks/useWindowSize',
'prism-include-languages',] |
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.
That looks good!
Will test this soon and merge it for the next release
@anshulrgoyal btw, there's a merge conflict here |
Thanks. I will resolve them |
that looks good thanks |
Motivation
Better user experience for swizzle cli. Based on #2984
Have you read the Contributing Guidelines on pull requests?
yes
Test Plan