diff --git a/packages/client/src/components/Component.svelte b/packages/client/src/components/Component.svelte
index a1550cf72f..582392babe 100644
--- a/packages/client/src/components/Component.svelte
+++ b/packages/client/src/components/Component.svelte
@@ -23,6 +23,7 @@
import Manifest from "manifest.json"
import { getActiveConditions, reduceConditionActions } from "utils/conditions"
import Placeholder from "components/app/Placeholder.svelte"
+ import ComponentPlaceholder from "components/app/ComponentPlaceholder.svelte"
export let instance = {}
export let isLayout = false
@@ -81,6 +82,7 @@
let definition
let settingsDefinition
let settingsDefinitionMap
+ let missingRequiredSettings = false
// Set up initial state for each new component instance
$: initialise(instance)
@@ -102,6 +104,7 @@
$: editable = !!definition?.editable
$: hasChildren = !!definition?.hasChildren
$: showEmptyState = definition?.showEmptyState !== false
+ $: hasMissingRequiredSettings = missingRequiredSettings?.length > 0
// Interactive components can be selected, dragged and highlighted inside
// the builder preview
@@ -155,6 +158,7 @@
name,
editing,
type: instance._component,
+ missingRequiredSettings,
})
const initialise = instance => {
@@ -201,6 +205,14 @@
staticSettings = instanceSettings.staticSettings
dynamicSettings = instanceSettings.dynamicSettings
+ // Check if we have any missing required settings
+ missingRequiredSettings = settingsDefinition.filter(setting => {
+ return (
+ setting.required &&
+ (instance[setting.key] == null || instance[setting.key] === "")
+ )
+ })
+
// Force an initial enrichment of the new settings
enrichComponentSettings(get(context), settingsDefinitionMap, {
force: true,
@@ -414,17 +426,21 @@
data-id={id}
data-name={name}
>
-
- {#if children.length}
- {#each children as child (child._id)}
-
- {/each}
- {:else if emptyState}
-
- {:else if isBlock}
-
- {/if}
-
+ {#if hasMissingRequiredSettings}
+
+ {:else}
+
+ {#if children.length}
+ {#each children as child (child._id)}
+
+ {/each}
+ {:else if emptyState}
+
+ {:else if isBlock}
+
+ {/if}
+
+ {/if}
{/if}
diff --git a/packages/client/src/components/app/ComponentPlaceholder.svelte b/packages/client/src/components/app/ComponentPlaceholder.svelte
new file mode 100644
index 0000000000..e8164fdb8b
--- /dev/null
+++ b/packages/client/src/components/app/ComponentPlaceholder.svelte
@@ -0,0 +1,50 @@
+
+
+{#if $builderStore.inBuilder && focusSetting}
+
+
+
+ Add the {focusSetting?.label} setting to start using your component
+
+
+ {
+ builderStore.actions.setFocus([
+ {
+ location: "component_settings",
+ key: focusSetting.key,
+ target: $component.id,
+ },
+ ])
+ }}
+ >
+ Show me
+
+
+
+{/if}
+
+
diff --git a/packages/client/src/components/app/Placeholder.svelte b/packages/client/src/components/app/Placeholder.svelte
index 4fb182ff12..203071e0b1 100644
--- a/packages/client/src/components/app/Placeholder.svelte
+++ b/packages/client/src/components/app/Placeholder.svelte
@@ -1,67 +1,15 @@
{#if $builderStore.inBuilder}
-
- {#if componentInstance && focus_setting}
-
-
- Add the {focus_setting?.label} setting to start using your
- component
-
- {
- builderStore.actions.setFocus([
- {
- location: "component_settings",
- key: focus_setting.key,
- target: $component.id,
- },
- ])
- }}
- >
- Show me
-
-
- {:else}
- {text || $component.name || "Placeholder"}
- {/if}
+
+ {text || $component.name || "Placeholder"}
{/if}
@@ -69,18 +17,5 @@
div {
color: var(--spectrum-global-color-gray-600);
font-size: var(--font-size-s);
- padding: var(--spacing-xs);
- }
- :global(div.placeholder_wrap mark) {
- background-color: var(--spectrum-global-color-gray-400);
- padding: 0px 2px;
- border-radius: 2px;
- }
- :global(div.placeholder_wrap .showMe) {
- cursor: pointer;
- }
- :global(div.placeholder_wrap .showMe:hover) {
- text-decoration: underline;
- cursor: pointer;
}