1
0
Fork 0
mirror of synced 2024-07-04 14:01:27 +12:00

Add groundwork for custom themes based off other themes

This commit is contained in:
Andrew Kingston 2022-07-27 16:37:35 +01:00
parent a307d91faf
commit 30256bbb8d
3 changed files with 40 additions and 17 deletions

View file

@ -16,16 +16,19 @@ export const getThemeStore = () => {
return
}
Constants.ThemeOptions.forEach(option => {
// Update global class names to use the new theme and remove others
Constants.Themes.forEach(option => {
themeElement.classList.toggle(
`spectrum--${option}`,
option === state.theme
`spectrum--${option.class}`,
option.class === state.theme
)
// Ensure darkest is always added as this is the base class for custom
// themes
themeElement.classList.add("spectrum--darkest")
})
// Add base theme if required
const selectedTheme = Constants.Themes.find(x => x.class === state.theme)
if (selectedTheme?.base) {
themeElement.classList.add(`spectrum--${selectedTheme.base}`)
}
})
return store

View file

@ -1,7 +1,6 @@
<script>
import { Layout, Heading, Body, Divider, Label, Select } from "@budibase/bbui"
import { themeStore } from "builderStore"
import { capitalise } from "helpers"
import { Constants } from "@budibase/frontend-core"
</script>
@ -15,10 +14,11 @@
<div class="field">
<Label size="L">Builder theme</Label>
<Select
options={Constants.ThemeOptions}
options={Constants.Themes}
bind:value={$themeStore.theme}
placeholder={null}
getOptionLabel={capitalise}
getOptionLabel={x => x.name}
getOptionValue={x => x.class}
/>
</div>
</div>

View file

@ -99,11 +99,31 @@ export const SqlNumberTypeRangeMap = {
},
}
export const ThemeOptions = [
"lightest",
"light",
"dark",
"darkest",
"nord",
"midnight",
export const Themes = [
{
class: "lightest",
name: "Lightest",
},
{
class: "light",
name: "Light",
},
{
class: "dark",
name: "Dark",
},
{
class: "darkest",
name: "Darkest",
},
{
class: "nord",
name: "Nord",
base: "darkest",
},
{
class: "midnight",
name: "Midnight",
base: "darkest",
},
]