Update collapsed button groups to support alignment

This commit is contained in:
Andrew Kingston 2024-09-04 11:12:26 +01:00
parent 07b9ac1a37
commit b60923f929
No known key found for this signature in database
2 changed files with 28 additions and 39 deletions

View File

@ -517,11 +517,7 @@
"barTitle": "Align stretched horizontally" "barTitle": "Align stretched horizontally"
} }
], ],
"defaultValue": "left", "defaultValue": "left"
"dependsOn": {
"setting": "collapsed",
"invert": true
}
}, },
{ {
"type": "select", "type": "select",
@ -555,11 +551,7 @@
"barTitle": "Align stretched vertically" "barTitle": "Align stretched vertically"
} }
], ],
"defaultValue": "top", "defaultValue": "top"
"dependsOn": {
"setting": "collapsed",
"invert": true
}
}, },
{ {
"type": "select", "type": "select",

View File

@ -12,8 +12,7 @@
export let collapsed = false export let collapsed = false
export let collapsedText = "Action" export let collapsedText = "Action"
const { styleable, enrichButtonActions } = getContext("sdk") const { enrichButtonActions } = getContext("sdk")
const component = getContext("component")
const context = getContext("context") const context = getContext("context")
$: collapsedButtons = collapsed ? makeCollapsed(buttons) : null $: collapsedButtons = collapsed ? makeCollapsed(buttons) : null
@ -29,30 +28,28 @@
} }
</script> </script>
{#if collapsed} <Block>
<div use:styleable={$component.styles}> <BlockComponent
<CollapsedButtonGroup type="container"
text={collapsedText || "Action"} props={{
buttons={collapsedButtons} direction,
/> hAlign,
</div> vAlign,
{:else} gap,
<Block> wrap: true,
<BlockComponent }}
type="container" styles={{
props={{ normal: {
direction, height: "100%",
hAlign, },
vAlign, }}
gap, >
wrap: true, {#if collapsed}
}} <CollapsedButtonGroup
styles={{ text={collapsedText || "Action"}
normal: { buttons={collapsedButtons}
height: "100%", />
}, {:else}
}}
>
{#each buttons as { text, type, quiet, disabled, onClick, size, icon, gap }} {#each buttons as { text, type, quiet, disabled, onClick, size, icon, gap }}
<BlockComponent <BlockComponent
type="button" type="button"
@ -68,6 +65,6 @@
}} }}
/> />
{/each} {/each}
</BlockComponent> {/if}
</Block> </BlockComponent>
{/if} </Block>