Merge pull request #1676 from innocenzi/color-closure
Allow colors to be defined as closures
This commit is contained in:
commit
7371ea992b
2 changed files with 19 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import createColor from 'color'
|
||||
import _ from 'lodash'
|
||||
|
||||
function hasAlpha(color) {
|
||||
return (
|
||||
|
|
@ -18,6 +19,12 @@ function toRgba(color) {
|
|||
}
|
||||
|
||||
export default function withAlphaVariable({ color, property, variable }) {
|
||||
if (_.isFunction(color)) {
|
||||
return {
|
||||
[property]: color({ opacityVariable: variable }),
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const [r, g, b, a] = toRgba(color)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue