Skip to content

Commit 9fda461

Browse files
Fix multiple <alpha-value> in color definitions (#13740)
* Fix multiple <alpha-value> in color definitions Fixes #13716 * Update CHANGELOG.md * Use `replace` with global regex --------- Co-authored-by: Jordan Pittman <[email protected]>
1 parent f1f419a commit 9fda461

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
- Nothing yet!
10+
### Fixed
11+
12+
- Make it possible to use multiple `<alpha-value>` placeholders in a single color definition ([#13740](https://github.com/tailwindlabs/tailwindcss/pull/13740))
1113

1214
## [3.4.3] - 2024-03-27
1315

src/util/pluginUtils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export function parseColorFormat(value) {
124124
if (typeof value === 'string' && value.includes('<alpha-value>')) {
125125
let oldValue = value
126126

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

130130
return value

tests/opacity.test.js

+24
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,30 @@ it('should be possible to use an <alpha-value> as part of the color definition w
673673
})
674674
})
675675

676+
it('should be possible to use multiple <alpha-value>s as part of the color definition with an opacity modifiers', () => {
677+
let config = {
678+
content: [
679+
{
680+
raw: html` <div class="bg-primary/50"></div> `,
681+
},
682+
],
683+
corePlugins: ['backgroundColor'],
684+
theme: {
685+
colors: {
686+
primary: 'light-dark(rgb(0 0 0 / <alpha-value>), rgb(255 255 255 / <alpha-value>))',
687+
},
688+
},
689+
}
690+
691+
return run('@tailwind utilities', config).then((result) => {
692+
expect(result.css).toMatchFormattedCss(css`
693+
.bg-primary\/50 {
694+
background-color: light-dark(rgb(0 0 0 / 0.5), rgb(255 255 255 / 0.5));
695+
}
696+
`)
697+
})
698+
})
699+
676700
it('should be possible to use an <alpha-value> as part of the color definition with an opacity modifiers', () => {
677701
let config = {
678702
content: [

0 commit comments

Comments
 (0)