Skip to content
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 multiple <alpha-value> in color definitions #13740

Merged
merged 3 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- Nothing yet!
### Fixed

- Make it possible to use multiple `<alpha-value>` placeholders in a single color definition ([#13740](https://github.com/tailwindlabs/tailwindcss/pull/13740))

## [3.4.3] - 2024-03-27

Expand Down
2 changes: 1 addition & 1 deletion src/util/pluginUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export function parseColorFormat(value) {
if (typeof value === 'string' && value.includes('<alpha-value>')) {
let oldValue = value

return ({ opacityValue = 1 }) => oldValue.replace('<alpha-value>', opacityValue)
return ({ opacityValue = 1 }) => oldValue.replace(/<alpha-value>/g, opacityValue)
}

return value
Expand Down
24 changes: 24 additions & 0 deletions tests/opacity.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,30 @@ it('should be possible to use an <alpha-value> as part of the color definition w
})
})

it('should be possible to use multiple <alpha-value>s as part of the color definition with an opacity modifiers', () => {
let config = {
content: [
{
raw: html` <div class="bg-primary/50"></div> `,
},
],
corePlugins: ['backgroundColor'],
theme: {
colors: {
primary: 'light-dark(rgb(0 0 0 / <alpha-value>), rgb(255 255 255 / <alpha-value>))',
},
},
}

return run('@tailwind utilities', config).then((result) => {
expect(result.css).toMatchFormattedCss(css`
.bg-primary\/50 {
background-color: light-dark(rgb(0 0 0 / 0.5), rgb(255 255 255 / 0.5));
}
`)
})
})

it('should be possible to use an <alpha-value> as part of the color definition with an opacity modifiers', () => {
let config = {
content: [
Expand Down
Loading