-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
fix(cli): deduplicate classNames in applyColorMapping #1089
Conversation
@santidalmasso is attempting to deploy a commit to the shadcn-pro Team on Vercel. A member of the Team first needs to authorize it. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
} | ||
} | ||
|
||
return lightMode.join(" ") + " " + darkMode.join(" ").trim() | ||
return ( | ||
Array.from(lightMode).join(" ") + |
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.
🔧 Can be simplified to return [...lightMode, ...darkMode].join(' ').trim()
.
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.
Thank you for the suggestion to simplify the code. I did try implementing it that way at first, but I encountered a TypeScript error. Since TypeScript was unable to infer that lightMode and darkMode were iterable, it prevented me from using the spread syntax directly. So I opted for the Array.from method instead.
This was the error: Type 'Set<string>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
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.
I like the solution you shipped with the latest commit though. Much cleaner now!
@santidalmasso Thanks for the PR. Reviewing... |
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.
THANK YOU.
* fix(cli): deduplicate classNames in applyColorMapping * refactor: simplify applyColorMapping return * chore: add changeset --------- Co-authored-by: shadcn <[email protected]>
* fix(cli): deduplicate classNames in applyColorMapping * refactor: simplify applyColorMapping return * chore: add changeset --------- Co-authored-by: shadcn <[email protected]>
Deduplicate class names within the
applyColorMapping
function. To resolve this, the method of storing class names has been updated from using arrays to sets, which inherently ensures that all class names are unique.