From 888002f67f064dc09b230329406e59bc87d9d58c Mon Sep 17 00:00:00 2001 From: Davis SHYAKA <87414827+davis-shyaka@users.noreply.github.com> Date: Wed, 14 Aug 2024 17:02:26 +0200 Subject: [PATCH] component: Table --- src/lib/components/ui/table/index.ts | 27 ++++++ src/lib/components/ui/table/table-body.svelte | 24 ++++++ .../components/ui/table/table-caption.svelte | 13 +++ src/lib/components/ui/table/table-cell.svelte | 18 ++++ .../components/ui/table/table-footer.svelte | 14 ++++ src/lib/components/ui/table/table-head.svelte | 19 +++++ .../components/ui/table/table-header.svelte | 14 ++++ src/lib/components/ui/table/table-row.svelte | 23 +++++ src/lib/components/ui/table/table.svelte | 15 ++++ src/lib/config/sitemap.ts | 2 +- src/routes/table/+page.svelte | 33 +++++++- src/routes/table/+page.ts | 21 +++++ src/routes/table/basic-table.svelte | 30 +++++++ src/routes/table/full-featured-table.svelte | 83 +++++++++++++++++++ src/routes/table/interactive-table.svelte | 30 +++++++ src/routes/table/striped-table.svelte | 30 +++++++ 16 files changed, 394 insertions(+), 2 deletions(-) create mode 100644 src/lib/components/ui/table/index.ts create mode 100644 src/lib/components/ui/table/table-body.svelte create mode 100644 src/lib/components/ui/table/table-caption.svelte create mode 100644 src/lib/components/ui/table/table-cell.svelte create mode 100644 src/lib/components/ui/table/table-footer.svelte create mode 100644 src/lib/components/ui/table/table-head.svelte create mode 100644 src/lib/components/ui/table/table-header.svelte create mode 100644 src/lib/components/ui/table/table-row.svelte create mode 100644 src/lib/components/ui/table/table.svelte create mode 100644 src/routes/table/+page.ts create mode 100644 src/routes/table/basic-table.svelte create mode 100644 src/routes/table/full-featured-table.svelte create mode 100644 src/routes/table/interactive-table.svelte create mode 100644 src/routes/table/striped-table.svelte diff --git a/src/lib/components/ui/table/index.ts b/src/lib/components/ui/table/index.ts new file mode 100644 index 0000000..8ce5be7 --- /dev/null +++ b/src/lib/components/ui/table/index.ts @@ -0,0 +1,27 @@ +import Body from './table-body.svelte'; +import Caption from './table-caption.svelte'; +import Cell from './table-cell.svelte'; +import Footer from './table-footer.svelte'; +import Head from './table-head.svelte'; +import Header from './table-header.svelte'; +import Row from './table-row.svelte'; +import Root from './table.svelte'; + +export { + Body, + Caption, + Cell, + Footer, + Head, + Header, + Root, + Row, + Root as Table, + Body as TableBody, + Caption as TableCaption, + Cell as TableCell, + Footer as TableFooter, + Head as TableHead, + Header as TableHeader, + Row as TableRow +}; diff --git a/src/lib/components/ui/table/table-body.svelte b/src/lib/components/ui/table/table-body.svelte new file mode 100644 index 0000000..e588fce --- /dev/null +++ b/src/lib/components/ui/table/table-body.svelte @@ -0,0 +1,24 @@ + + + + + + diff --git a/src/lib/components/ui/table/table-caption.svelte b/src/lib/components/ui/table/table-caption.svelte new file mode 100644 index 0000000..3b7d002 --- /dev/null +++ b/src/lib/components/ui/table/table-caption.svelte @@ -0,0 +1,13 @@ + + + + + diff --git a/src/lib/components/ui/table/table-cell.svelte b/src/lib/components/ui/table/table-cell.svelte new file mode 100644 index 0000000..20da0a1 --- /dev/null +++ b/src/lib/components/ui/table/table-cell.svelte @@ -0,0 +1,18 @@ + + + + + diff --git a/src/lib/components/ui/table/table-footer.svelte b/src/lib/components/ui/table/table-footer.svelte new file mode 100644 index 0000000..050a7a9 --- /dev/null +++ b/src/lib/components/ui/table/table-footer.svelte @@ -0,0 +1,14 @@ + + + + + + diff --git a/src/lib/components/ui/table/table-head.svelte b/src/lib/components/ui/table/table-head.svelte new file mode 100644 index 0000000..5c75cc8 --- /dev/null +++ b/src/lib/components/ui/table/table-head.svelte @@ -0,0 +1,19 @@ + + + + + diff --git a/src/lib/components/ui/table/table-header.svelte b/src/lib/components/ui/table/table-header.svelte new file mode 100644 index 0000000..03db622 --- /dev/null +++ b/src/lib/components/ui/table/table-header.svelte @@ -0,0 +1,14 @@ + + + + + + diff --git a/src/lib/components/ui/table/table-row.svelte b/src/lib/components/ui/table/table-row.svelte new file mode 100644 index 0000000..f106dd1 --- /dev/null +++ b/src/lib/components/ui/table/table-row.svelte @@ -0,0 +1,23 @@ + + + + + diff --git a/src/lib/components/ui/table/table.svelte b/src/lib/components/ui/table/table.svelte new file mode 100644 index 0000000..a72993d --- /dev/null +++ b/src/lib/components/ui/table/table.svelte @@ -0,0 +1,15 @@ + + +
+ + +
+
diff --git a/src/lib/config/sitemap.ts b/src/lib/config/sitemap.ts index 4c7edb6..15c630f 100644 --- a/src/lib/config/sitemap.ts +++ b/src/lib/config/sitemap.ts @@ -235,7 +235,7 @@ export const aside_items: Aside = { { title: 'Table', href: '/table', - status: 'soon' + status: 'new' }, { title: 'Tabs', diff --git a/src/routes/table/+page.svelte b/src/routes/table/+page.svelte index a65c8af..a2f754c 100644 --- a/src/routes/table/+page.svelte +++ b/src/routes/table/+page.svelte @@ -1 +1,32 @@ -

table

+ + + + + + + + + + + + + + + + + + + diff --git a/src/routes/table/+page.ts b/src/routes/table/+page.ts new file mode 100644 index 0000000..970315d --- /dev/null +++ b/src/routes/table/+page.ts @@ -0,0 +1,21 @@ +import type { MetaTagsProps } from 'svelte-meta-tags'; + +export function load() { + const title = 'Table'; + const description = 'A semantic HTML table component'; + + const pageMetaTags = Object.freeze({ + title, + description, + openGraph: { + title, + description + } + }) satisfies MetaTagsProps; + + return { + pageMetaTags, + title, + description + }; +} diff --git a/src/routes/table/basic-table.svelte b/src/routes/table/basic-table.svelte new file mode 100644 index 0000000..920303b --- /dev/null +++ b/src/routes/table/basic-table.svelte @@ -0,0 +1,30 @@ + + + + + + Col 1 + Col 2 + Col 3 + + + + + Value 1.1 + Value 1.2 + Value 1.3 + + + Value 2.1 + Value 2.2 + Value 2.3 + + + Value 3.1 + Value 3.2 + Value 3.3 + + + diff --git a/src/routes/table/full-featured-table.svelte b/src/routes/table/full-featured-table.svelte new file mode 100644 index 0000000..71d443e --- /dev/null +++ b/src/routes/table/full-featured-table.svelte @@ -0,0 +1,83 @@ + + + + + + Product + Usage + Price + Charge + + + + {#each items as item, i (i)} + + {item.product} + {item.usage} + {item.price} + {format_currency(item.charge)} + + {/each} + + + + Subtotal + + + + {format_currency(items.reduce((sum, val) => sum + val.charge, 0))} + + + + diff --git a/src/routes/table/interactive-table.svelte b/src/routes/table/interactive-table.svelte new file mode 100644 index 0000000..7e4bb3c --- /dev/null +++ b/src/routes/table/interactive-table.svelte @@ -0,0 +1,30 @@ + + + + + + Col 1 + Col 2 + Col 3 + + + + + Value 1.1 + Value 1.2 + Value 1.3 + + + Value 2.1 + Value 2.2 + Value 2.3 + + + Value 3.1 + Value 3.2 + Value 3.3 + + + diff --git a/src/routes/table/striped-table.svelte b/src/routes/table/striped-table.svelte new file mode 100644 index 0000000..7e678da --- /dev/null +++ b/src/routes/table/striped-table.svelte @@ -0,0 +1,30 @@ + + + + + + Col 1 + Col 2 + Col 3 + + + + + Value 1.1 + Value 1.2 + Value 1.3 + + + Value 2.1 + Value 2.2 + Value 2.3 + + + Value 3.1 + Value 3.2 + Value 3.3 + + +