Update cards block to be ejectable

This commit is contained in:
Andrew Kingston 2022-08-23 19:30:35 +01:00
parent ea9eb1c056
commit 5286cbf214
2 changed files with 57 additions and 92 deletions

View File

@ -7,6 +7,7 @@
export let type export let type
export let props export let props
export let styles export let styles
export let css
export let context export let context
export let order = 0 export let order = 0
@ -29,6 +30,7 @@
normal: { normal: {
...styles, ...styles,
}, },
custom: css,
}, },
...props, ...props,
} }

View File

@ -84,35 +84,61 @@
{#if schemaLoaded} {#if schemaLoaded}
<Block> <Block>
<div class="card-list" use:styleable={$component.styles}> <div use:styleable={$component.styles}>
<BlockComponent <BlockComponent
type="form" type="form"
bind:id={formId} bind:id={formId}
props={{ dataSource, disableValidation: true }} props={{ dataSource, disableValidation: true }}
> >
{#if title || enrichedSearchColumns?.length || showTitleButton} {#if title || enrichedSearchColumns?.length || showTitleButton}
<div class="header" class:mobile={$context.device.mobile}> <BlockComponent
<div class="title"> type="container"
<Heading>{title || ""}</Heading> props={{
</div> direction: "row",
<div class="controls"> hAlign: "stretch",
vAlign: "middle",
gap: "M",
wrap: true,
}}
styles={{
"margin-bottom": "20px",
}}
order={0}
>
<BlockComponent
type="heading"
props={{
text: title,
}}
order={0}
/>
<BlockComponent
type="container"
props={{
direction: "row",
hAlign: "left",
vAlign: "middle",
gap: "M",
wrap: true,
}}
order={1}
>
{#if enrichedSearchColumns?.length} {#if enrichedSearchColumns?.length}
<div {#each enrichedSearchColumns as column, idx}
class="search" <BlockComponent
style="--cols:{enrichedSearchColumns?.length}" type={column.componentType}
> props={{
{#each enrichedSearchColumns as column} field: column.name,
<BlockComponent placeholder: column.name,
type={column.componentType} text: column.name,
props={{ autoWidth: true,
field: column.name, }}
placeholder: column.name, order={idx}
text: column.name, styles={{
autoWidth: true, width: "192px",
}} }}
/> />
{/each} {/each}
</div>
{/if} {/if}
{#if showTitleButton} {#if showTitleButton}
<BlockComponent <BlockComponent
@ -122,10 +148,11 @@
text: titleButtonText, text: titleButtonText,
type: "cta", type: "cta",
}} }}
order={enrichedSearchColumns?.length ?? 0}
/> />
{/if} {/if}
</div> </BlockComponent>
</div> </BlockComponent>
{/if} {/if}
<BlockComponent <BlockComponent
type="dataprovider" type="dataprovider"
@ -138,6 +165,7 @@
paginate, paginate,
limit, limit,
}} }}
order={1}
> >
<BlockComponent <BlockComponent
type="repeater" type="repeater"
@ -151,10 +179,8 @@
gap: "M", gap: "M",
noRowsMessage: "No rows found", noRowsMessage: "No rows found",
}} }}
styles={{ css={`display: grid;\ngrid-template-columns: repeat(auto-fill, minmax(min(${cardWidth}px, 100%), 1fr));`}
display: "grid", order={0}
"grid-template-columns": `repeat(auto-fill, minmax(min(${cardWidth}px, 100%), 1fr))`,
}}
> >
<BlockComponent <BlockComponent
type="spectrumcard" type="spectrumcard"
@ -173,6 +199,7 @@
styles={{ styles={{
width: "auto", width: "auto",
}} }}
order={0}
/> />
</BlockComponent> </BlockComponent>
</BlockComponent> </BlockComponent>
@ -180,67 +207,3 @@
</div> </div>
</Block> </Block>
{/if} {/if}
<style>
.header {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
gap: 20px;
margin-bottom: 20px;
}
.title {
overflow: hidden;
}
.title :global(.spectrum-Heading) {
flex: 1 1 auto;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.controls {
flex: 0 1 auto;
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: center;
gap: 20px;
}
.controls :global(.spectrum-InputGroup .spectrum-InputGroup-input) {
width: 100%;
}
.search {
flex: 0 1 auto;
gap: 10px;
max-width: 100%;
display: grid;
grid-template-columns: repeat(var(--cols), minmax(120px, 200px));
}
.search :global(.spectrum-InputGroup) {
min-width: 0;
}
/* Mobile styles */
.mobile {
flex-direction: column;
justify-content: flex-start;
align-items: stretch;
}
.mobile .controls {
flex-direction: column-reverse;
justify-content: flex-start;
align-items: stretch;
}
.mobile .search {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: stretch;
position: relative;
width: 100%;
}
</style>