Skip to content

Commit

Permalink
Allow custom theme properties
Browse files Browse the repository at this point in the history
This allows to define custom theme properties in
the app-config JSON.
  • Loading branch information
chrismayer committed Jun 18, 2024
1 parent fe48724 commit 7add730
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/util/ColorTheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ const ColorThemeUtil = {
merged.light.warning = light.warning ? light.warning : LIGHT_WARNING;
merged.light.error = light.error ? light.error : LIGHT_ERROR;

// apply unknown / custom theme properties to light theme
for (const themeProp in light) {
const hasProp = themeProp in merged.light;
if (!hasProp) {
merged.light[themeProp] = light[themeProp];
}
}

// If light theme is configured with at least the secondary color
if (!dark || !dark.secondary) {
// fallback to default dark theme
Expand Down Expand Up @@ -144,6 +152,14 @@ const ColorThemeUtil = {
merged.dark.warning = dark.warning ? dark.warning : DARK_WARNING;
merged.dark.error = dark.error ? dark.error : DARK_ERROR;

// apply unknown / custom theme properties to dark theme
for (const themeProp in dark) {
const hasProp = themeProp in merged.dark;
if (!hasProp) {
merged.dark[themeProp] = dark[themeProp];
}
}

return merged;
},

Expand Down

0 comments on commit 7add730

Please sign in to comment.