Add wrap setting to containers and force repeaters to always wrap

This commit is contained in:
Andrew Kingston 2021-06-24 12:15:04 +01:00
parent aecebc96a7
commit 13f9b8b532
3 changed files with 47 additions and 4 deletions

View File

@ -123,7 +123,7 @@
"type": "select", "type": "select",
"label": "Vert. Align", "label": "Vert. Align",
"key": "vAlign", "key": "vAlign",
"showInBar": "true", "showInBar": true,
"barStyle": "buttons", "barStyle": "buttons",
"options": [ "options": [
{ {
@ -200,6 +200,14 @@
} }
], ],
"defaultValue": "M" "defaultValue": "M"
},
{
"type": "boolean",
"label": "Wrap",
"key": "wrap",
"showInBar": true,
"barIcon": "ModernGridView",
"barTitle": "Wrap"
} }
] ]
}, },
@ -290,6 +298,7 @@
"label": "Direction", "label": "Direction",
"key": "direction", "key": "direction",
"showInBar": true, "showInBar": true,
"barStyle": "buttons",
"options": [ "options": [
{ {
"label": "Column", "label": "Column",
@ -311,6 +320,7 @@
"label": "Horiz. Align", "label": "Horiz. Align",
"key": "hAlign", "key": "hAlign",
"showInBar": true, "showInBar": true,
"barStyle": "buttons",
"options": [ "options": [
{ {
"label": "Left", "label": "Left",
@ -343,7 +353,8 @@
"type": "select", "type": "select",
"label": "Vert. Align", "label": "Vert. Align",
"key": "vAlign", "key": "vAlign",
"showInBar": "true", "showInBar": true,
"barStyle": "buttons",
"options": [ "options": [
{ {
"label": "Top", "label": "Top",
@ -371,6 +382,32 @@
} }
], ],
"defaultValue": "top" "defaultValue": "top"
},
{
"type": "select",
"label": "Gap",
"key": "gap",
"showInBar": true,
"barStyle": "picker",
"options": [
{
"label": "None",
"value": "N"
},
{
"label": "Small",
"value": "S"
},
{
"label": "Medium",
"value": "M"
},
{
"label": "Large",
"value": "L"
}
],
"defaultValue": "M"
} }
], ],
"context": { "context": {

View File

@ -9,6 +9,7 @@
export let vAlign export let vAlign
export let size export let size
export let gap export let gap
export let wrap
$: directionClass = direction ? `valid-container direction-${direction}` : "" $: directionClass = direction ? `valid-container direction-${direction}` : ""
$: hAlignClass = hAlign ? `hAlign-${hAlign}` : "" $: hAlignClass = hAlign ? `hAlign-${hAlign}` : ""
@ -24,7 +25,7 @@
].join(" ") ].join(" ")
</script> </script>
<div class={classNames} use:styleable={$component.styles}> <div class={classNames} use:styleable={$component.styles} class:wrap>
<slot /> <slot />
</div> </div>
@ -99,4 +100,8 @@
.gap-L { .gap-L {
gap: 32px; gap: 32px;
} }
.wrap {
flex-wrap: wrap;
}
</style> </style>

View File

@ -8,6 +8,7 @@
export let direction export let direction
export let hAlign export let hAlign
export let vAlign export let vAlign
export let gap
const { Provider } = getContext("sdk") const { Provider } = getContext("sdk")
const component = getContext("component") const component = getContext("component")
@ -16,7 +17,7 @@
$: loaded = dataProvider?.loaded ?? true $: loaded = dataProvider?.loaded ?? true
</script> </script>
<Container {direction} {hAlign} {vAlign}> <Container {direction} {hAlign} {vAlign} {gap} wrap>
{#if $component.empty} {#if $component.empty}
<Placeholder /> <Placeholder />
{:else if rows.length > 0} {:else if rows.length > 0}