diff --git a/data/themes.json b/data/themes.json index aa1e7ff..c027b47 100644 --- a/data/themes.json +++ b/data/themes.json @@ -1,6 +1,6 @@ { - "themes": [ - { + "themes": { + "dark" : { "name": "Dark", "id": "dark", "description": "Dark", @@ -16,5 +16,5 @@ "accentColorOrange": "0xFFFEA68D", "accentColorDark": "0xFFF3F3F3" } - ] + } } \ No newline at end of file diff --git a/src/getThemeDetails.ts b/src/getThemeDetails.ts index 29db92e..a4435f1 100644 --- a/src/getThemeDetails.ts +++ b/src/getThemeDetails.ts @@ -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; \ No newline at end of file diff --git a/src/getThemeList.ts b/src/getThemeList.ts index cdd9cbd..b0fcd82 100644 --- a/src/getThemeList.ts +++ b/src/getThemeList.ts @@ -4,17 +4,18 @@ function getThemeList() { const json = JSON.parse(json_file); const themes = json.themes; var themeArray : Array = []; - 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; }