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",
"id": "dark",
"description": "Dark",
@ -16,5 +16,5 @@
"accentColorOrange": "0xFFFEA68D",
"accentColorDark": "0xFFF3F3F3"
}
]
}
}

View File

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

View File

@ -4,17 +4,18 @@ function getThemeList() {
const json = JSON.parse(json_file);
const themes = json.themes;
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 = {
"name": themes[i].name,
"id": themes[i].id,
"description": themes[i].description,
"primary_color": themes[i].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
"tertiary_color": themes[i].tertiary_color, // Tertiary color is the color of the buttonTextPrimary in the theme
"name": themes[key].name,
"id": themes[key].id,
"description": themes[key].description,
"primary_color": themes[key].primary_color, // Primary color is background color in the theme
"secondary_color": themes[key].secondary_color, // Secondary color is the color of the buttonBackPrimary in the theme
"tertiary_color": themes[key].tertiary_color, // Tertiary color is the color of the buttonTextPrimary in the theme
}
themeArray.push(theme);
}
})
return themeArray;
}