Skip to content

Commit

Permalink
Set color opacity variable when colors are defined as functions (#2515)
Browse files Browse the repository at this point in the history
* Always set color opacity variable, even if color cannot be parsed

* Only set color opacity when it might be used
  • Loading branch information
adamwathan authored Oct 7, 2020
1 parent 2f9e669 commit f3893d1
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions __tests__/plugins/gradientColorStops.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ test('opacity variables are given to colors defined as closures', () => {
.then(result => {
const expected = `
.text-primary {
--text-opacity: 1;
color: rgba(31,31,31,var(--text-opacity,1))
}
.text-opacity-50 {
Expand Down
1 change: 1 addition & 0 deletions __tests__/withAlphaVariable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ test('it allows a closure to be passed', () => {
variable: '--bg-opacity',
})
).toEqual({
'--bg-opacity': '1',
'background-color': 'rgba(0, 0, 0, var(--bg-opacity))',
})
})
1 change: 1 addition & 0 deletions src/util/withAlphaVariable.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export function toRgba(color) {
export default function withAlphaVariable({ color, property, variable }) {
if (_.isFunction(color)) {
return {
[variable]: '1',
[property]: color({ opacityVariable: variable }),
}
}
Expand Down

0 comments on commit f3893d1

Please sign in to comment.