Skip to content

Commit

Permalink
fix(Table): "no records" label is always visible (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinFabre-ods authored Aug 26, 2024
1 parent 2f2b663 commit b9987af
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
15 changes: 3 additions & 12 deletions packages/visualizations/src/components/Table/Body.svelte
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
<script lang="ts">
import type { Column, TableData } from './types';
import Cell, { LoadingCell } from './Cell';
import EmptyRow from './EmptyRow.svelte';
export let loadingRowsNumber: number | null;
export let columns: Column[];
export let records: TableData | undefined;
export let emptyStateLabel = 'No records found...';
export let emptyStateLabel: string | undefined;
</script>

<tbody>
{#if records?.length === 0 && !loadingRowsNumber}
<tr>
<td colspan={columns.length}>
<em>{emptyStateLabel}</em>
</td>
</tr>
<EmptyRow label={emptyStateLabel} />
{/if}
{#if loadingRowsNumber}
{#each Array(loadingRowsNumber) as _}
Expand Down Expand Up @@ -43,10 +40,4 @@
:global(.ods-dataviz--default) tr:last-child {
border-bottom: none;
}
:global(.ods-dataviz--default) em {
text-align: center;
width: 100%;
display: block;
}
</style>
26 changes: 26 additions & 0 deletions packages/visualizations/src/components/Table/EmptyRow.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<script lang="ts">
export let label = 'No records found...';
</script>

<tr>
<td>
<em>{label}</em>
</td>
</tr>

<style lang="scss">
$row-height: 48px;
tr {
height: $row-height;
}
td {
box-sizing: border-box;
position: absolute;
left: 0;
right: 0;
height: $row-height;
display: flex;
align-items: center;
justify-content: center;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
margin-bottom: var(--spacing-100);
overflow: hidden;
background-color: var(--background-color);
position: relative;
}
:global(.ods-dataviz--default) div {
max-width: 100%;
Expand Down

1 comment on commit b9987af

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage for this commit

94.64%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   index.ts100%100%100%100%
src/client
   error.ts100%100%100%100%
   index.ts84.14%74.03%100%95.31%102–103, 124, 13, 146, 148, 148–149, 15, 15, 151, 162, 169, 169, 17, 17, 171, 176, 179, 182, 184, 52, 82
   types.ts100%100%100%100%
src/odsql
   clauses.ts82.61%71.43%80%90.91%14, 32, 42
   index.ts92.05%83.72%95.74%94.19%111, 146, 25, 28, 56–57, 57, 57–58, 68, 78–79

Please sign in to comment.