From faf7dacfd481bd7b8dcdb0105d411bd5853bdb73 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Mon, 29 May 2023 17:22:57 -0400 Subject: [PATCH] fix: updates the paragon-theme.json output (#2334) * fix: updates the paragon-theme.json output * fix: typo --- build-scss.js | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/build-scss.js b/build-scss.js index a49d591158..09c1331a44 100755 --- a/build-scss.js +++ b/build-scss.js @@ -27,19 +27,27 @@ const updateParagonThemeOutput = ({ paragonThemeOutput, name, isThemeVariant, + isDefaultThemeVariant, + isDarkThemeVariant, }) => { if (isThemeVariant) { paragonThemeOutput.themeUrls.variants = { ...paragonThemeOutput.themeUrls.variants, [name]: { - default: `./${name}.css`, - minified: `./${name}.min.css`, + paths: { + default: `./${name}.css`, + minified: `./${name}.min.css`, + }, + default: isDefaultThemeVariant, + dark: isDarkThemeVariant, }, }; } else { paragonThemeOutput.themeUrls[name] = { - default: `./${name}.css`, - minified: `./${name}.min.css`, + paths: { + default: `./${name}.css`, + minified: `./${name}.min.css`, + }, }; } return paragonThemeOutput; @@ -61,6 +69,8 @@ const compileAndWriteStyleSheets = ({ stylesPath, outDir, isThemeVariant = false, + isDefaultThemeVariant = true, + isDarkThemeVariant = false, }) => { const compiledStyleSheet = sass.compile(stylesPath, { importers: [{ @@ -93,6 +103,8 @@ const compileAndWriteStyleSheets = ({ paragonThemeOutput: initialConfigOutput, name, isThemeVariant, + isDefaultThemeVariant, + isDarkThemeVariant, }); } else { const existingParagonThemeOutput = JSON.parse(fs.readFileSync(`${outDir}/${paragonThemeOutputFilename}`, 'utf8')); @@ -100,6 +112,8 @@ const compileAndWriteStyleSheets = ({ paragonThemeOutput: existingParagonThemeOutput, name, isThemeVariant, + isDefaultThemeVariant, + isDarkThemeVariant, }); } fs.writeFileSync(`${outDir}/${paragonThemeOutputFilename}`, `${JSON.stringify(paragonThemeOutput, null, 2)}\n`); @@ -171,6 +185,9 @@ program stylesPath: `${themesPath}/${themeDir.name}/index.css`, outDir, isThemeVariant: true, + isDefaultThemeVariant: themeDir.name === 'light', + // "dark" theme dir does not exist yet, but no harm in having this here + isDarkThemeVariant: themeDir.name === 'dark', }); }); });