@@ -2,8 +2,8 @@ const _ = require('lodash');
22const Color = require ( 'color' ) ;
33
44module . exports = function ( ) {
5- return ( { config , e , addUtilities , variants } ) => {
6- const defaultDirections = {
5+ return ( { theme , variants , e , addUtilities } ) => {
6+ const defaultGradientDirections = {
77 't' : 'to top' ,
88 'tr' : 'to top right' ,
99 'r' : 'to right' ,
@@ -13,18 +13,22 @@ module.exports = function() {
1313 'l' : 'to left' ,
1414 'tl' : 'to top left' ,
1515 } ;
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 ) ;
1822
1923 const gradientUtilities = ( function ( ) {
2024 let utilities = { } ;
21- _ . forEach ( config ( 'theme.gradients.colors' , defaultColors ) , ( colors , colorKey ) => {
25+ _ . forEach ( gradientColors , ( colors , colorKey ) => {
2226 if ( ! _ . isArray ( colors ) || colors . length === 1 ) {
2327 let color = _ . isArray ( colors ) ? colors [ 0 ] : colors ;
2428 let parsedColor = Color ( color ) ;
2529 colors = [ parsedColor . alpha ( 0 ) . rgb ( ) . string ( ) , color ] ;
2630 }
27- _ . forEach ( config ( 'theme.gradients.directions' , defaultDirections ) , ( direction , directionKey ) => {
31+ _ . forEach ( gradientDirections , ( direction , directionKey ) => {
2832 utilities [ `.${ e ( `bg-gradient-${ directionKey } -${ colorKey } ` ) } ` ] = {
2933 backgroundImage : `linear-gradient(${ direction } , ${ colors . join ( ', ' ) } )` ,
3034 } ;
@@ -33,6 +37,6 @@ module.exports = function() {
3337 return utilities ;
3438 } ) ( ) ;
3539
36- addUtilities ( gradientUtilities , variants ( 'gradients' , defaultVariants ) ) ;
40+ addUtilities ( gradientUtilities , gradientVariants ) ;
3741 } ;
3842} ;
0 commit comments