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,24 +84,47 @@
{#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",
{#if enrichedSearchColumns?.length} vAlign: "middle",
<div gap: "M",
class="search" wrap: true,
style="--cols:{enrichedSearchColumns?.length}" }}
styles={{
"margin-bottom": "20px",
}}
order={0}
> >
{#each enrichedSearchColumns as column} <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}
{#each enrichedSearchColumns as column, idx}
<BlockComponent <BlockComponent
type={column.componentType} type={column.componentType}
props={{ props={{
@ -110,9 +133,12 @@
text: column.name, text: column.name,
autoWidth: true, autoWidth: true,
}} }}
order={idx}
styles={{
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>