From fb2e04f90ef589b1f089534953fc0480ba74cb2b Mon Sep 17 00:00:00 2001 From: William Brawner Date: Mon, 19 Jun 2023 10:15:44 -0600 Subject: [PATCH] WIP: Add static web frontend --- .../com/wbrawner/twigs/web/WebRoutes.kt | 4 +- web/src/main/resources/web/img/logo-color.svg | 1 + web/src/main/resources/web/img/logo-white.svg | 68 +++++++++++++++ web/src/main/resources/web/index.html | 18 ++++ web/src/main/resources/web/js/index.js | 16 ++++ web/src/main/resources/web/style.css | 85 +++++++++++++++++++ 6 files changed, 190 insertions(+), 2 deletions(-) create mode 100644 web/src/main/resources/web/img/logo-color.svg create mode 100644 web/src/main/resources/web/img/logo-white.svg create mode 100644 web/src/main/resources/web/index.html create mode 100644 web/src/main/resources/web/js/index.js create mode 100644 web/src/main/resources/web/style.css diff --git a/web/src/main/kotlin/com/wbrawner/twigs/web/WebRoutes.kt b/web/src/main/kotlin/com/wbrawner/twigs/web/WebRoutes.kt index 63f4723..566d39a 100644 --- a/web/src/main/kotlin/com/wbrawner/twigs/web/WebRoutes.kt +++ b/web/src/main/kotlin/com/wbrawner/twigs/web/WebRoutes.kt @@ -9,12 +9,12 @@ import io.ktor.server.routing.* fun Application.webRoutes() { routing { static { - resources("twigs") + resources("web") default("index.html") } intercept(ApplicationCallPipeline.Setup) { if (!call.request.path().startsWith("/api") && !call.request.path().matches(Regex(".*\\.\\w+$"))) { - call.resolveResource("twigs/index.html")?.let { + call.resolveResource("web/index.html")?.let { call.respond(it) return@intercept finish() } diff --git a/web/src/main/resources/web/img/logo-color.svg b/web/src/main/resources/web/img/logo-color.svg new file mode 100644 index 0000000..81119ac --- /dev/null +++ b/web/src/main/resources/web/img/logo-color.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/web/src/main/resources/web/img/logo-white.svg b/web/src/main/resources/web/img/logo-white.svg new file mode 100644 index 0000000..7c78cd1 --- /dev/null +++ b/web/src/main/resources/web/img/logo-white.svg @@ -0,0 +1,68 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/web/src/main/resources/web/index.html b/web/src/main/resources/web/index.html new file mode 100644 index 0000000..d3bd36c --- /dev/null +++ b/web/src/main/resources/web/index.html @@ -0,0 +1,18 @@ + + + + Twigs + + + +
+
+ + +
+
+ + + \ No newline at end of file diff --git a/web/src/main/resources/web/js/index.js b/web/src/main/resources/web/js/index.js new file mode 100644 index 0000000..05ec1b6 --- /dev/null +++ b/web/src/main/resources/web/js/index.js @@ -0,0 +1,16 @@ +window.onload = () => { + const container = document.getElementsByClassName('center')[0] + container.innerHTML += ` +
+ + +
` +} + +function login() { + console.log('show login form') +} + +function register() { + console.log('show registration form') +} \ No newline at end of file diff --git a/web/src/main/resources/web/style.css b/web/src/main/resources/web/style.css new file mode 100644 index 0000000..4ed4b6c --- /dev/null +++ b/web/src/main/resources/web/style.css @@ -0,0 +1,85 @@ +html, body { + margin: 0; + padding: 0; + font-family: "Segoe UI", "Product Sans", "Roboto", "San Francisco", sans-serif; +} + +:root { + --color-accent: #004800; + --color-on-accent: #FFFFFF; + --color-on-background: #000000; + --logo: url("/img/logo-color.svg"); + --background-color-primary: #ffffff; + --background-color-secondary: #bbbbbb; +} + +@media all and (prefers-color-scheme: dark) { + :root { + --color-accent: #baff33; + --color-on-accent: #000000; + --color-on-background: #FFFFFF; + --logo: url("/img/logo-white.svg"); + --background-color-primary: #000000; + --background-color-secondary: #333333; + } +} + +body { + background-image: linear-gradient(var(--background-color-primary), var(--background-color-secondary)); + height: 100vh; + width: 100vw; +} + +#app { + height: 100%; + width: 100%; +} + +button { + border: 1px solid var(--color-accent); + border-radius: 1rem; + cursor: pointer; + font-weight: bold; + padding: 1rem; +} + +.flex-full-width { + display: flex; + flex-direction: row; +} + +.button-primary { + background-color: var(--color-accent); + color: var(--color-on-accent); +} + +.button-secondary { + background-color: var(--background-color-primary); + color: var(--color-accent); +} + +.center { + align-items: center; + display: flex; + flex-direction: column; + height: 100%; + justify-content: center; + width: 100%; +} + +.logo { + background-image: var(--logo); + background-size: contain; + height: 200px; + width: 200px; +} + +@media all and (max-width: 400px) { + button { + width: 100%; + } + + .flex-full-width { + flex-direction: column; + } +}