Skip to content

Commit fe98cc3

Browse files
committed
Pass full opacityValue always
1 parent af25d51 commit fe98cc3

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

CHANGELOG.md

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

1010
- Nothing yet!
1111

12+
## [2.0.4] - 2021-03-17
13+
14+
## Fixed
15+
16+
- Pass full `var(--bg-opacity)` value as `opacityValue` when defining colors as functions
17+
1218
## [2.0.3] - 2021-02-07
1319

1420
## Fixed
@@ -1330,7 +1336,8 @@ No release notes
13301336

13311337
- Everything!
13321338

1333-
[unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v2.0.3...HEAD
1339+
[unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v2.0.4...HEAD
1340+
[2.0.4]: https://github.com/tailwindlabs/tailwindcss/compare/v2.0.3...v2.0.4
13341341
[2.0.3]: https://github.com/tailwindlabs/tailwindcss/compare/v2.0.2...v2.0.3
13351342
[2.0.2]: https://github.com/tailwindlabs/tailwindcss/compare/v2.0.1...v2.0.2
13361343
[2.0.1]: https://github.com/tailwindlabs/tailwindcss/compare/v2.0.0...v2.0.1

__tests__/withAlphaVariable.test.js

+10
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,14 @@ test('it allows a closure to be passed', () => {
107107
'--tw-bg-opacity': '1',
108108
'background-color': 'rgba(0, 0, 0, var(--tw-bg-opacity))',
109109
})
110+
expect(
111+
withAlphaVariable({
112+
color: ({ opacityValue }) => `rgba(0, 0, 0, ${opacityValue})`,
113+
property: 'background-color',
114+
variable: '--tw-bg-opacity',
115+
})
116+
).toEqual({
117+
'--tw-bg-opacity': '1',
118+
'background-color': 'rgba(0, 0, 0, var(--tw-bg-opacity))',
119+
})
110120
})

src/util/withAlphaVariable.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default function withAlphaVariable({ color, property, variable }) {
2020
if (_.isFunction(color)) {
2121
return {
2222
[variable]: '1',
23-
[property]: color({ opacityVariable: variable }),
23+
[property]: color({ opacityVariable: variable, opacityValue: `var(${variable})` }),
2424
}
2525
}
2626

0 commit comments

Comments
 (0)