@@ -2,8 +2,8 @@ const _ = require('lodash');
2
2
const Color = require ( 'color' ) ;
3
3
4
4
module . exports = function ( ) {
5
- return ( { config , e , addUtilities , variants } ) => {
6
- const defaultDirections = {
5
+ return ( { theme , variants , e , addUtilities } ) => {
6
+ const defaultGradientDirections = {
7
7
't' : 'to top' ,
8
8
'tr' : 'to top right' ,
9
9
'r' : 'to right' ,
@@ -13,18 +13,22 @@ module.exports = function() {
13
13
'l' : 'to left' ,
14
14
'tl' : 'to top left' ,
15
15
} ;
16
- const defaultColors = { } ;
17
- const defaultVariants = [ 'responsive' ] ;
16
+ const defaultGradientColors = { } ;
17
+ const defaultGradientVariants = [ 'responsive' ] ;
18
+
19
+ const gradientDirections = theme ( 'gradients.directions' , defaultGradientDirections ) ;
20
+ const gradientColors = theme ( 'gradients.colors' , defaultGradientColors ) ;
21
+ const gradientVariants = variants ( 'gradients' , defaultGradientVariants ) ;
18
22
19
23
const gradientUtilities = ( function ( ) {
20
24
let utilities = { } ;
21
- _ . forEach ( config ( 'theme.gradients.colors' , defaultColors ) , ( colors , colorKey ) => {
25
+ _ . forEach ( gradientColors , ( colors , colorKey ) => {
22
26
if ( ! _ . isArray ( colors ) || colors . length === 1 ) {
23
27
let color = _ . isArray ( colors ) ? colors [ 0 ] : colors ;
24
28
let parsedColor = Color ( color ) ;
25
29
colors = [ parsedColor . alpha ( 0 ) . rgb ( ) . string ( ) , color ] ;
26
30
}
27
- _ . forEach ( config ( 'theme.gradients.directions' , defaultDirections ) , ( direction , directionKey ) => {
31
+ _ . forEach ( gradientDirections , ( direction , directionKey ) => {
28
32
utilities [ `.${ e ( `bg-gradient-${ directionKey } -${ colorKey } ` ) } ` ] = {
29
33
backgroundImage : `linear-gradient(${ direction } , ${ colors . join ( ', ' ) } )` ,
30
34
} ;
@@ -33,6 +37,6 @@ module.exports = function() {
33
37
return utilities ;
34
38
} ) ( ) ;
35
39
36
- addUtilities ( gradientUtilities , variants ( 'gradients' , defaultVariants ) ) ;
40
+ addUtilities ( gradientUtilities , gradientVariants ) ;
37
41
} ;
38
42
} ;
0 commit comments