forked from gregsullivan/_tw-themejson
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·41 lines (37 loc) · 1.07 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const plugin = require( 'tailwindcss/plugin' );
module.exports = plugin.withOptions(
function() {
// Use an empty plugin function to accept the options object.
return function() {};
}, function( themejson ) {
// Create an empty object for the theme.json properties.
const themejsonProps = {};
// Load all of the colors from the theme.json file.
if ( Array.isArray( themejson.settings.color.palette ) ) {
themejsonProps.colors = {};
themejson.settings.color.palette.forEach( function( color ) {
themejsonProps.colors[ color.slug ] = color.color;
} );
}
// Load all of the widths from the theme.json file.
themejsonProps.widths = {};
[ 'content', 'wide' ].forEach( function( width ) {
if ( undefined !== themejson.settings.layout[ width + 'Size' ] ) {
themejsonProps.widths[ width ] = themejson.settings.layout[ width + 'Size' ];
}
} );
// Update the configuration.
return {
theme: {
extend: {
colors: {
...themejsonProps.colors,
},
maxWidth: {
...themejsonProps.widths,
},
},
},
};
},
);