Add button to reset theme to default and fix determination of theme
This commit is contained in:
parent
b11deece29
commit
44dd731be8
|
@ -24,7 +24,6 @@
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Select
|
<Select
|
||||||
autoWidth
|
|
||||||
value={$store.theme}
|
value={$store.theme}
|
||||||
options={themeOptions}
|
options={themeOptions}
|
||||||
placeholder={null}
|
placeholder={null}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
ColorPicker,
|
ColorPicker,
|
||||||
Label,
|
Label,
|
||||||
Select,
|
Select,
|
||||||
|
Button,
|
||||||
} from "@budibase/bbui"
|
} from "@budibase/bbui"
|
||||||
import { store } from "builderStore"
|
import { store } from "builderStore"
|
||||||
import AppThemeSelect from "./AppThemeSelect.svelte"
|
import AppThemeSelect from "./AppThemeSelect.svelte"
|
||||||
|
@ -49,6 +50,10 @@
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const resetTheme = () => {
|
||||||
|
store.actions.customTheme.save(null)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
@ -68,14 +73,16 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="setting">
|
<div class="setting">
|
||||||
<Label size="L">Button roundness</Label>
|
<Label size="L">Button roundness</Label>
|
||||||
|
<div class="select-wrapper">
|
||||||
<Select
|
<Select
|
||||||
autoWidth
|
placeholder={null}
|
||||||
value={$store.customTheme?.buttonBorderRadius ||
|
value={$store.customTheme?.buttonBorderRadius ||
|
||||||
defaultTheme.buttonBorderRadius}
|
defaultTheme.buttonBorderRadius}
|
||||||
on:change={updateProperty("buttonBorderRadius")}
|
on:change={updateProperty("buttonBorderRadius")}
|
||||||
options={buttonBorderRadiusOptions}
|
options={buttonBorderRadiusOptions}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="setting">
|
<div class="setting">
|
||||||
<Label size="L">Primary color</Label>
|
<Label size="L">Primary color</Label>
|
||||||
<ColorPicker
|
<ColorPicker
|
||||||
|
@ -111,6 +118,9 @@
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
<div slot="footer">
|
||||||
|
<Button secondary quiet on:click={resetTheme}>Reset</Button>
|
||||||
|
</div>
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
|
@ -123,11 +133,8 @@
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding-bottom: var(--spectrum-global-dimension-static-size-200);
|
|
||||||
border-bottom: var(--border-light);
|
|
||||||
}
|
}
|
||||||
.setting:last-child {
|
.select-wrapper {
|
||||||
padding-bottom: 0;
|
width: 100px;
|
||||||
border-bottom: none;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -18,12 +18,17 @@ const createThemeStore = () => {
|
||||||
const store = derived(
|
const store = derived(
|
||||||
[builderStore, appStore],
|
[builderStore, appStore],
|
||||||
([$builderStore, $appStore]) => {
|
([$builderStore, $appStore]) => {
|
||||||
const theme =
|
let theme = $appStore.application?.theme
|
||||||
$builderStore.theme || $appStore.application?.theme || defaultTheme
|
let customTheme = $appStore.application?.customTheme
|
||||||
|
if ($builderStore.inBuilder) {
|
||||||
|
theme = $builderStore.theme
|
||||||
|
customTheme = $builderStore.customTheme
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure theme is set
|
||||||
|
theme = theme || defaultTheme
|
||||||
|
|
||||||
// Delete and nullish keys from the custom theme
|
// Delete and nullish keys from the custom theme
|
||||||
let customTheme =
|
|
||||||
$builderStore.customTheme || $appStore.application?.customTheme
|
|
||||||
if (customTheme) {
|
if (customTheme) {
|
||||||
Object.entries(customTheme).forEach(([key, value]) => {
|
Object.entries(customTheme).forEach(([key, value]) => {
|
||||||
if (value == null || value === "") {
|
if (value == null || value === "") {
|
||||||
|
|
Loading…
Reference in New Issue