diff options
Diffstat (limited to 'fe/src/lib')
| -rw-r--r-- | fe/src/lib/Card.svelte | 22 | ||||
| -rw-r--r-- | fe/src/lib/Counter.svelte | 10 | ||||
| -rw-r--r-- | fe/src/lib/Table.svelte | 41 | ||||
| -rw-r--r-- | fe/src/lib/errors.ts | 7 | ||||
| -rw-r--r-- | fe/src/lib/utils.ts | 9 |
5 files changed, 89 insertions, 0 deletions
diff --git a/fe/src/lib/Card.svelte b/fe/src/lib/Card.svelte new file mode 100644 index 0000000..feb5bcc --- /dev/null +++ b/fe/src/lib/Card.svelte | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | <script lang="ts"> | ||
| 2 | export let title; | ||
| 3 | </script> | ||
| 4 | |||
| 5 | <div class="card"> | ||
| 6 | {#if title} | ||
| 7 | <h2>{title}</h2> | ||
| 8 | {/if} | ||
| 9 | <slot /> | ||
| 10 | </div> | ||
| 11 | |||
| 12 | <style> | ||
| 13 | .card { | ||
| 14 | background: #fff; | ||
| 15 | width: 16rem; | ||
| 16 | display: flex; | ||
| 17 | flex-direction: column; | ||
| 18 | align-items: left; | ||
| 19 | border: solid 2px #00000066; | ||
| 20 | border-radius: 0.25em; | ||
| 21 | } | ||
| 22 | </style> | ||
diff --git a/fe/src/lib/Counter.svelte b/fe/src/lib/Counter.svelte new file mode 100644 index 0000000..979b4df --- /dev/null +++ b/fe/src/lib/Counter.svelte | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | <script lang="ts"> | ||
| 2 | let count: number = 0 | ||
| 3 | const increment = () => { | ||
| 4 | count += 1 | ||
| 5 | } | ||
| 6 | </script> | ||
| 7 | |||
| 8 | <button on:click={increment}> | ||
| 9 | count is {count} | ||
| 10 | </button> | ||
diff --git a/fe/src/lib/Table.svelte b/fe/src/lib/Table.svelte new file mode 100644 index 0000000..2df9f8c --- /dev/null +++ b/fe/src/lib/Table.svelte | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | <script lang="ts"> | ||
| 2 | export let data; | ||
| 3 | export let nofooter: boolean = false; | ||
| 4 | export let noheader: boolean = false; | ||
| 5 | export let title: string; | ||
| 6 | </script> | ||
| 7 | <table> | ||
| 8 | {#if title} | ||
| 9 | <h2>{title}</h2> | ||
| 10 | {/if} | ||
| 11 | {#if !noheader} | ||
| 12 | <thead> | ||
| 13 | <tr> | ||
| 14 | <th> | ||
| 15 | Data Header | ||
| 16 | </th> | ||
| 17 | </tr> | ||
| 18 | </thead> | ||
| 19 | {/if} | ||
| 20 | <tbody> | ||
| 21 | <tr> | ||
| 22 | <td>Data</td> | ||
| 23 | </tr> | ||
| 24 | </tbody> | ||
| 25 | {#if !nofooter} | ||
| 26 | <slot name="footer"> | ||
| 27 | <tfoot> | ||
| 28 | <tr> | ||
| 29 | <td>Table Footer</td> | ||
| 30 | </tr> | ||
| 31 | </tfoot> | ||
| 32 | </slot> | ||
| 33 | {/if} | ||
| 34 | </table> | ||
| 35 | <style> | ||
| 36 | table { | ||
| 37 | padding: 16px; | ||
| 38 | margin: 8px; | ||
| 39 | border: solid 1px black; | ||
| 40 | } | ||
| 41 | </style> | ||
diff --git a/fe/src/lib/errors.ts b/fe/src/lib/errors.ts new file mode 100644 index 0000000..0663d63 --- /dev/null +++ b/fe/src/lib/errors.ts | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | export class UnauthorizedError extends Error { | ||
| 2 | constructor (message?: string , options?: ErrorOptions) { | ||
| 3 | super(message, options); | ||
| 4 | } | ||
| 5 | } | ||
| 6 | |||
| 7 | |||
diff --git a/fe/src/lib/utils.ts b/fe/src/lib/utils.ts new file mode 100644 index 0000000..c5501ae --- /dev/null +++ b/fe/src/lib/utils.ts | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | export function processFormInput(form) { | ||
| 2 | const formData = new FormData(form); | ||
| 3 | const data = {}; | ||
| 4 | for (let field of formData) { | ||
| 5 | const [key, value] = field; | ||
| 6 | data[key] = value; | ||
| 7 | } | ||
| 8 | return data; | ||
| 9 | } | ||
