sdc-build-wp 2.0.3 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.js +1 -1
  2. package/lib/style.js +18 -9
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -20,7 +20,7 @@ let chokidarOpts = {
20
20
  let sassGlobPath = project.package?.sdc?.sassGlobPath || project.path + '/_src/style/**/*.scss';
21
21
  let sassGlob = glob.sync(sassGlobPath, {
22
22
  ignore: [
23
- project.path + '/_src/style/partials/_colors.scss'
23
+ project.path + '/_src/style/partials/_theme.scss'
24
24
  ]
25
25
  });
26
26
 
package/lib/style.js CHANGED
@@ -13,18 +13,27 @@ import { promises } from 'fs';
13
13
  const buildColors = async () => {
14
14
  try {
15
15
  let theme = JSON.parse(await promises.readFile(project.path + '/theme.json'));
16
- if (theme.settings?.color?.palette?.length > 0) {
17
- let palette = theme.settings.color.palette;
18
- let colorFileData = `// This file is automatically generated. Do not edit.\n`;
19
- for (var color of palette) {
20
- colorFileData += `$${color['slug']}: ${color['color']};\n`;
16
+ let themeFileData = `// This file is automatically generated. Do not edit.\n`;
17
+ if (theme.settings?.typography?.fontFamilies) {
18
+ for (var fontFamily of theme.settings.typography.fontFamilies) {
19
+ themeFileData += `$${fontFamily['slug']}: ${fontFamily['fontFamily']};\n`;
21
20
  }
22
- try {
23
- await promises.writeFile(project.path + '/_src/style/partials/_colors.scss', colorFileData);
24
- } catch {
25
- log('error', `Failed to write auto-generated _colors.scss - See above error.`);
21
+ }
22
+ if (theme.settings?.color?.palette) {
23
+ for (var color of theme.settings.color.palette) {
24
+ themeFileData += `$${color['slug']}: ${color['color']};\n`;
25
+ }
26
+ }
27
+ if (theme.settings?.color?.gradients) {
28
+ for (var color of theme.settings.color.gradients) {
29
+ themeFileData += `$gradient-${color['slug']}: ${color['gradient']};\n`;
26
30
  }
27
31
  }
32
+ try {
33
+ await promises.writeFile(project.path + '/_src/style/partials/_theme.scss', themeFileData);
34
+ } catch {
35
+ log('error', `Failed to write auto-generated _theme.scss - See above error.`);
36
+ }
28
37
  } catch {
29
38
  log('error', `Failed to read theme.json - See above error.`);
30
39
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sdc-build-wp",
3
- "version": "2.0.3",
3
+ "version": "2.1.0",
4
4
  "description": "Custom WordPress build process.",
5
5
  "author": {
6
6
  "name": "Robert Sefer",