Allow user styles to override placeholder styles

This commit is contained in:
Andrew Kingston 2021-06-11 09:14:22 +01:00
parent 72dfa1ba1b
commit 7d87befe13
3 changed files with 11 additions and 12 deletions

View File

@ -7,6 +7,7 @@
import { builderStore } from "../store" import { builderStore } from "../store"
import { hashString } from "../utils/hash" import { hashString } from "../utils/hash"
import Manifest from "@budibase/standard-components/manifest.json" import Manifest from "@budibase/standard-components/manifest.json"
import { Placeholder } from "@budibase/standard-components"
export let instance = {} export let instance = {}
@ -127,7 +128,7 @@
<svelte:self instance={child} /> <svelte:self instance={child} />
{/each} {/each}
{:else if empty} {:else if empty}
<div class="placeholder">{name}</div> <Placeholder />
{/if} {/if}
</svelte:component> </svelte:component>
{/if} {/if}
@ -138,8 +139,4 @@
.component { .component {
display: contents; display: contents;
} }
.placeholder {
color: #888;
padding: 20px;
}
</style> </style>

View File

@ -25,9 +25,17 @@ export const styleable = (node, styles = {}) => {
// Creates event listeners and applies initial styles // Creates event listeners and applies initial styles
const setupStyles = (newStyles = {}) => { const setupStyles = (newStyles = {}) => {
// Use empty state styles as base styles if required, but let them, get
// overridden by any user specified styles
let baseStyles = {}
if (newStyles.empty) {
baseStyles.border = "2px dashed var(--grey-5)"
baseStyles.padding = "var(--spacing-l)"
}
const componentId = newStyles.id const componentId = newStyles.id
const customStyles = newStyles.custom || "" const customStyles = newStyles.custom || ""
const normalStyles = newStyles.normal || {} const normalStyles = { ...baseStyles, ...newStyles.normal }
const hoverStyles = { const hoverStyles = {
...normalStyles, ...normalStyles,
...(newStyles.hover || {}), ...(newStyles.hover || {}),
@ -35,11 +43,6 @@ export const styleable = (node, styles = {}) => {
// Applies a style string to a DOM node // Applies a style string to a DOM node
const applyStyles = styleString => { const applyStyles = styleString => {
// Apply empty border if required
if (newStyles.empty) {
styleString += "border: 2px dashed var(--grey-5);"
}
node.style = styleString node.style = styleString
node.dataset.componentId = componentId node.dataset.componentId = componentId
} }

View File

@ -17,6 +17,5 @@
div { div {
color: var(--grey-6); color: var(--grey-6);
font-size: var(--font-size-s); font-size: var(--font-size-s);
padding: var(--spacing-l);
} }
</style> </style>