From bf25f79c1926656b33a4f7bac01ed5aa224ae83b Mon Sep 17 00:00:00 2001 From: palewire Date: Sun, 2 Apr 2023 08:04:45 -0400 Subject: [PATCH] Switched some basic styles and expanded the metadata we allow --- src/components/Table/Table.stories.svelte | 4 +- src/components/Table/Table.svelte | 107 ++++++++++++------ src/components/Table/stories/docs/metadata.md | 5 +- 3 files changed, 80 insertions(+), 36 deletions(-) diff --git a/src/components/Table/Table.stories.svelte b/src/components/Table/Table.stories.svelte index 2ee9951c..6539ea26 100644 --- a/src/components/Table/Table.stories.svelte +++ b/src/components/Table/Table.stories.svelte @@ -62,7 +62,9 @@ width: 'normal', data: homeRuns, title: 'Career home run leaders', - notes: 'As of Opening Day 2023', + dek: 'In baseball, a home run (also known as a "dinger" or "tater") occurs when a batter hits the ball over the outfield fence. When a home run is hit, the batter and any runners on base are able to score.', + notes: 'Note: As of Opening Day 2023', + source: 'Source: Baseball Reference', }}" /> diff --git a/src/components/Table/Table.svelte b/src/components/Table/Table.svelte index 456fb954..83d3153b 100644 --- a/src/components/Table/Table.svelte +++ b/src/components/Table/Table.svelte @@ -11,15 +11,27 @@ /** * A title that runs above the table. - * @type string + * @type {string} */ - export let title: string; + export let title: string | null = null; + + /** + * A block of text that runs above the table. + * @type {string} + */ + export let dek: string | null = null; /** * A footnote that runs below the table. - * @type string + * @type {string} */ - export let notes: string; + export let notes: string | null = null; + + /** + * A source line that runs below the table. + * @type {string} + */ + export let source: string | null = null; /** * list of the fields to include in the table. By default everything goes. @@ -31,62 +43,62 @@ /** * The default page size. - * @type number + * @type {number} */ export let pageSize: number = 25; /** * Whether or not searches are allowed. - * @type boolean + * @type {boolean} */ export let searchable: boolean = false; /** * The label to place above the search box. - * @type string + * @type {string} */ export let searchLabel: string; /** * The placeholder text that appears in the search box. - * @type string + * @type {string} */ export let searchPlaceholder: string; /** * A field to offer uses as an interactive filter. - * @type string + * @type {string} */ export let filterField: string; /** * The label to place above the filter box - * @type string + * @type {string} */ export let filterLabel: string; /** * Whether or not sorts are allowed. - * @type boolean + * @type {boolean} */ export let sortable: boolean = false; /** * The column to sort by. By default it's the first header. - * @type string + * @type {string} */ export let sortField: string = Object.keys(data[0])[0]; /** * The direction of the sort. By default it's ascending. - * @type SortDirection + * @type {SortDirection} */ type SortDirection = 'ascending' | 'descending'; export let sortDirection: SortDirection = 'ascending'; /** * Custom field formatting functions. Should be keyed to the name of the field. - * @type object + * @type {object} */ export let fieldFormatters: object = {}; @@ -238,10 +250,15 @@ {/if}
- {#if title} - + {#if title || dek} + {/if} @@ -280,11 +297,18 @@ {/each} - {#if notes} + {#if notes || source} - - - + {#if notes} + + + + {/if} + {#if source} + + + + {/if} {/if}
{@html title} + {#if title} +
{@html title}
+ {/if} + {#if dek} +
{@html dek}
+ {/if} +
{@html notes}
{@html notes}
{@html source}
@@ -348,21 +372,34 @@ border-spacing: 0; width: 100%; font-size: 1rem; - font-family: var(--theme-font-family-sans-serif, $font-family-sans-serif); - color: var(--theme-colour-text-primary, $tr-dark-grey); - .table--caption--title { + font-family: $font-family-display; + color: $tr-dark-grey; + .table--caption { caption-side: top; - font-weight: 500; - color: var(--theme-colour-text-primary, $tr-dark-grey); - font-size: 1.25rem; + .table--caption--title { + font-weight: 500; + color: $tr-dark-grey; + font-size: 1.33rem; + padding: 0; + } + .table--caption--dek { + font-size: 1rem; + font-weight: 300; + padding: 0; + line-height: 1.4; + } } thead { tr { - border-bottom: 1px solid $tr-muted-grey; + border-bottom: 1px solid $tr-light-grey; th { + color: $tr-medium-grey; + font-size: 0.85rem; font-weight: 500; + text-transform: uppercase; + letter-spacing: 0.06rem; line-height: 1.4; - padding: 0 0.333rem; + padding: 0.5rem 0.25rem 0.5rem 0; &.sortable { cursor: pointer; } @@ -388,7 +425,9 @@ border-bottom: 1px solid $tr-light-muted-grey; } td { - padding: 0.333rem; + font-size: 1rem; + font-weight: 300; + padding: 0.5rem 0.25rem 0.5rem 0; } } .table--tfoot--footnote { @@ -396,10 +435,10 @@ border-bottom: 0; } td { - font-weight: 400; + font-weight: 300; color: var(--theme-colour-text-primary, $tr-dark-grey); - font-size: 0.75rem; - padding: 0.666rem 0 0 0; + font-size: 0.8rem; + padding: 0.5rem 0 0 0; } } } diff --git a/src/components/Table/stories/docs/metadata.md b/src/components/Table/stories/docs/metadata.md index 0033de07..a2f33be1 100644 --- a/src/components/Table/stories/docs/metadata.md +++ b/src/components/Table/stories/docs/metadata.md @@ -4,6 +4,9 @@ Set the `title` and `notes` options to add supporting metadata above and below t ```