From 984b092c3280ee398df792b9d4942c1f98c97a64 Mon Sep 17 00:00:00 2001 From: Sam Chau Date: Thu, 29 Jan 2026 01:11:59 +1030 Subject: [PATCH] style(ui): responsive card based styling for table comps --- .../client/ui/table/ExpandableTable.svelte | 386 +++++++++++------- src/lib/client/ui/table/Table.svelte | 320 ++++++++++----- 2 files changed, 455 insertions(+), 251 deletions(-) diff --git a/src/lib/client/ui/table/ExpandableTable.svelte b/src/lib/client/ui/table/ExpandableTable.svelte index fe27659..d464b60 100644 --- a/src/lib/client/ui/table/ExpandableTable.svelte +++ b/src/lib/client/ui/table/ExpandableTable.svelte @@ -1,4 +1,5 @@ -
- - - - - {#if chevronPosition === 'left'} - - {/if} - {#each columns as column} - - {/each} - {#if $$slots.actions} - - {/if} - - {#if chevronPosition === 'right'} - - {/if} - - - - {#if sortedData.length === 0} - - - - {:else} - {#each sortedData as row, index} - {@const rowId = getRowId(row)} - - - +
+ {#if sortedData.length === 0} +
+ {emptyMessage} +
+ {:else} + {#each sortedData as row, index} + {@const rowId = getRowId(row)} +
+ +
- {/if} - - {#each columns as column} - - {/each} - {#if $$slots.actions} - - {/if} - - - {#if chevronPosition === 'right'} - - {/if} - + {#if expandedRows.has(rowId)} + + {:else} + + {/if} + + - + + {#if columns.length > 1} +
+ {#each columns.slice(1) as column, colIndex} +
+ {column.header} + + + {getCellValue(row, column.key)} + + +
+ {/each} +
+ {/if} + + + {#if expandedRows.has(rowId)} -
- - + + {/if} - {/each} - {/if} - -
- {#if column.sortable} - - {:else} - {column.header} - {/if} - - Actions -
- {emptyMessage} -
- {#if expandedRows.has(rowId)} - - {:else} - - {/if} - - - {getCellValue(row, column.key)} + +
+
+ + {getCellValue(row, columns[0].key)} -
- - - {#if expandedRows.has(rowId)} - - {:else} - + +
+ {#if $$slots.actions} + +
+ +
{/if} -
-
- - -
- No additional details -
-
+
+ +
+ No additional details
-
-
+ + {/each} + {/if} + +{:else} + +
+ + + + + {#if chevronPosition === 'left'} + + {/if} + {#each columns as column} + + {/each} + {#if $$slots.actions} + + {/if} + + {#if chevronPosition === 'right'} + + {/if} + + + + {#if sortedData.length === 0} + + + + {:else} + {#each sortedData as row, index} + {@const rowId = getRowId(row)} + + + toggleRow(rowId)} + > + + {#if chevronPosition === 'left'} + + {/if} + + {#each columns as column} + + {/each} + {#if $$slots.actions} + + {/if} + + + {#if chevronPosition === 'right'} + + {/if} + + + + {#if expandedRows.has(rowId)} + + + + {/if} + {/each} + {/if} + +
+ {#if column.sortable} + + {:else} + {column.header} + {/if} + + Actions +
+ {emptyMessage} +
+ {#if expandedRows.has(rowId)} + + {:else} + + {/if} + + + {getCellValue(row, column.key)} + + + + + {#if expandedRows.has(rowId)} + + {:else} + + {/if} +
+
+ + +
+ No additional details +
+
+
+
+
+{/if} diff --git a/src/lib/client/ui/table/Table.svelte b/src/lib/client/ui/table/Table.svelte index f2fee30..d6f255d 100644 --- a/src/lib/client/ui/table/Table.svelte +++ b/src/lib/client/ui/table/Table.svelte @@ -1,4 +1,5 @@ -
- - - - - {#each columns as column} - - {/each} - - {#if $$slots.actions} - - {/if} - - + - - - {#if sortedData.length === 0} + + {#if columns.length > 1} +
+ {#each columns.slice(1) as column, colIndex} +
+ {column.header} + + {#if column.cell} + {@const rendered = column.cell(row)} + {#if typeof rendered === 'string'} + {rendered} + {:else if typeof rendered === 'object' && 'html' in rendered} + {@html rendered.html} + {:else} + + {/if} + {:else} + + {getCellValue(row, column.key)} + + {/if} + +
+ {/each} +
+ {/if} + + {/each} + {/if} + +{:else} + +
+
- {#if column.sortable} - - {:else} -
- {#if column.headerIcon} - - {/if} - {column.header} + {:else} + + {getCellValue(row, columns[0].key)} + + {/if} +
+ {#if $$slots.actions} +
+
{/if} -
- {actionsHeader} -
+ + - - - {:else} - {#each sortedData as row, rowIndex} - onRowClick && onRowClick(row)} - > - {#each columns as column} - + {/each} + + {#if $$slots.actions} + + {/if} + + - - {#if $$slots.actions} - - {/if} + + + {#if sortedData.length === 0} + + - {/each} - {/if} - -
- {emptyMessage} -
- {#if column.cell} - {@const rendered = column.cell(row)} - {#if typeof rendered === 'string'} - {rendered} - {:else if typeof rendered === 'object' && 'html' in rendered} - {@html rendered.html} - {:else} - + {#each columns as column} + + {#if column.sortable} + + {:else} +
+ {#if column.headerIcon} + + {/if} + {column.header} +
+ {/if} +
+ {actionsHeader} +
- -
+ {emptyMessage} +
-
+ {:else} + {#each sortedData as row, rowIndex} + onRowClick && onRowClick(row)} + > + {#each columns as column} + + {#if column.cell} + {@const rendered = column.cell(row)} + {#if typeof rendered === 'string'} + {rendered} + {:else if typeof rendered === 'object' && 'html' in rendered} + {@html rendered.html} + {:else} + + {/if} + {:else} + + {getCellValue(row, column.key)} + + {/if} + + {/each} + + + {#if $$slots.actions} + + + + {/if} + + {/each} + {/if} + + + +{/if}