Show empty screen placeholder with a CTA to add a component
This commit is contained in:
parent
d059433f1f
commit
6e83c96236
|
@ -174,6 +174,8 @@
|
|||
if (!$isActive("./navigation")) {
|
||||
$goto("./navigation")
|
||||
}
|
||||
} else if (type === "request-add-component") {
|
||||
$goto("./components/new")
|
||||
} else {
|
||||
console.warn(`Client sent unknown event type: ${type}`)
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
import { Helpers } from "@budibase/bbui"
|
||||
import { getActiveConditions, reduceConditionActions } from "utils/conditions"
|
||||
import Placeholder from "components/app/Placeholder.svelte"
|
||||
import ScreenPlaceholder from "components/app/ScreenPlaceholder.svelte"
|
||||
|
||||
export let instance = {}
|
||||
export let isLayout = false
|
||||
|
@ -428,7 +429,11 @@
|
|||
<svelte:self instance={child} />
|
||||
{/each}
|
||||
{:else if emptyState}
|
||||
<Placeholder />
|
||||
{#if isScreen}
|
||||
<ScreenPlaceholder />
|
||||
{:else}
|
||||
<Placeholder />
|
||||
{/if}
|
||||
{:else if isBlock}
|
||||
<slot />
|
||||
{/if}
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<script>
|
||||
import { getContext } from "svelte"
|
||||
import { Heading, Body, Button } from "@budibase/bbui"
|
||||
|
||||
const { builderStore } = getContext("sdk")
|
||||
</script>
|
||||
|
||||
{#if $builderStore.inBuilder}
|
||||
<div class="placeholder">
|
||||
<Heading size="L">Your screen is empty</Heading>
|
||||
<Body>Bring your app to life by adding some components!</Body>
|
||||
<Button cta icon="Add" on:click={builderStore.actions.requestAddComponent}
|
||||
>Add component</Button
|
||||
>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.placeholder {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: var(--spacing-s);
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
.placeholder :global(.spectrum-Button) {
|
||||
margin-top: var(--spacing-m);
|
||||
}
|
||||
</style>
|
|
@ -78,6 +78,9 @@ const createBuilderStore = () => {
|
|||
clickNav: () => {
|
||||
dispatchEvent("click-nav")
|
||||
},
|
||||
requestAddComponent: () => {
|
||||
dispatchEvent("request-add-component")
|
||||
},
|
||||
}
|
||||
return {
|
||||
...store,
|
||||
|
|
Loading…
Reference in New Issue