Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved navbar layout #130

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/webserver/controller/user/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
func (u *Controller) Create(c *fiber.Ctx) error {
role, _ := strconv.Atoi(c.FormValue("role"))
user := model.User{
Name: c.FormValue("name"),
Name: strings.TrimSpace(c.FormValue("name")),
Username: strings.ToLower(c.FormValue("username")),
Email: c.FormValue("email"),
SendToEmail: c.FormValue("send-to-email"),
Expand Down
116 changes: 60 additions & 56 deletions internal/webserver/embedded/views/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<body class="d-flex flex-column h-100" hx-ext="response-targets">
<header>
<nav class="navbar navbar-expand-md fixed-top {{if .HomeNavbar}}navbar-home{{end}}">
<nav class="navbar navbar-expand-lg fixed-top {{if .HomeNavbar}}navbar-home{{end}}">
<div class="container d-flex justify-content-end">
{{if not .HomeNavbar}}
<span class="navbar-brand mb-0 h1">
Expand All @@ -45,63 +45,49 @@
data-bs-target="#offcanvasNavbar" aria-controls="offcanvasNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="offcanvas offcanvas-end" tabindex="-1" id="offcanvasNavbar"
<div class="offcanvas-lg offcanvas-end" tabindex="-1" id="offcanvasNavbar"
aria-labelledby="offcanvasNavbarLabel">
<div class="offcanvas-header">
<h5 class="offcanvas-title" id="offcanvasNavbarLabel">Coreander</h5>
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
<h5 class="offcanvas-title" id="offcanvasNavbarLabel">
<img src="/images/coreander-logo-small.png" alt="Logo" width="32" height="32" class="d-inline-block align-text-middle">
{{.Session.Name}}
</h5>
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#offcanvasNavbar" aria-label="Close"></button>
</div>
<div class="offcanvas-body">
<ul class="navbar-nav justify-content-end flex-grow-1 pe-3 text-start">
{{if and (.Session) (ne .Session.Name "")}}
<li class="nav-item dropdown">
<button class="btn dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
{{.Session.Name}}
</button>
<ul class="dropdown-menu">
<li>
{{if eq .Session.Role 2}}
<a class="dropdown-item" href="/users">
<i class="bi-person-fill"></i>

{{t .Lang "Users"}}
</a>
{{else}}
<a class="dropdown-item" href="/users/{{.Session.Username}}">
<i class="bi-person-fill"></i>
<li class="p-2">
{{if eq .Session.Role 2}}
<a href="/users" class="link-underline link-underline-opacity-0">
<i class="bi-person-fill"></i>

{{t .Lang "Update your profile"}}
</a>
{{end}}
</li>
<li>
<a class="dropdown-item" href="/highlights">
<i class="bi-star-fill"></i>
{{t .Lang "Users"}}
</a>
{{else}}
<a href="/users/{{.Session.Username}}" class="link-underline link-underline-opacity-0">
<i class="bi-person-fill"></i>

{{t .Lang "Highlights"}}
</a>
</li>
{{if eq .Session.Role 2}}
<li>
<a class="dropdown-item" href="/upload">
<i class="bi-cloud-upload-fill"></i>
{{t .Lang "Update your profile"}}
</a>
{{end}}
</li>
<li class="p-2">
<a href="/highlights" class="link-underline link-underline-opacity-0">
<i class="bi-star-fill"></i>

{{t .Lang "Upload document"}}
</a>
</li>
{{end}}
<li>
<hr class="dropdown-divider">
</li>
<li>
<a class="dropdown-item" href="/sessions" hx-delete="/sessions">
<i class="bi-box-arrow-right"></i>
{{t .Lang "Highlights"}}
</a>
</li>
{{if eq .Session.Role 2}}
<li class="p-2">
<a href="/upload" class="link-underline link-underline-opacity-0">
<i class="bi-cloud-upload-fill"></i>

{{t .Lang "Logout"}}
</a>
</li>
</ul>
{{t .Lang "Upload document"}}
</a>
</li>
{{end}}
{{else if not .DisableLoginLink}}
<li class="p-2">
<a href="/sessions/new">{{t .Lang "Login"}}</a>
Expand All @@ -111,17 +97,35 @@ <h5 class="offcanvas-title" id="offcanvasNavbarLabel">Coreander</h5>
{{$lang := .Lang}}
{{$URLPath := .URLPath}}
{{$queryString := .QueryString}}
{{range $i, $currentLang := .SupportedLanguages}}
{{if eq $lang $currentLang}}
<li class="p-2">{{uppercase $currentLang}}</li>
{{else if eq $queryString ""}}
<li class="p-2"><a href="{{$URLPath}}?l={{$currentLang}}">{{uppercase $currentLang}}</a></li>
{{else}}
<li class="p-2"><a href="{{$URLPath}}?{{$queryString}}&l={{$currentLang}}">{{uppercase $currentLang}}</a></li>
<li class="nav-item dropdown">
<button class="btn dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
<i class="bi-globe"></i>
</button>
<ul class="dropdown-menu">
{{range $i, $currentLang := .SupportedLanguages}}
{{if eq $lang $currentLang}}
<li class="dropdown-item">{{uppercase $currentLang}}</li>
{{else if eq $queryString ""}}
<li class="dropdown-item"><a href="{{$URLPath}}?l={{$currentLang}}">{{uppercase $currentLang}}</a></li>
{{else}}
<li class="dropdown-item"><a href="{{$URLPath}}?{{$queryString}}&l={{$currentLang}}">{{uppercase $currentLang}}</a></li>
{{end}}
{{end}}
{{end}}
</ul>
</li>
<li class="nav-item dropdown">
{{template "partials/color-mode-toggle" dict "Lang" $lang}}
</li>
{{if and (.Session) (ne .Session.Name "")}}
<hr class="d-lg-none">
{{template "partials/color-mode-toggle" dict "Lang" $lang}}
<li class="p-2">
<a href="/sessions" hx-delete="/sessions" class="link-underline link-underline-opacity-0">
<i class="bi-box-arrow-right"></i>

{{t .Lang "Logout"}}
</a>
</li>
{{end}}
</ul>
</div>
</div>
Expand Down
111 changes: 55 additions & 56 deletions internal/webserver/embedded/views/partials/color-mode-toggle.html
Original file line number Diff line number Diff line change
@@ -1,57 +1,56 @@
<li class="nav-item dropdown">
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
<symbol id="circle-half" viewBox="0 0 16 16">
<path d="M8 15A7 7 0 1 0 8 1v14zm0 1A8 8 0 1 1 8 0a8 8 0 0 1 0 16z"></path>
</symbol>
<symbol id="moon-stars-fill" viewBox="0 0 16 16">
<path
d="M6 .278a.768.768 0 0 1 .08.858 7.208 7.208 0 0 0-.878 3.46c0 4.021 3.278 7.277 7.318 7.277.527 0 1.04-.055 1.533-.16a.787.787 0 0 1 .81.316.733.733 0 0 1-.031.893A8.349 8.349 0 0 1 8.344 16C3.734 16 0 12.286 0 7.71 0 4.266 2.114 1.312 5.124.06A.752.752 0 0 1 6 .278z">
</path>
<path
d="M10.794 3.148a.217.217 0 0 1 .412 0l.387 1.162c.173.518.579.924 1.097 1.097l1.162.387a.217.217 0 0 1 0 .412l-1.162.387a1.734 1.734 0 0 0-1.097 1.097l-.387 1.162a.217.217 0 0 1-.412 0l-.387-1.162A1.734 1.734 0 0 0 9.31 6.593l-1.162-.387a.217.217 0 0 1 0-.412l1.162-.387a1.734 1.734 0 0 0 1.097-1.097l.387-1.162zM13.863.099a.145.145 0 0 1 .274 0l.258.774c.115.346.386.617.732.732l.774.258a.145.145 0 0 1 0 .274l-.774.258a1.156 1.156 0 0 0-.732.732l-.258.774a.145.145 0 0 1-.274 0l-.258-.774a1.156 1.156 0 0 0-.732-.732l-.774-.258a.145.145 0 0 1 0-.274l.774-.258c.346-.115.617-.386.732-.732L13.863.1z">
</path>
</symbol>
<symbol id="sun-fill" viewBox="0 0 16 16">
<path
d="M8 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM8 0a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 0zm0 13a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 13zm8-5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2a.5.5 0 0 1 .5.5zM3 8a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2A.5.5 0 0 1 3 8zm10.657-5.657a.5.5 0 0 1 0 .707l-1.414 1.415a.5.5 0 1 1-.707-.708l1.414-1.414a.5.5 0 0 1 .707 0zm-9.193 9.193a.5.5 0 0 1 0 .707L3.05 13.657a.5.5 0 0 1-.707-.707l1.414-1.414a.5.5 0 0 1 .707 0zm9.193 2.121a.5.5 0 0 1-.707 0l-1.414-1.414a.5.5 0 0 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .707zM4.464 4.465a.5.5 0 0 1-.707 0L2.343 3.05a.5.5 0 1 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .708z">
</path>
</symbol>
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
<symbol id="circle-half" viewBox="0 0 16 16">
<path d="M8 15A7 7 0 1 0 8 1v14zm0 1A8 8 0 1 1 8 0a8 8 0 0 1 0 16z"></path>
</symbol>
<symbol id="moon-stars-fill" viewBox="0 0 16 16">
<path
d="M6 .278a.768.768 0 0 1 .08.858 7.208 7.208 0 0 0-.878 3.46c0 4.021 3.278 7.277 7.318 7.277.527 0 1.04-.055 1.533-.16a.787.787 0 0 1 .81.316.733.733 0 0 1-.031.893A8.349 8.349 0 0 1 8.344 16C3.734 16 0 12.286 0 7.71 0 4.266 2.114 1.312 5.124.06A.752.752 0 0 1 6 .278z">
</path>
<path
d="M10.794 3.148a.217.217 0 0 1 .412 0l.387 1.162c.173.518.579.924 1.097 1.097l1.162.387a.217.217 0 0 1 0 .412l-1.162.387a1.734 1.734 0 0 0-1.097 1.097l-.387 1.162a.217.217 0 0 1-.412 0l-.387-1.162A1.734 1.734 0 0 0 9.31 6.593l-1.162-.387a.217.217 0 0 1 0-.412l1.162-.387a1.734 1.734 0 0 0 1.097-1.097l.387-1.162zM13.863.099a.145.145 0 0 1 .274 0l.258.774c.115.346.386.617.732.732l.774.258a.145.145 0 0 1 0 .274l-.774.258a1.156 1.156 0 0 0-.732.732l-.258.774a.145.145 0 0 1-.274 0l-.258-.774a1.156 1.156 0 0 0-.732-.732l-.774-.258a.145.145 0 0 1 0-.274l.774-.258c.346-.115.617-.386.732-.732L13.863.1z">
</path>
</symbol>
<symbol id="sun-fill" viewBox="0 0 16 16">
<path
d="M8 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM8 0a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 0zm0 13a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 13zm8-5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2a.5.5 0 0 1 .5.5zM3 8a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2A.5.5 0 0 1 3 8zm10.657-5.657a.5.5 0 0 1 0 .707l-1.414 1.415a.5.5 0 1 1-.707-.708l1.414-1.414a.5.5 0 0 1 .707 0zm-9.193 9.193a.5.5 0 0 1 0 .707L3.05 13.657a.5.5 0 0 1-.707-.707l1.414-1.414a.5.5 0 0 1 .707 0zm9.193 2.121a.5.5 0 0 1-.707 0l-1.414-1.414a.5.5 0 0 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .707zM4.464 4.465a.5.5 0 0 1-.707 0L2.343 3.05a.5.5 0 1 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .708z">
</path>
</symbol>
</svg>
<button
class="btn dropdown-toggle"
id="bd-theme" type="button" aria-expanded="false" data-bs-toggle="dropdown"
data-bs-display="static" aria-label='{{t .Lang "Toggle theme (light)"}}'>
<svg class="bi my-1 theme-icon-active" fill="currentColor">
<use href="#sun-fill"></use>
</svg>
<button
class="btn btn-link nav-link py-2 px-0 px-lg-2 dropdown-toggle d-flex align-items-center"
id="bd-theme" type="button" aria-expanded="false" data-bs-toggle="dropdown"
data-bs-display="static" aria-label='{{t .Lang "Toggle theme (light)"}}'>
<svg class="bi my-1 theme-icon-active" fill="currentColor">
<use href="#sun-fill"></use>
</svg>
</button>
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="bd-theme-text">
<li>
<button type="button" class="dropdown-item d-flex align-items-center active"
data-bs-theme-value="light" aria-pressed="true">
<svg class="bi me-2 opacity-50 theme-icon" fill="currentColor">
<use href="#sun-fill"></use>
</svg>
{{t .Lang "Light"}}
</button>
</li>
<li>
<button type="button" class="dropdown-item d-flex align-items-center"
data-bs-theme-value="dark" aria-pressed="false">
<svg class="bi me-2 opacity-50 theme-icon" fill="currentColor">
<use href="#moon-stars-fill"></use>
</svg>
{{t .Lang "Dark"}}
</button>
</li>
<li>
<button type="button" class="dropdown-item d-flex align-items-center"
data-bs-theme-value="auto" aria-pressed="false">
<svg class="bi me-2 opacity-50 theme-icon" fill="currentColor">
<use href="#circle-half"></use>
</svg>
{{t .Lang "Auto"}}
</button>
</li>
</ul>
</li>
</button>
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="bd-theme-text">
<li>
<button type="button" class="dropdown-item d-flex align-items-center active"
data-bs-theme-value="light" aria-pressed="true">
<svg class="bi me-2 opacity-50 theme-icon" fill="currentColor">
<use href="#sun-fill"></use>
</svg>
{{t .Lang "Light"}}
</button>
</li>
<li>
<button type="button" class="dropdown-item d-flex align-items-center"
data-bs-theme-value="dark" aria-pressed="false">
<svg class="bi me-2 opacity-50 theme-icon" fill="currentColor">
<use href="#moon-stars-fill"></use>
</svg>
{{t .Lang "Dark"}}
</button>
</li>
<li>
<button type="button" class="dropdown-item d-flex align-items-center"
data-bs-theme-value="auto" aria-pressed="false">
<svg class="bi me-2 opacity-50 theme-icon" fill="currentColor">
<use href="#circle-half"></use>
</svg>
{{t .Lang "Auto"}}
</button>
</li>
</ul>

22 changes: 13 additions & 9 deletions internal/webserver/embedded/views/partials/latest-highlights.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
<div class="col-9">
<h2>{{t .Lang "Your highlights" }}</h2>
<div class="row border-bottom mb-3">
<div class="col-9">
<h2>{{t .Lang "Your highlights" }}</h2>
</div>

{{if gt (len .Highlights) 0}}
<div class="col-3 text-end">
<a href="/highlights">
{{t .Lang "See all" }}
</a>
</div>
{{end}}
</div>

{{if gt (len .Highlights) 0}}
<div class="col-3 text-end">
<a href="/highlights">
{{t .Lang "See all" }}
</a>
</div>

<div class="row mt-3 pe-0 align-items-end">
<div class="row pe-0 align-items-end">
{{$lang := .Lang}}
{{$emailSendingConfigured := .EmailSendingConfigured}}
{{$session := .Session}}
Expand Down
Loading