Limit grid buttons at 3

This commit is contained in:
Andrew Kingston 2023-11-07 14:55:02 +00:00
parent a343572815
commit ace3b69971
2 changed files with 16 additions and 5 deletions

View File

@ -12,6 +12,7 @@
export let value export let value
export let key export let key
export let nested export let nested
export let max
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
@ -30,6 +31,7 @@
removeButton, removeButton,
nested, nested,
} }
$: canAddButtons = max == null || buttonList.length < max
const sanitizeValue = val => { const sanitizeValue = val => {
return val?.map(button => { return val?.map(button => {
@ -97,7 +99,12 @@
/> />
{/if} {/if}
<div class="list-footer" on:click={addButton} class:empty={!buttonCount}> <div
class="list-footer"
class:disabled={!canAddButtons}
on:click={addButton}
class:empty={!buttonCount}
>
<div class="add-button">Add button</div> <div class="add-button">Add button</div>
</div> </div>
</div> </div>
@ -132,15 +139,18 @@
.list-footer.empty { .list-footer.empty {
border-radius: 4px; border-radius: 4px;
} }
.list-footer.disabled {
.add-button { color: var(--spectrum-global-color-gray-500);
margin: var(--spacing-s); pointer-events: none;
} }
.list-footer:hover { .list-footer:hover {
background-color: var( background-color: var(
--spectrum-table-row-background-color-hover, --spectrum-table-row-background-color-hover,
var(--spectrum-alias-highlight-hover) var(--spectrum-alias-highlight-hover)
); );
} }
.add-button {
margin: var(--spacing-s);
}
</style> </style>

View File

@ -6348,6 +6348,7 @@
"type": "buttonConfiguration", "type": "buttonConfiguration",
"key": "buttons", "key": "buttons",
"nested": true, "nested": true,
"max": 3,
"context": [ "context": [
{ {
"label": "Clicked row", "label": "Clicked row",