Skip to content

Commit

Permalink
Pass full opacityValue always
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwathan committed Mar 17, 2021
1 parent af25d51 commit fe98cc3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Nothing yet!

## [2.0.4] - 2021-03-17

## Fixed

- Pass full `var(--bg-opacity)` value as `opacityValue` when defining colors as functions

## [2.0.3] - 2021-02-07

## Fixed
Expand Down Expand Up @@ -1330,7 +1336,8 @@ No release notes

- Everything!

[unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v2.0.3...HEAD
[unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v2.0.4...HEAD
[2.0.4]: https://github.com/tailwindlabs/tailwindcss/compare/v2.0.3...v2.0.4
[2.0.3]: https://github.com/tailwindlabs/tailwindcss/compare/v2.0.2...v2.0.3
[2.0.2]: https://github.com/tailwindlabs/tailwindcss/compare/v2.0.1...v2.0.2
[2.0.1]: https://github.com/tailwindlabs/tailwindcss/compare/v2.0.0...v2.0.1
Expand Down
10 changes: 10 additions & 0 deletions __tests__/withAlphaVariable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,14 @@ test('it allows a closure to be passed', () => {
'--tw-bg-opacity': '1',
'background-color': 'rgba(0, 0, 0, var(--tw-bg-opacity))',
})
expect(
withAlphaVariable({
color: ({ opacityValue }) => `rgba(0, 0, 0, ${opacityValue})`,
property: 'background-color',
variable: '--tw-bg-opacity',
})
).toEqual({
'--tw-bg-opacity': '1',
'background-color': 'rgba(0, 0, 0, var(--tw-bg-opacity))',
})
})
2 changes: 1 addition & 1 deletion src/util/withAlphaVariable.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function withAlphaVariable({ color, property, variable }) {
if (_.isFunction(color)) {
return {
[variable]: '1',
[property]: color({ opacityVariable: variable }),
[property]: color({ opacityVariable: variable, opacityValue: `var(${variable})` }),
}
}

Expand Down

0 comments on commit fe98cc3

Please sign in to comment.