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