Skip to content

Spreading tailwindcss/defaultTheme exports keeps bare values#14257

Merged
philipp-spiess merged 5 commits into
nextfrom
fix/spreading-default-theme-exports-keeps-bare-values
Aug 29, 2024
Merged

Spreading tailwindcss/defaultTheme exports keeps bare values#14257
philipp-spiess merged 5 commits into
nextfrom
fix/spreading-default-theme-exports-keeps-bare-values

Conversation

@philipp-spiess
Copy link
Copy Markdown
Contributor

In #14221 we added a new export to the tailwindcss package: tailwindcss/defaultTheme. This is build on top of the full config from V3 and will allow plugins to keep being compatible.

However, spreading in from this package has overwritten the bare value callback handler. This PR fixes it by sharing the bare value callbacks with the compat config.

philipp-spiess added a commit that referenced this pull request Aug 26, 2024
We noticed that when the `defaultTheme` (change for this is coming in
#14257) defines a tuple that is also defined in the CSS theme, the
values are incorrectly merged as objects instead of overwritten.
However, CSS theme values should take precedence, even when they use
tuple syntax.

Proper coverage of this will come once `#14257` is merged when calling
`theme(fontSize.xs[1].lineHeight)` will also have a default value passed
in from the `defaultTheme`.
philipp-spiess added a commit that referenced this pull request Aug 26, 2024
While working on #14257, we noticed two issues with the CSS `theme()`
function:

1. In V3 it's possible to set arrays inside the theme object. An example
for this is the default font families as defined here:
https://github.com/tailwindlabs/tailwindcss/blob/main/stubs/config.full.js#L303-L311.
We now properly join these arrays that are not tuples.
2. We noticed that in the case where there are no modifiers, the
fallback values for the CSS `theme()` function had the first word
removed. A regression test for this was added.
@philipp-spiess philipp-spiess force-pushed the fix/spreading-default-theme-exports-keeps-bare-values branch from 43a3aea to b4fbe0c Compare August 26, 2024 16:55
Comment thread packages/tailwindcss/src/compat/default-theme.ts
Comment thread packages/tailwindcss/src/plugin-api.test.ts
Comment thread packages/tailwindcss/src/functions.test.ts
philipp-spiess added a commit that referenced this pull request Aug 27, 2024
We noticed that when the `defaultTheme` (change for this is coming in
#14257) defines a tuple that is also defined in the CSS theme, the
values are incorrectly merged as objects instead of overwritten.
However, CSS theme values should take precedence, even when they use
tuple syntax.

Proper coverage of this will come once `#14257` is merged when calling
`theme(fontSize.xs[1].lineHeight)` will also have a default value passed
in from the `defaultTheme`.
philipp-spiess added a commit that referenced this pull request Aug 27, 2024
While working on #14257, we noticed two issues with the CSS `theme()`
function:

1. In V3 it's possible to set arrays inside the theme object. An example
for this is the default font families as defined here:
https://github.com/tailwindlabs/tailwindcss/blob/main/stubs/config.full.js#L303-L311.
We now properly join these arrays that are not tuples.
2. We noticed that in the case where there are no modifiers, the
fallback values for the CSS `theme()` function had the first word
removed. A regression test for this was added.
@philipp-spiess philipp-spiess force-pushed the fix/spreading-default-theme-exports-keeps-bare-values branch from ad744e3 to d211be1 Compare August 29, 2024 11:18
@philipp-spiess philipp-spiess merged commit ac6d4a6 into next Aug 29, 2024
@philipp-spiess philipp-spiess deleted the fix/spreading-default-theme-exports-keeps-bare-values branch August 29, 2024 12:05
philipp-spiess added a commit that referenced this pull request Aug 29, 2024
While working on #14257, we noticed two issues with the CSS `theme()`
function:

1. In V3 it's possible to set arrays inside the theme object. An example
for this is the default font families as defined here:
https://github.com/tailwindlabs/tailwindcss/blob/main/stubs/config.full.js#L303-L311.
We now properly join these arrays that are not tuples.
2. We noticed that in the case where there are no modifiers, the
fallback values for the CSS `theme()` function had the first word
removed. A regression test for this was added.
philipp-spiess added a commit that referenced this pull request Aug 29, 2024
In #14221 we added a new export to the `tailwindcss` package:
`tailwindcss/defaultTheme`. This is build on top of the full config from
V3 and will allow plugins to keep being compatible.

However, spreading in from this package has overwritten the bare value
callback handler. This PR fixes it by sharing the bare value callbacks
with the compat config.
philipp-spiess added a commit that referenced this pull request Aug 29, 2024
While working on #14257, we noticed two issues with the CSS `theme()`
function:

1. In V3 it's possible to set arrays inside the theme object. An example
for this is the default font families as defined here:
https://github.com/tailwindlabs/tailwindcss/blob/main/stubs/config.full.js#L303-L311.
We now properly join these arrays that are not tuples.
2. We noticed that in the case where there are no modifiers, the
fallback values for the CSS `theme()` function had the first word
removed. A regression test for this was added.
philipp-spiess added a commit that referenced this pull request Aug 29, 2024
In #14221 we added a new export to the `tailwindcss` package:
`tailwindcss/defaultTheme`. This is build on top of the full config from
V3 and will allow plugins to keep being compatible.

However, spreading in from this package has overwritten the bare value
callback handler. This PR fixes it by sharing the bare value callbacks
with the compat config.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants