1
0
Fork 0
mirror of synced 2024-07-14 18:55:45 +12:00

Update validation editor setting to be full width and have descriptive text

This commit is contained in:
Andrew Kingston 2023-07-18 08:56:16 +01:00
parent 1fbff5c6ef
commit 7c7d909d81

View file

@ -8,16 +8,29 @@
export let componentDefinition
export let type
const dispatch = createEventDispatcher()
let drawer
const dispatch = createEventDispatcher()
$: text = getText(value)
const save = () => {
dispatch("change", value)
drawer.hide()
}
const getText = rules => {
if (!rules?.length) {
return "No rules set"
} else {
return `${rules.length} rule${rules.length === 1 ? "" : "s"} set`
}
}
</script>
<ActionButton on:click={drawer.show}>Configure validation</ActionButton>
<div class="validation-editor">
<ActionButton on:click={drawer.show}>{text}</ActionButton>
</div>
<Drawer bind:this={drawer} title="Validation Rules">
<svelte:fragment slot="description">
Configure validation rules for this field.
@ -31,3 +44,9 @@
{componentDefinition}
/>
</Drawer>
<style>
.validation-editor :global(.spectrum-ActionButton) {
width: 100%;
}
</style>