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