Skip to content

Commit

Permalink
work for #6673 import font settings for article elements
Browse files Browse the repository at this point in the history
  • Loading branch information
OlgaLarina committed Aug 24, 2023
1 parent aefa916 commit 5d23df4
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion themes-import.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const fs = require("fs");
const MikeThemes = require("./themes.json");
var themes = {};
var articleFontSettings = {};

const _dirPath = "./src/themes/";
const displayNameMap = {
Expand Down Expand Up @@ -58,7 +59,19 @@ function getShadowSettings(shadowGroup) {
return createBoxShadow(result);
}

Object.keys(MikeThemes).forEach(function (themeName) {
if(!!MikeThemes["article"] && Object.keys(MikeThemes["article"]).length > 0) {
const allowedSettings = ["fontSize", "textDecoration", "fontFamily", "fontWeight", "fontStyle", "fontStretch", "letterSpacing", "lineHeight", "paragraphIndent", "paragraphSpacing", "textCase"];
Object.keys(MikeThemes["article"]).forEach(fontSettingsName => {
const fontSettings = MikeThemes["article"][fontSettingsName];
if(!!fontSettings && Object.keys(fontSettings).length > 0) {
Object.keys(fontSettings).filter(key => allowedSettings.indexOf(key) !== -1).forEach(key => {
articleFontSettings["--sjs-article-font-" + fontSettingsName + "-" + key] = fontSettings[key] ? fontSettings[key]["value"] : undefined;
});
}
});
}

Object.keys(MikeThemes).filter(key => ["light", "dark", "ui", "article"].indexOf(key) === -1).forEach(function (themeName) {
console.log(themeName);

const generalGroup = MikeThemes[themeName]["general"];
Expand Down Expand Up @@ -128,6 +141,7 @@ Object.keys(MikeThemes).forEach(function (themeName) {
themes[displayThemeName]["--sjs-special-yellow-light"] = specialGroup["yellow-light"] ? specialGroup["yellow-light"]["value"] : undefined;
themes[displayThemeName]["--sjs-special-yellow-forecolor"] = specialGroup["yellow-forecolor"] ? specialGroup["yellow-forecolor"]["value"] : undefined;
}
themes[displayThemeName] = Object.assign(themes[displayThemeName], articleFontSettings);
});

const predefinedThemesContent = JSON.stringify(themes, null, 4);
Expand Down

0 comments on commit 5d23df4

Please sign in to comment.