From 3eafb413a48cde60dea8a7355ee621c6acca952f Mon Sep 17 00:00:00 2001 From: Doog <157747121+doogongithub@users.noreply.github.com> Date: Wed, 21 Feb 2024 22:07:27 -0500 Subject: first commit --- fe/src/App.svelte | 167 ++++++++++++++++++++++++++++++++++++++++++++++ fe/src/app.css | 111 ++++++++++++++++++++++++++++++ fe/src/assets/svelte.svg | 1 + fe/src/lib/Card.svelte | 22 ++++++ fe/src/lib/Counter.svelte | 10 +++ fe/src/lib/Table.svelte | 41 ++++++++++++ fe/src/lib/errors.ts | 7 ++ fe/src/lib/utils.ts | 9 +++ fe/src/main.ts | 8 +++ fe/src/vite-env.d.ts | 2 + 10 files changed, 378 insertions(+) create mode 100644 fe/src/App.svelte create mode 100644 fe/src/app.css create mode 100644 fe/src/assets/svelte.svg create mode 100644 fe/src/lib/Card.svelte create mode 100644 fe/src/lib/Counter.svelte create mode 100644 fe/src/lib/Table.svelte create mode 100644 fe/src/lib/errors.ts create mode 100644 fe/src/lib/utils.ts create mode 100644 fe/src/main.ts create mode 100644 fe/src/vite-env.d.ts (limited to 'fe/src') diff --git a/fe/src/App.svelte b/fe/src/App.svelte new file mode 100644 index 0000000..cc4e594 --- /dev/null +++ b/fe/src/App.svelte @@ -0,0 +1,167 @@ + + +
+ {#if !authenticated} + +
+
+ + +
+
+ + +
+ {#if error} +

{error}

+ {/if} + +
+
+ {:else} +
+ +
+
+ + + + + + +
+ + + + {#await data} +

...fetching

+ {:then data} + {#if data} +

Status

+

{data.status}

+ +
+
+ {:else} +

No data yet

+ {/if} + {:catch errror} +

{error.message}

+ {/await} + {/if} + + + diff --git a/fe/src/app.css b/fe/src/app.css new file mode 100644 index 0000000..4768cf6 --- /dev/null +++ b/fe/src/app.css @@ -0,0 +1,111 @@ +:root { + font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; + line-height: 1.5; + font-weight: 400; + + color-scheme: light dark; + color: rgba(255, 255, 255, 0.87); + background-color: #242424; + + font-synthesis: none; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + + --submit: #28a745; +} + +a { + font-weight: 500; + color: #646cff; + text-decoration: inherit; +} +a:hover { + color: #535bf2; +} + +body { + margin: 0; + display: flex; + place-items: center; + min-width: 320px; + min-height: 100vh; +} + +h1 { + font-size: 3.2em; + line-height: 1.1; +} + +.card { + padding: 2em; +} + +#app { + max-width: 1280px; + margin: 0 auto; + padding: 2rem; +} + +button { + border-radius: 8px; + border: 1px solid transparent; + padding: 0.6em 1.2em; + font-size: 1em; + font-weight: 500; + font-family: inherit; + background-color: #1a1a1a; + cursor: pointer; + transition: border-color 0.25s; +} +button:hover { + border-color: #646cff; +} +button:focus, +button:focus-visible { + outline: 4px auto -webkit-focus-ring-color; +} + +@media (prefers-color-scheme: light) { + :root { + color: #213547; + background-color: #ffffff; + } + a:hover { + color: #747bff; + } + button { + background-color: #f9f9f9; + } +} + +@media (prefers-color-scheme: dark) { + :root { + color: #000; + } +} + +.form { + display: flex; + flex-direction: column; +} + +.form.input.group { + display: flex; + flex-direction: column; + margin-bottom: 1em; +} + +.form.input.group label { + margin-bottom: .5em; +} + +.form.input.group input { + padding: 1em; +} + +.form button[type=submit] { + align-self: flex-end; + background: var(--submit); + color: #fff; +} diff --git a/fe/src/assets/svelte.svg b/fe/src/assets/svelte.svg new file mode 100644 index 0000000..c5e0848 --- /dev/null +++ b/fe/src/assets/svelte.svg @@ -0,0 +1 @@ + \ No newline at end of file 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 @@ + + +
+ {#if title} +

{title}

+ {/if} + +
+ + 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 @@ + + + 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 @@ + +
+ {#if title} +

{title}

+ {/if} + {#if !noheader} + + + + + + {/if} + + + + + + {#if !nofooter} + + + + + + + + {/if} +
+ Data Header +
Data
Table Footer
+ 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 @@ +export class UnauthorizedError extends Error { + constructor (message?: string , options?: ErrorOptions) { + super(message, options); + } +} + + 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 @@ +export function processFormInput(form) { + const formData = new FormData(form); + const data = {}; + for (let field of formData) { + const [key, value] = field; + data[key] = value; + } + return data; +} diff --git a/fe/src/main.ts b/fe/src/main.ts new file mode 100644 index 0000000..8a909a1 --- /dev/null +++ b/fe/src/main.ts @@ -0,0 +1,8 @@ +import './app.css' +import App from './App.svelte' + +const app = new App({ + target: document.getElementById('app'), +}) + +export default app diff --git a/fe/src/vite-env.d.ts b/fe/src/vite-env.d.ts new file mode 100644 index 0000000..4078e74 --- /dev/null +++ b/fe/src/vite-env.d.ts @@ -0,0 +1,2 @@ +/// +/// -- cgit v1.1