Improve grid height

This commit is contained in:
Andrew Kingston 2024-04-25 10:49:48 +01:00
parent 9c244f6645
commit 5cc2e90e4f
3 changed files with 50 additions and 36 deletions

View File

@ -101,8 +101,7 @@
<style> <style>
.wrapper { .wrapper {
padding-top: 400px; flex: 1 1 auto;
flex: 0 0 400px;
margin: -28px -40px -40px -40px; margin: -28px -40px -40px -40px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;

View File

@ -50,6 +50,8 @@
metadata: { dataSource: table }, metadata: { dataSource: table },
}, },
] ]
$: height = $component.styles?.normal?.height || "408px"
$: styles = getSanitisedStyles($component.styles)
// Provide additional data context for live binding eval // Provide additional data context for live binding eval
export const getAdditionalDataContext = () => { export const getAdditionalDataContext = () => {
@ -106,39 +108,48 @@
}, },
})) }))
} }
const getSanitisedStyles = styles => {
return {
...styles,
normal: {
...styles?.normal,
height: undefined,
},
}
}
</script> </script>
<div <div use:styleable={styles} class:in-builder={$builderStore.inBuilder}>
use:styleable={$component.styles} <span style="--height:{height};">
class:in-builder={$builderStore.inBuilder} <Provider {actions}>
> <Grid
<Provider {actions}> bind:this={grid}
<Grid datasource={table}
bind:this={grid} {API}
datasource={table} {stripeRows}
{API} {quiet}
{stripeRows} {initialFilter}
{quiet} {initialSortColumn}
{initialFilter} {initialSortOrder}
{initialSortColumn} {fixedRowHeight}
{initialSortOrder} {columnWhitelist}
{fixedRowHeight} {schemaOverrides}
{columnWhitelist} {repeat}
{schemaOverrides} canAddRows={allowAddRows}
{repeat} canEditRows={allowEditRows}
canAddRows={allowAddRows} canDeleteRows={allowDeleteRows}
canEditRows={allowEditRows} canEditColumns={false}
canDeleteRows={allowDeleteRows} canExpandRows={false}
canEditColumns={false} canSaveSchema={false}
canExpandRows={false} showControls={false}
canSaveSchema={false} notifySuccess={notificationStore.actions.success}
showControls={false} notifyError={notificationStore.actions.error}
notifySuccess={notificationStore.actions.success} buttons={enrichedButtons}
notifyError={notificationStore.actions.error} on:rowclick={e => onRowClick?.({ row: e.detail })}
buttons={enrichedButtons} />
on:rowclick={e => onRowClick?.({ row: e.detail })} </Provider>
/> </span>
</Provider>
</div> </div>
<style> <style>
@ -149,10 +160,14 @@
border: 1px solid var(--spectrum-global-color-gray-300); border: 1px solid var(--spectrum-global-color-gray-300);
border-radius: 4px; border-radius: 4px;
overflow: hidden; overflow: hidden;
/* min-height: 230px;*/
/* height: 410px;*/
} }
div.in-builder :global(*) { div.in-builder :global(*) {
pointer-events: none; pointer-events: none;
} }
span {
display: contents;
}
span :global(.grid) {
height: var(--height);
}
</style> </style>

View File

@ -20,7 +20,7 @@
$: style = buildStyles(minWidth, maxWidth, maxHeight) $: style = buildStyles(minWidth, maxWidth, maxHeight)
const buildStyles = (minWidth, maxWidth, maxHeight) => { const buildStyles = (minWidth, maxWidth, maxHeight) => {
let style = "min-height: 100px;" let style = ""
if (minWidth != null) { if (minWidth != null) {
style += `min-width: ${minWidth}px;` style += `min-width: ${minWidth}px;`
} }