From dffd1c94b52bbc845af56236bba06b1abca26fed Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Tue, 2 Jul 2024 22:58:33 -0500 Subject: [PATCH] Add a profile dropdown menu --- public/style.css | 8 ++-- src/hmnurl/hmnurl_test.go | 2 +- src/hmnurl/urls.go | 2 +- src/rawdata/scss/header.css | 48 +++++++++++----------- src/templates/src/include/header-2024.html | 21 +++++++--- src/templates/src/include/header.html | 2 +- src/templates/types.go | 14 +++---- src/website/base_data.go | 12 +++--- src/website/routes.go | 2 +- 9 files changed, 58 insertions(+), 53 deletions(-) diff --git a/public/style.css b/public/style.css index d5633d21..ebeff171 100644 --- a/public/style.css +++ b/public/style.css @@ -8298,7 +8298,7 @@ header .header-nav > .root-item > a { display: block; padding: var(--spacing-3); } -header .header-nav .submenu { +header .submenu { display: flex; flex-direction: column; position: absolute; @@ -8309,16 +8309,16 @@ header .header-nav .submenu { border-width: 1px; border-top-width: 0; } -header .header-nav .submenu > a { +header .submenu > a { padding: var(--spacing-2) var(--spacing-3); display: block; white-space: nowrap; z-index: 1; } -header .header-nav .root-item:not(:hover):not(.clicked) > .submenu { +header .root-item:not(:hover):not(.clicked) > .submenu { display: none; } -header .header-nav .root-item.clicked .svgicon { +header .root-item.clicked .svgicon { transform: rotate(180deg); } header:not(.clicked) .root-item:not(:hover) > .submenu, diff --git a/src/hmnurl/hmnurl_test.go b/src/hmnurl/hmnurl_test.go index f9f6e82f..7b451f08 100644 --- a/src/hmnurl/hmnurl_test.go +++ b/src/hmnurl/hmnurl_test.go @@ -67,7 +67,7 @@ func TestLoginWithDiscord(t *testing.T) { } func TestLogoutAction(t *testing.T) { - AssertRegexMatch(t, BuildLogoutAction(""), RegexLogoutAction, nil) + AssertRegexMatch(t, BuildLogoutAction(""), RegexLogout, nil) } func TestRegister(t *testing.T) { diff --git a/src/hmnurl/urls.go b/src/hmnurl/urls.go index 880da51e..0dfeb0e9 100644 --- a/src/hmnurl/urls.go +++ b/src/hmnurl/urls.go @@ -219,7 +219,7 @@ func BuildLoginWithDiscord(redirectTo string) string { return Url("/login-with-discord", []Q{{Name: "redirect", Value: redirectTo}}) } -var RegexLogoutAction = regexp.MustCompile("^/logout$") +var RegexLogout = regexp.MustCompile("^/logout$") func BuildLogoutAction(redir string) string { defer CatchPanic() diff --git a/src/rawdata/scss/header.css b/src/rawdata/scss/header.css index c5e48159..68faacbb 100644 --- a/src/rawdata/scss/header.css +++ b/src/rawdata/scss/header.css @@ -144,34 +144,34 @@ header { display: block; padding: var(--spacing-3); } + } - .submenu { - display: flex; - flex-direction: column; - position: absolute; - z-index: 100; - min-width: 8rem; - background-color: var(--c3); - border-style: solid; - border-width: 1px; - border-top-width: 0; + .submenu { + display: flex; + flex-direction: column; + position: absolute; + z-index: 100; + min-width: 8rem; + background-color: var(--c3); + border-style: solid; + border-width: 1px; + border-top-width: 0; - >a { - padding: var(--spacing-2) var(--spacing-3); - display: block; - white-space: nowrap; - z-index: 1; - } + >a { + padding: var(--spacing-2) var(--spacing-3); + display: block; + white-space: nowrap; + z-index: 1; + } + } + + .root-item { + &:not(:hover):not(.clicked)>.submenu { + display: none; } - .root-item { - &:not(:hover):not(.clicked)>.submenu { - display: none; - } - - &.clicked .svgicon { - transform: rotate(180deg); - } + &.clicked .svgicon { + transform: rotate(180deg); } } diff --git a/src/templates/src/include/header-2024.html b/src/templates/src/include/header-2024.html index 531043fb..801ea574 100644 --- a/src/templates/src/include/header-2024.html +++ b/src/templates/src/include/header-2024.html @@ -39,13 +39,22 @@ - - {{ with .User }} - - {{ else }} - Log In +
+ + {{ with .User }} + + {{ else }} + Log In + {{ end }} + + {{ if .User }} + {{ end }} - +