-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Allow configs to override default CSS theme values in theme()
function provided to plugins and configs
#14359
Merged
Merged
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
bba014c
Add failing test
adamwathan 237c6de
WIP
RobinMalfait 1efd997
WIP
RobinMalfait f99b8c5
make TypeScript happy
RobinMalfait 98421d2
move tests around
RobinMalfait 7a90d34
refactor `theme(…)`, simplify implementation
RobinMalfait 26c98ec
adjust comments
RobinMalfait 67daf9f
Correctly overwrite default theme tuple values
thecrypticace 5f2851a
Simplify code
thecrypticace 14555ea
Cleanup code
thecrypticace 29dfe92
Apply suggestions from code review
adamwathan ffc9fed
Update changelog
adamwathan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
type Colors = { | ||
[key: string | number]: string | Colors | ||
} | ||
|
||
export function flattenColorPalette(colors: Colors) { | ||
let result: Record<string, string> = {} | ||
|
||
for (let [root, children] of Object.entries(colors ?? {})) { | ||
if (typeof children === 'object' && children !== null) { | ||
for (let [parent, value] of Object.entries(flattenColorPalette(children))) { | ||
result[`${root}${parent === 'DEFAULT' ? '' : `-${parent}`}`] = value | ||
} | ||
} else { | ||
result[root] = children | ||
} | ||
} | ||
|
||
return result | ||
} |
Oops, something went wrong.
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.
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.
TODO: We need to expose this to the end user for backwards compatibility. I believe it's
tailwindcss/lib/util/flattenColorPalette
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.
Really unfortunate it needs to live at
tailwindcss/lib/util/flattenColorPalette
and nottailwindcss/flattenColorPalette
.Do you think we should do this in this PR or a followup?
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 that be something we configure in our exports config or copy over at build-time or something I wonder?
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 think we would still require a separate file to point to, but the paths should be fixable via exports I believe.
I also think that it should be a default export in the final result so that you can do
const flattenColorPalette = require('...')
which is what's currently used.