feat: changed themes.json style

This commit is contained in:
detherminal 2023-04-18 14:05:15 +03:00
parent 1a84029031
commit 3f7a03d8b5
3 changed files with 18 additions and 15 deletions

View File

@ -1,6 +1,6 @@
{ {
"themes": [ "themes": {
{ "dark" : {
"name": "Dark", "name": "Dark",
"id": "dark", "id": "dark",
"description": "Dark", "description": "Dark",
@ -16,5 +16,5 @@
"accentColorOrange": "0xFFFEA68D", "accentColorOrange": "0xFFFEA68D",
"accentColorDark": "0xFFF3F3F3" "accentColorDark": "0xFFF3F3F3"
} }
] }
} }

View File

@ -3,11 +3,13 @@ function getThemeDetails(id : string) {
const json_file = fs.readFileSync("data/themes.json"); const json_file = fs.readFileSync("data/themes.json");
const json = JSON.parse(json_file); const json = JSON.parse(json_file);
const themes = json.themes; const themes = json.themes;
for (let i = 0; i < themes.length; i++) { var theme = {};
if (themes[i].id == id) { Object.entries(themes).map(([key, value]) => {
return themes[i]; if (key == id){
theme = (themes[key])
} }
} });
return theme
} }
module.exports = getThemeDetails; module.exports = getThemeDetails;

View File

@ -4,17 +4,18 @@ function getThemeList() {
const json = JSON.parse(json_file); const json = JSON.parse(json_file);
const themes = json.themes; const themes = json.themes;
var themeArray : Array<Object> = []; var themeArray : Array<Object> = [];
for (let i = 0; i < themes.length; i++) { // For loop that will look for all the themes in the themes.json file
Object.entries(themes).map(([key, value]) => {
var theme : Object = { var theme : Object = {
"name": themes[i].name, "name": themes[key].name,
"id": themes[i].id, "id": themes[key].id,
"description": themes[i].description, "description": themes[key].description,
"primary_color": themes[i].primary_color, // Primary color is background color in the theme "primary_color": themes[key].primary_color, // Primary color is background color in the theme
"secondary_color": themes[i].secondary_color, // Secondary color is the color of the buttonBackPrimary in the theme "secondary_color": themes[key].secondary_color, // Secondary color is the color of the buttonBackPrimary in the theme
"tertiary_color": themes[i].tertiary_color, // Tertiary color is the color of the buttonTextPrimary in the theme "tertiary_color": themes[key].tertiary_color, // Tertiary color is the color of the buttonTextPrimary in the theme
} }
themeArray.push(theme); themeArray.push(theme);
} })
return themeArray; return themeArray;
} }