Add custom theme options for button roundedness and header color
This commit is contained in:
parent
8ab0fc2d7f
commit
d1e3dda05f
|
@ -24,6 +24,7 @@
|
|||
|
||||
<div>
|
||||
<Select
|
||||
autoWidth
|
||||
value={$store.theme}
|
||||
options={themeOptions}
|
||||
placeholder={null}
|
||||
|
@ -34,6 +35,5 @@
|
|||
<style>
|
||||
div {
|
||||
width: 100px;
|
||||
padding-right: 8px;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -7,16 +7,39 @@
|
|||
Layout,
|
||||
ColorPicker,
|
||||
Label,
|
||||
Select,
|
||||
} from "@budibase/bbui"
|
||||
import { store } from "builderStore"
|
||||
import AppThemeSelect from "./AppThemeSelect.svelte"
|
||||
|
||||
let modal
|
||||
|
||||
const defaultTheme = {
|
||||
primaryColor: "var(--spectrum-global-color-blue-600)",
|
||||
primaryColorHover: "var(--spectrum-global-color-blue-500)",
|
||||
buttonBorderRadius: "16px",
|
||||
navBackground: "var(--spectrum-global-color-gray-100)",
|
||||
}
|
||||
|
||||
const buttonBorderRadiusOptions = [
|
||||
{
|
||||
label: "None",
|
||||
value: "0",
|
||||
},
|
||||
{
|
||||
label: "Small",
|
||||
value: "4px",
|
||||
},
|
||||
{
|
||||
label: "Medium",
|
||||
value: "8px",
|
||||
},
|
||||
{
|
||||
label: "Large",
|
||||
value: "16px",
|
||||
},
|
||||
]
|
||||
|
||||
const updateProperty = property => {
|
||||
return e => {
|
||||
store.actions.customTheme.save({
|
||||
|
@ -28,7 +51,7 @@
|
|||
</script>
|
||||
|
||||
<div class="container">
|
||||
<ActionButton icon="Brush" on:click={modal.show}>Edit</ActionButton>
|
||||
<ActionButton icon="Brush" on:click={modal.show}>Theme</ActionButton>
|
||||
</div>
|
||||
<Modal bind:this={modal}>
|
||||
<ModalContent
|
||||
|
@ -37,9 +60,23 @@
|
|||
showCloseIcon={false}
|
||||
title="Theme settings"
|
||||
>
|
||||
<Layout noPadding gap="XS">
|
||||
<Layout noPadding gap="S">
|
||||
<div class="setting">
|
||||
<Label size="L">Primary Color</Label>
|
||||
<Label size="L">Theme</Label>
|
||||
<AppThemeSelect />
|
||||
</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>
|
||||
<div class="setting">
|
||||
<Label size="L">Primary color</Label>
|
||||
<ColorPicker
|
||||
spectrumTheme={$store.theme}
|
||||
value={$store.customTheme?.primaryColor || defaultTheme.primaryColor}
|
||||
|
@ -47,7 +84,7 @@
|
|||
/>
|
||||
</div>
|
||||
<div class="setting">
|
||||
<Label size="L">Primary Color (Hover)</Label>
|
||||
<Label size="L">Primary color (hover)</Label>
|
||||
<ColorPicker
|
||||
spectrumTheme={$store.theme}
|
||||
value={$store.customTheme?.primaryColorHover ||
|
||||
|
@ -55,6 +92,15 @@
|
|||
on:change={updateProperty("primaryColorHover")}
|
||||
/>
|
||||
</div>
|
||||
<div class="setting">
|
||||
<Label size="L">Navigation bar background</Label>
|
||||
<ColorPicker
|
||||
spectrumTheme={$store.theme}
|
||||
value={$store.customTheme?.navBackground ||
|
||||
defaultTheme.navBackground}
|
||||
on:change={updateProperty("navBackground")}
|
||||
/>
|
||||
</div>
|
||||
</Layout>
|
||||
</ModalContent>
|
||||
</Modal>
|
||||
|
|
|
@ -151,11 +151,10 @@
|
|||
{#if $currentAsset}
|
||||
<div class="preview-header">
|
||||
<ComponentSelectionList />
|
||||
{#if $store.clientFeatures.spectrumThemes}
|
||||
<AppThemeSelect />
|
||||
{/if}
|
||||
{#if $store.clientFeatures.customThemes}
|
||||
<ThemeEditor />
|
||||
{:else if $store.clientFeatures.spectrumThemes}
|
||||
<AppThemeSelect />
|
||||
{/if}
|
||||
</div>
|
||||
<div class="preview-content">
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
/* Buttons */
|
||||
--spectrum-semantic-cta-color-background-default: var(--primaryColor);
|
||||
--spectrum-semantic-cta-color-background-hover: var(--primaryColorHover);
|
||||
--spectrum-alias-item-rounded-border-radius-m: var(--buttonBorderRadius);
|
||||
|
||||
/* Loading spinners */
|
||||
--spectrum-progresscircle-medium-track-fill-color: var(--primaryColor);
|
||||
|
|
|
@ -142,7 +142,7 @@
|
|||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: stretch;
|
||||
background: var(--spectrum-alias-background-color-primary);
|
||||
background: var(--navBackground);
|
||||
z-index: 2;
|
||||
border-bottom: 1px solid var(--spectrum-global-color-gray-300);
|
||||
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.05);
|
||||
|
|
|
@ -9,6 +9,8 @@ const defaultTheme = "spectrum--light"
|
|||
const defaultCustomTheme = {
|
||||
primaryColor: "var(--spectrum-glo" + "bal-color-blue-600)",
|
||||
primaryColorHover: "var(--spectrum-glo" + "bal-color-blue-500)",
|
||||
buttonBorderRadius: "16px",
|
||||
navBackground: "var(--spectrum-glo" + "bal-color-gray-100)",
|
||||
}
|
||||
|
||||
const createThemeStore = () => {
|
||||
|
@ -17,14 +19,30 @@ const createThemeStore = () => {
|
|||
([$builderStore, $appStore]) => {
|
||||
const theme =
|
||||
$builderStore.theme || $appStore.application?.theme || defaultTheme
|
||||
const customTheme = {
|
||||
...defaultCustomTheme,
|
||||
...($builderStore.customTheme || $appStore.application?.customTheme),
|
||||
|
||||
// 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 === "") {
|
||||
delete customTheme[key]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Merge custom theme with defaults
|
||||
customTheme = {
|
||||
...defaultCustomTheme,
|
||||
...customTheme,
|
||||
}
|
||||
|
||||
// Build CSS string setting all custom variables
|
||||
let customThemeCss = ""
|
||||
Object.entries(customTheme).forEach(([key, value]) => {
|
||||
customThemeCss += `--${key}:${value};`
|
||||
})
|
||||
|
||||
return {
|
||||
theme,
|
||||
customTheme,
|
||||
|
|
Loading…
Reference in New Issue