From 5a6d495818b49da05366e1f844c6c8599c688c50 Mon Sep 17 00:00:00 2001
From: Ian Meyer
Date: Mon, 14 Oct 2024 14:31:11 -0400
Subject: [PATCH] Implement a consistent navigation menu (#65)
- Add menu template partial
- Ensure renderTemplate is passed the user object
- Style improvements for both light/dark themes
Change-Id: I8d24561fe5df8a1622fec01f7dd3ff83c990dab5
Signed-off-by: Ian Meyer
---
BUILD.bazel | 1 +
server.go | 12 ++++----
static/style.css | 64 ++++++++++++++++++++++++------------------
tmpl/admin.html | 6 ++--
tmpl/edit-profile.html | 4 ++-
tmpl/footer.html | 3 --
tmpl/header.html | 2 +-
tmpl/index.html | 8 +++---
tmpl/member.html | 7 ++---
tmpl/menu.html | 11 ++++++++
tmpl/newthread.html | 4 ++-
tmpl/thread.html | 2 ++
12 files changed, 73 insertions(+), 51 deletions(-)
create mode 100644 tmpl/menu.html
diff --git a/BUILD.bazel b/BUILD.bazel
index 30d5e52..9306b35 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -34,6 +34,7 @@ go_library(
"tmpl/index-thread-partial.html",
"tmpl/index.html",
"tmpl/member.html",
+ "tmpl/menu.html",
"tmpl/newthread.html",
"tmpl/thread.html",
"static/style.css",
diff --git a/server.go b/server.go
index 0288999..8570b02 100644
--- a/server.go
+++ b/server.go
@@ -1122,12 +1122,12 @@ func (s *DiscussService) ListMember(w http.ResponseWriter, r *http.Request) {
}
s.renderTemplate(w, r, "member.html", map[string]interface{}{
- "Title": GetBoardTitle(r),
- "Member": member,
- "CurrentUserEmail": user.Email,
- "Threads": memberThreadsParsed,
- "GitSha": s.gitSha,
- "Version": s.version,
+ "Title": GetBoardTitle(r),
+ "Member": member,
+ "Threads": memberThreadsParsed,
+ "GitSha": s.gitSha,
+ "Version": s.version,
+ "User": user,
})
}
diff --git a/static/style.css b/static/style.css
index eacde74..b4ff651 100644
--- a/static/style.css
+++ b/static/style.css
@@ -2,18 +2,22 @@
:root {
/* Common variables */
--border: 1px solid #454545;
+ --menu-border: 0.5px solid #454545;
/* Light mode variables */
--background-color-light: #f0f4f8;
--content-bg-light: #f9f9f9;
- --even-row-color-light: #CCC;
- --odd-row-color-light: #DDD;
+ --even-row-color-light: #8C867D;
+ --odd-row-color-light: #CCB287;
--form-bg-light: #ddd;
--header-color-light: #efefef;
--primary-color-light: #1e6091;
--text-color-light: #333;
--text-color-secondary-light: #555;
--threadpost-bg-light: #fff;
+ --menu-item-bg-light: #C7CACD;
+ --button-text-color-light: #fff;
+
/* Dark mode variables */
--background-color-dark: #1a2634;
@@ -22,10 +26,12 @@
--odd-row-color-dark: #333;
--form-bg-dark: #333;
--header-color-dark: #2c2c2c;
- --primary-color-dark: #64b5f6;
+ --primary-color-dark: #b5deff;
--text-color-dark: #e0e0e0;
--text-color-secondary-dark: #b0b0b0;
--threadpost-bg-dark: #333;
+ --menu-item-bg-dark: #6B84A2;
+ --button-text-color-dark: #222;
/* Default to light mode */
--background-color: var(--background-color-light);
@@ -38,6 +44,8 @@
--text-color: var(--text-color-light);
--text-color-secondary: var(--text-color-secondary-light);
--threadpost-bg: var(--threadpost-bg-light);
+ --menu-item-bg: var(--menu-item-bg-light);
+ --button-text-color: var(--button-text-color-light);
}
/* Base styles */
@@ -61,17 +69,6 @@ a:hover {
/* Table styles */
table {
- border: var(--border);
- border-collapse: separate;
- border-radius: 0 0.625rem 0.625rem 0.625rem;
- border-spacing: 0;
- margin: 0 auto;
- overflow: hidden;
- table-layout: fixed;
- width: 100%;
-}
-
-.content-container table {
border: var(--border);
border-collapse: separate;
border-radius: 0.625rem;
@@ -159,7 +156,7 @@ tbody>tr:nth-child(odd) {
background-color: var(--primary-color);
border: none;
border-radius: 0.625rem;
- color: white;
+ color: var(--button-text-color);
cursor: pointer;
font-size: 1em;
padding: 0.625rem;
@@ -168,7 +165,7 @@ tbody>tr:nth-child(odd) {
.edit-profile button:hover,
.form-group button:hover {
- background-color: (var(--primary-color) + 20%);
+ background-color: var(--primary-color);
}
.edit-profile input,
@@ -200,6 +197,11 @@ tbody>tr:nth-child(odd) {
margin-bottom: 0.3125rem;
}
+.menu {
+ display: flex;
+ flex-direction: row;
+}
+
.profile-column {
background-color: var(--primary-color);
box-sizing: border-box;
@@ -296,13 +298,12 @@ tbody>tr:nth-child(odd) {
.subject {
display: inline-block;
-
}
.subject p {
- font-size: 1.25rem;
+ font-size: 1.20rem;
font-weight: 600;
- margin-top: 0.4rem;
+ margin-top: 0rem;
margin-bottom: 0.4rem;
margin-left: 0rem;
margin-right: 0rem;
@@ -315,17 +316,26 @@ tbody>tr:nth-child(odd) {
padding-bottom: 10px;
}
+hr {
+ border: var(--menu-border);
+ margin-top: 0;
+ margin-bottom: 1.2rem;
+}
+
.sub-header {
display: block;
width: fit-content;
- border-top-right-radius: 0.625rem;
- border-top-left-radius: 0.625rem;
- border-bottom-left-radius: 0;
- border-bottom-right-radius: 0;
+ border-radius: 0.625rem 0.625rem 0 0;
border: var(--border);
border-bottom: 0px;
- margin-bottom: -1px;
+ margin-right: 0.625rem;
padding: 5px 10px 10px 10px;
+ background-color: var(--menu-item-bg)
+}
+
+.sub-header.admin {
+ margin-left: 1.5rem;
+ border-radius: 0.625rem 0.625rem 0 0;
}
.board-title {
@@ -412,10 +422,8 @@ svg a:active {
--text-color: var(--text-color-dark);
--text-color-secondary: var(--text-color-secondary-dark);
--threadpost-bg: var(--threadpost-bg-dark);
- }
-
- .form-group button:hover {
- background-color: #ffb8d9;
+ --menu-item-bg: var(--menu-item-bg-dark);
+ --button-text-color: var(--button-text-color-dark);
}
}
diff --git a/tmpl/admin.html b/tmpl/admin.html
index 73b4fae..51d6b27 100644
--- a/tmpl/admin.html
+++ b/tmpl/admin.html
@@ -1,6 +1,8 @@
{{ template "header" . }}
-Board statistics
+{{ template "menu" . }}
+
+Board statistics
@@ -17,7 +19,7 @@
Board statistics
-Edit board configuration
+Board configuration
- {{ .Title }}
+ {{ .Title }}
{{end}}
diff --git a/tmpl/index.html b/tmpl/index.html
index c42813a..9bffbea 100644
--- a/tmpl/index.html
+++ b/tmpl/index.html
@@ -1,7 +1,7 @@
- {{ template "header" . }}
+{{ template "header" . }}
-
+{{ template "menu" . }}
- {{ template "index-thread-partial" . }}
+{{ template "index-thread-partial" . }}
- {{ template "footer" . }}
+{{ template "footer" . }}
diff --git a/tmpl/member.html b/tmpl/member.html
index b8ff251..df33e9d 100644
--- a/tmpl/member.html
+++ b/tmpl/member.html
@@ -1,11 +1,8 @@
{{ template "header" . }}
+{{ template "menu" . }}
+
{{ if .Member }}
-{{ if eq .CurrentUserEmail .Member.Email }}
-
-{{ end }}
diff --git a/tmpl/menu.html b/tmpl/menu.html
new file mode 100644
index 0000000..1de0ec4
--- /dev/null
+++ b/tmpl/menu.html
@@ -0,0 +1,11 @@
+{{ define "menu" }}
+
+
+{{ end }}
diff --git a/tmpl/newthread.html b/tmpl/newthread.html
index 5aff41d..92715c5 100644
--- a/tmpl/newthread.html
+++ b/tmpl/newthread.html
@@ -1,6 +1,8 @@
{{ template "header" .}}
-Top serious throwback...
+{{ template "menu" .}}
+
+Top serious throwback...