Handle variable colors that have variable fallback values (#12049)

* Parse colors even when variable has fallback that is a variable

* Update changelog
This commit is contained in:
Jordan Pittman 2023-09-20 16:34:39 -04:00
parent 38fd41ea0b
commit 8012d1819b
3 changed files with 20 additions and 1 deletions

View File

@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Skip `calc()` normalisation in nested `theme()` calls ([#11705](https://github.com/tailwindlabs/tailwindcss/pull/11705))
- Fix incorrectly generated CSS when using square brackets inside arbitrary properties ([#11709](https://github.com/tailwindlabs/tailwindcss/pull/11709))
- Make `content` optional for presets in TypeScript types ([#11730](https://github.com/tailwindlabs/tailwindcss/pull/11730))
- Handle variable colors that have variable fallback values ([#12049](https://github.com/tailwindlabs/tailwindcss/pull/12049))
## [3.3.3] - 2023-07-13

View File

@ -5,7 +5,7 @@ let SHORT_HEX = /^#([a-f\d])([a-f\d])([a-f\d])([a-f\d])?$/i
let VALUE = /(?:\d+|\d*\.\d+)%?/
let SEP = /(?:\s*,\s*|\s+)/
let ALPHA_SEP = /\s*[,/]\s*/
let CUSTOM_PROPERTY = /var\(--(?:[^ )]*?)\)/
let CUSTOM_PROPERTY = /var\(--(?:[^ )]*?)(?:,(?:[^ )]*?|var\(--[^ )]*?\)))?\)/
let RGB = new RegExp(
`^(rgba?)\\(\\s*(${VALUE.source}|${CUSTOM_PROPERTY.source})(?:${SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?(?:${SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?(?:${ALPHA_SEP.source}(${VALUE.source}|${CUSTOM_PROPERTY.source}))?\\s*\\)$`

View File

@ -1113,3 +1113,21 @@ crosscheck(({ stable, oxide }) => {
`)
})
})
it('variables with variable fallback values can use opacity modifier', async () => {
let config = {
content: [
{
raw: html`<div class="bg-[rgb(var(--some-var,var(--some-other-var)))]/50"></div>`,
},
],
}
let result = await run(`@tailwind utilities;`, config)
expect(result.css).toMatchFormattedCss(css`
.bg-\[rgb\(var\(--some-var\,var\(--some-other-var\)\)\)\]\/50 {
background-color: rgb(var(--some-var, var(--some-other-var)) / 0.5);
}
`)
})