Add button to reset styles

This commit is contained in:
Andrew Kingston 2021-01-05 11:48:14 +00:00
parent 19d71e318b
commit 57d69d1c9a
2 changed files with 9 additions and 4 deletions

View File

@ -32,6 +32,7 @@
const onStyleChanged = store.actions.components.updateStyle
const onCustomStyleChanged = store.actions.components.updateCustomStyle
const onResetStyles = store.actions.components.resetStyles
$: isComponentOrScreen =
$store.currentView === "component" ||
@ -98,7 +99,8 @@
{panelDefinition}
{componentInstance}
{onStyleChanged}
{onCustomStyleChanged} />
{onCustomStyleChanged}
{onResetStyles} />
{:else if selectedCategory.value === 'settings'}
<SettingsView
{componentInstance}

View File

@ -1,5 +1,5 @@
<script>
import { TextArea, DetailSummary } from "@budibase/bbui"
import { TextArea, DetailSummary, Button } from "@budibase/bbui"
import PropertyGroup from "./PropertyGroup.svelte"
import FlatButtonGroup from "./FlatButtonGroup.svelte"
@ -8,6 +8,7 @@
export let componentDefinition = {}
export let onStyleChanged = () => {}
export let onCustomStyleChanged = () => {}
export let onResetStyles = () => {}
let selectedCategory = "normal"
let propGroup = null
@ -46,16 +47,18 @@
on:open={() => (currentGroup = groupName)} />
{/each}
<DetailSummary
name="Custom Styles"
name={`Custom Styles${componentInstance._styles.custom ? ' *' : ''}`}
on:open={() => (currentGroup = 'custom')}
show={currentGroup === 'custom'}
thin>
<div class="custom-styles">
<TextArea
value={componentInstance._styles.custom}
on:change={event => onCustomStyleChanged(event.target.value)} />
on:change={event => onCustomStyleChanged(event.target.value)}
placeholder="Enter some CSS..." />
</div>
</DetailSummary>
<Button secondary wide on:click={onResetStyles}>Reset Styles</Button>
{:else}
<div class="no-design">
This component doesn't have any design properties.