From f09320161b04d26aa26bdd141b9b7b4ca3bd39f2 Mon Sep 17 00:00:00 2001 From: anthdm Date: Sat, 8 Jun 2024 22:46:37 +0200 Subject: [PATCH] added theme switcher --- bootstrap/Makefile | 2 +- bootstrap/app/assets/app.css | 77 ++++++------ .../app/views/components/navigation.templ | 7 +- .../app/views/components/theme_switcher.templ | 18 +++ bootstrap/app/views/landing/index.templ | 2 +- bootstrap/app/views/layouts/base_layout.templ | 4 +- bootstrap/public/assets/styles.css | 111 +++++++++++++++--- 7 files changed, 160 insertions(+), 61 deletions(-) create mode 100644 bootstrap/app/views/components/theme_switcher.templ diff --git a/bootstrap/Makefile b/bootstrap/Makefile index 46dd3f1..a80a509 100644 --- a/bootstrap/Makefile +++ b/bootstrap/Makefile @@ -39,7 +39,7 @@ sync_assets: # start the application in development dev: - @make -j5 templ server assets sync_assets + @make -j4 templ server assets sync_assets # build the application for production. This will compile your app # to a single binary with all its assets embedded. diff --git a/bootstrap/app/assets/app.css b/bootstrap/app/assets/app.css index 164a08e..cd7f173 100644 --- a/bootstrap/app/assets/app.css +++ b/bootstrap/app/assets/app.css @@ -10,47 +10,50 @@ @apply bg-background text-foreground; } +@layer base { :root { - --background: 224 71.4% 4.1%; - --foreground: 210 20% 98%; - --card: 224 71.4% 4.1%; - --card-foreground: 210 20% 98%; - --popover: 224 71.4% 4.1%; - --popover-foreground: 210 20% 98%; - --primary: 263.4 70% 50.4%; - --primary-foreground: 210 20% 98%; - --secondary: 215 27.9% 16.9%; - --secondary-foreground: 210 20% 98%; - --muted: 215 27.9% 16.9%; - --muted-foreground: 217.9 10.6% 64.9%; - --accent: 215 27.9% 16.9%; - --accent-foreground: 210 20% 98%; - --destructive: 0 62.8% 30.6%; - --destructive-foreground: 210 20% 98%; - --border: 215 27.9% 16.9%; - --input: 215 27.9% 16.9%; - --ring: 263.4 70% 50.4%; + --background: 0 0% 100%; + --foreground: 240 10% 3.9%; + --card: 0 0% 100%; + --card-foreground: 240 10% 3.9%; + --popover: 0 0% 100%;; + --popover-foreground: 240 10% 3.9%; + --primary: 240 5.9% 10%; + --primary-foreground: 0 0% 98%; + --secondary: 240 4.8% 95.9%; + --secondary-foreground: 240 5.9% 10%; + --muted: 240 4.8% 95.9%; + --muted-foreground: 240 3.8% 46.1%; + --accent: 240 4.8% 95.9%; + --accent-foreground: 240 5.9% 10%; + --destructive: 0 72.22% 50.59%; + --destructive-foreground: 0 0% 98%; + --border: 240 5.9% 90%; + --input: 240 5.9% 90%; + --ring: 240 5.9% 10%; + --radius: 0.5rem; } .dark { - --background: 224 71.4% 4.1%; - --foreground: 210 20% 98%; - --card: 224 71.4% 4.1%; - --card-foreground: 210 20% 98%; - --popover: 224 71.4% 4.1%; - --popover-foreground: 210 20% 98%; - --primary: 263.4 70% 50.4%; - --primary-foreground: 210 20% 98%; - --secondary: 215 27.9% 16.9%; - --secondary-foreground: 210 20% 98%; - --muted: 215 27.9% 16.9%; - --muted-foreground: 217.9 10.6% 64.9%; - --accent: 215 27.9% 16.9%; - --accent-foreground: 210 20% 98%; + --background: 240 10% 3.9%; + --foreground: 0 0% 98%; + --card: 240 10% 3.9%; + --card-foreground: 0 0% 98%; + --popover: 240 10% 3.9%; + --popover-foreground: 0 0% 98%; + --primary: 0 0% 98%; + --primary-foreground: 240 5.9% 10%; + --secondary: 240 3.7% 15.9%; + --secondary-foreground: 0 0% 98%; + --muted: 240 3.7% 15.9%; + --muted-foreground: 240 5% 64.9%; + --accent: 240 3.7% 15.9%; + --accent-foreground: 0 0% 98%; --destructive: 0 62.8% 30.6%; - --destructive-foreground: 210 20% 98%; - --border: 215 27.9% 16.9%; - --input: 215 27.9% 16.9%; - --ring: 263.4 70% 50.4%; + --destructive-foreground: 0 0% 98%; + --border: 240 3.7% 15.9%; + --input: 240 3.7% 15.9%; + --ring: 240 4.9% 83.9%; } } +} diff --git a/bootstrap/app/views/components/navigation.templ b/bootstrap/app/views/components/navigation.templ index 961c972..36100e0 100644 --- a/bootstrap/app/views/components/navigation.templ +++ b/bootstrap/app/views/components/navigation.templ @@ -2,10 +2,15 @@ package components templ Navigation() { } diff --git a/bootstrap/app/views/components/theme_switcher.templ b/bootstrap/app/views/components/theme_switcher.templ new file mode 100644 index 0000000..ce8d945 --- /dev/null +++ b/bootstrap/app/views/components/theme_switcher.templ @@ -0,0 +1,18 @@ +package components + +templ ThemeSwitcher() { +
+ @LightIcon() +
+
+ @DarkIcon() +
+} + +templ DarkIcon() { + +} + +templ LightIcon() { + +} diff --git a/bootstrap/app/views/landing/index.templ b/bootstrap/app/views/landing/index.templ index 8402b8b..c824a87 100644 --- a/bootstrap/app/views/landing/index.templ +++ b/bootstrap/app/views/landing/index.templ @@ -7,7 +7,7 @@ import ( templ Index() { @layouts.App() {
-

A single binary to change the world

+

A single binary to change the world

Get started by reading the documentation
} diff --git a/bootstrap/app/views/layouts/base_layout.templ b/bootstrap/app/views/layouts/base_layout.templ index b96b6e7..5a0e47b 100644 --- a/bootstrap/app/views/layouts/base_layout.templ +++ b/bootstrap/app/views/layouts/base_layout.templ @@ -22,10 +22,8 @@ templ BaseLayout() { - - - + { children... } diff --git a/bootstrap/public/assets/styles.css b/bootstrap/public/assets/styles.css index d60437f..20d8287 100644 --- a/bootstrap/public/assets/styles.css +++ b/bootstrap/public/assets/styles.css @@ -457,25 +457,48 @@ body { } :root { - --background: 224 71.4% 4.1%; - --foreground: 210 20% 98%; - --card: 224 71.4% 4.1%; - --card-foreground: 210 20% 98%; - --popover: 224 71.4% 4.1%; - --popover-foreground: 210 20% 98%; - --primary: 263.4 70% 50.4%; - --primary-foreground: 210 20% 98%; - --secondary: 215 27.9% 16.9%; - --secondary-foreground: 210 20% 98%; - --muted: 215 27.9% 16.9%; - --muted-foreground: 217.9 10.6% 64.9%; - --accent: 215 27.9% 16.9%; - --accent-foreground: 210 20% 98%; + --background: 0 0% 100%; + --foreground: 240 10% 3.9%; + --card: 0 0% 100%; + --card-foreground: 240 10% 3.9%; + --popover: 0 0% 100%; + --popover-foreground: 240 10% 3.9%; + --primary: 240 5.9% 10%; + --primary-foreground: 0 0% 98%; + --secondary: 240 4.8% 95.9%; + --secondary-foreground: 240 5.9% 10%; + --muted: 240 4.8% 95.9%; + --muted-foreground: 240 3.8% 46.1%; + --accent: 240 4.8% 95.9%; + --accent-foreground: 240 5.9% 10%; + --destructive: 0 72.22% 50.59%; + --destructive-foreground: 0 0% 98%; + --border: 240 5.9% 90%; + --input: 240 5.9% 90%; + --ring: 240 5.9% 10%; + --radius: 0.5rem; +} + +.dark { + --background: 240 10% 3.9%; + --foreground: 0 0% 98%; + --card: 240 10% 3.9%; + --card-foreground: 0 0% 98%; + --popover: 240 10% 3.9%; + --popover-foreground: 0 0% 98%; + --primary: 0 0% 98%; + --primary-foreground: 240 5.9% 10%; + --secondary: 240 3.7% 15.9%; + --secondary-foreground: 0 0% 98%; + --muted: 240 3.7% 15.9%; + --muted-foreground: 240 5% 64.9%; + --accent: 240 3.7% 15.9%; + --accent-foreground: 0 0% 98%; --destructive: 0 62.8% 30.6%; - --destructive-foreground: 210 20% 98%; - --border: 215 27.9% 16.9%; - --input: 215 27.9% 16.9%; - --ring: 263.4 70% 50.4%; + --destructive-foreground: 0 0% 98%; + --border: 240 3.7% 15.9%; + --input: 240 3.7% 15.9%; + --ring: 240 4.9% 83.9%; } *, ::before, ::after { @@ -617,6 +640,14 @@ body { max-width: 80rem; } +.max-w-xl { + max-width: 36rem; +} + +.cursor-pointer { + cursor: pointer; +} + .flex-col { flex-direction: column; } @@ -629,6 +660,10 @@ body { justify-content: center; } +.justify-between { + justify-content: space-between; +} + .gap-10 { gap: 2.5rem; } @@ -637,10 +672,35 @@ body { gap: 1rem; } +.gap-8 { + gap: 2rem; +} + +.rounded-full { + border-radius: 9999px; +} + +.border { + border-width: 1px; +} + .border-b { border-bottom-width: 1px; } +.border-black { + --tw-border-opacity: 1; + border-color: rgb(0 0 0 / var(--tw-border-opacity)); +} + +.p-1 { + padding: 0.25rem; +} + +.p-1\.5 { + padding: 0.375rem; +} + .py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; @@ -691,6 +751,14 @@ body { text-transform: uppercase; } +.tracking-wide { + letter-spacing: 0.025em; +} + +.tracking-wider { + letter-spacing: 0.05em; +} + .text-blue-500 { --tw-text-opacity: 1; color: rgb(59 130 246 / var(--tw-text-opacity)); @@ -716,3 +784,10 @@ body { line-height: 1; } } + +@media (prefers-color-scheme: dark) { + .dark\:border-white { + --tw-border-opacity: 1; + border-color: rgb(255 255 255 / var(--tw-border-opacity)); + } +}