Skip to content

Commit a568c4e

Browse files
authored
Improved navbar layout
1 parent 0dac580 commit a568c4e

File tree

4 files changed

+129
-122
lines changed

4 files changed

+129
-122
lines changed

Diff for: internal/webserver/controller/user/create.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
func (u *Controller) Create(c *fiber.Ctx) error {
1414
role, _ := strconv.Atoi(c.FormValue("role"))
1515
user := model.User{
16-
Name: c.FormValue("name"),
16+
Name: strings.TrimSpace(c.FormValue("name")),
1717
Username: strings.ToLower(c.FormValue("username")),
1818
Email: c.FormValue("email"),
1919
SendToEmail: c.FormValue("send-to-email"),

Diff for: internal/webserver/embedded/views/layout.html

+60-56
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
<body class="d-flex flex-column h-100" hx-ext="response-targets">
2727
<header>
28-
<nav class="navbar navbar-expand-md fixed-top {{if .HomeNavbar}}navbar-home{{end}}">
28+
<nav class="navbar navbar-expand-lg fixed-top {{if .HomeNavbar}}navbar-home{{end}}">
2929
<div class="container d-flex justify-content-end">
3030
{{if not .HomeNavbar}}
3131
<span class="navbar-brand mb-0 h1">
@@ -45,63 +45,49 @@
4545
data-bs-target="#offcanvasNavbar" aria-controls="offcanvasNavbar">
4646
<span class="navbar-toggler-icon"></span>
4747
</button>
48-
<div class="offcanvas offcanvas-end" tabindex="-1" id="offcanvasNavbar"
48+
<div class="offcanvas-lg offcanvas-end" tabindex="-1" id="offcanvasNavbar"
4949
aria-labelledby="offcanvasNavbarLabel">
5050
<div class="offcanvas-header">
51-
<h5 class="offcanvas-title" id="offcanvasNavbarLabel">Coreander</h5>
52-
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
51+
<h5 class="offcanvas-title" id="offcanvasNavbarLabel">
52+
<img src="/images/coreander-logo-small.png" alt="Logo" width="32" height="32" class="d-inline-block align-text-middle">
53+
{{.Session.Name}}
54+
</h5>
55+
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#offcanvasNavbar" aria-label="Close"></button>
5356
</div>
5457
<div class="offcanvas-body">
5558
<ul class="navbar-nav justify-content-end flex-grow-1 pe-3 text-start">
5659
{{if and (.Session) (ne .Session.Name "")}}
57-
<li class="nav-item dropdown">
58-
<button class="btn dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
59-
{{.Session.Name}}
60-
</button>
61-
<ul class="dropdown-menu">
62-
<li>
63-
{{if eq .Session.Role 2}}
64-
<a class="dropdown-item" href="/users">
65-
<i class="bi-person-fill"></i>
66-
67-
{{t .Lang "Users"}}
68-
</a>
69-
{{else}}
70-
<a class="dropdown-item" href="/users/{{.Session.Username}}">
71-
<i class="bi-person-fill"></i>
60+
<li class="p-2">
61+
{{if eq .Session.Role 2}}
62+
<a href="/users" class="link-underline link-underline-opacity-0">
63+
<i class="bi-person-fill"></i>
7264

73-
{{t .Lang "Update your profile"}}
74-
</a>
75-
{{end}}
76-
</li>
77-
<li>
78-
<a class="dropdown-item" href="/highlights">
79-
<i class="bi-star-fill"></i>
65+
{{t .Lang "Users"}}
66+
</a>
67+
{{else}}
68+
<a href="/users/{{.Session.Username}}" class="link-underline link-underline-opacity-0">
69+
<i class="bi-person-fill"></i>
8070

81-
{{t .Lang "Highlights"}}
82-
</a>
83-
</li>
84-
{{if eq .Session.Role 2}}
85-
<li>
86-
<a class="dropdown-item" href="/upload">
87-
<i class="bi-cloud-upload-fill"></i>
71+
{{t .Lang "Update your profile"}}
72+
</a>
73+
{{end}}
74+
</li>
75+
<li class="p-2">
76+
<a href="/highlights" class="link-underline link-underline-opacity-0">
77+
<i class="bi-star-fill"></i>
8878

89-
{{t .Lang "Upload document"}}
90-
</a>
91-
</li>
92-
{{end}}
93-
<li>
94-
<hr class="dropdown-divider">
95-
</li>
96-
<li>
97-
<a class="dropdown-item" href="/sessions" hx-delete="/sessions">
98-
<i class="bi-box-arrow-right"></i>
79+
{{t .Lang "Highlights"}}
80+
</a>
81+
</li>
82+
{{if eq .Session.Role 2}}
83+
<li class="p-2">
84+
<a href="/upload" class="link-underline link-underline-opacity-0">
85+
<i class="bi-cloud-upload-fill"></i>
9986

100-
{{t .Lang "Logout"}}
101-
</a>
102-
</li>
103-
</ul>
87+
{{t .Lang "Upload document"}}
88+
</a>
10489
</li>
90+
{{end}}
10591
{{else if not .DisableLoginLink}}
10692
<li class="p-2">
10793
<a href="/sessions/new">{{t .Lang "Login"}}</a>
@@ -111,17 +97,35 @@ <h5 class="offcanvas-title" id="offcanvasNavbarLabel">Coreander</h5>
11197
{{$lang := .Lang}}
11298
{{$URLPath := .URLPath}}
11399
{{$queryString := .QueryString}}
114-
{{range $i, $currentLang := .SupportedLanguages}}
115-
{{if eq $lang $currentLang}}
116-
<li class="p-2">{{uppercase $currentLang}}</li>
117-
{{else if eq $queryString ""}}
118-
<li class="p-2"><a href="{{$URLPath}}?l={{$currentLang}}">{{uppercase $currentLang}}</a></li>
119-
{{else}}
120-
<li class="p-2"><a href="{{$URLPath}}?{{$queryString}}&l={{$currentLang}}">{{uppercase $currentLang}}</a></li>
100+
<li class="nav-item dropdown">
101+
<button class="btn dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
102+
<i class="bi-globe"></i>
103+
</button>
104+
<ul class="dropdown-menu">
105+
{{range $i, $currentLang := .SupportedLanguages}}
106+
{{if eq $lang $currentLang}}
107+
<li class="dropdown-item">{{uppercase $currentLang}}</li>
108+
{{else if eq $queryString ""}}
109+
<li class="dropdown-item"><a href="{{$URLPath}}?l={{$currentLang}}">{{uppercase $currentLang}}</a></li>
110+
{{else}}
111+
<li class="dropdown-item"><a href="{{$URLPath}}?{{$queryString}}&l={{$currentLang}}">{{uppercase $currentLang}}</a></li>
112+
{{end}}
121113
{{end}}
122-
{{end}}
114+
</ul>
115+
</li>
116+
<li class="nav-item dropdown">
117+
{{template "partials/color-mode-toggle" dict "Lang" $lang}}
118+
</li>
119+
{{if and (.Session) (ne .Session.Name "")}}
123120
<hr class="d-lg-none">
124-
{{template "partials/color-mode-toggle" dict "Lang" $lang}}
121+
<li class="p-2">
122+
<a href="/sessions" hx-delete="/sessions" class="link-underline link-underline-opacity-0">
123+
<i class="bi-box-arrow-right"></i>
124+
125+
{{t .Lang "Logout"}}
126+
</a>
127+
</li>
128+
{{end}}
125129
</ul>
126130
</div>
127131
</div>
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,56 @@
1-
<li class="nav-item dropdown">
2-
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
3-
<symbol id="circle-half" viewBox="0 0 16 16">
4-
<path d="M8 15A7 7 0 1 0 8 1v14zm0 1A8 8 0 1 1 8 0a8 8 0 0 1 0 16z"></path>
5-
</symbol>
6-
<symbol id="moon-stars-fill" viewBox="0 0 16 16">
7-
<path
8-
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">
9-
</path>
10-
<path
11-
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">
12-
</path>
13-
</symbol>
14-
<symbol id="sun-fill" viewBox="0 0 16 16">
15-
<path
16-
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">
17-
</path>
18-
</symbol>
1+
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
2+
<symbol id="circle-half" viewBox="0 0 16 16">
3+
<path d="M8 15A7 7 0 1 0 8 1v14zm0 1A8 8 0 1 1 8 0a8 8 0 0 1 0 16z"></path>
4+
</symbol>
5+
<symbol id="moon-stars-fill" viewBox="0 0 16 16">
6+
<path
7+
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">
8+
</path>
9+
<path
10+
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">
11+
</path>
12+
</symbol>
13+
<symbol id="sun-fill" viewBox="0 0 16 16">
14+
<path
15+
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">
16+
</path>
17+
</symbol>
18+
</svg>
19+
<button
20+
class="btn dropdown-toggle"
21+
id="bd-theme" type="button" aria-expanded="false" data-bs-toggle="dropdown"
22+
data-bs-display="static" aria-label='{{t .Lang "Toggle theme (light)"}}'>
23+
<svg class="bi my-1 theme-icon-active" fill="currentColor">
24+
<use href="#sun-fill"></use>
1925
</svg>
20-
<button
21-
class="btn btn-link nav-link py-2 px-0 px-lg-2 dropdown-toggle d-flex align-items-center"
22-
id="bd-theme" type="button" aria-expanded="false" data-bs-toggle="dropdown"
23-
data-bs-display="static" aria-label='{{t .Lang "Toggle theme (light)"}}'>
24-
<svg class="bi my-1 theme-icon-active" fill="currentColor">
25-
<use href="#sun-fill"></use>
26-
</svg>
27-
</button>
28-
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="bd-theme-text">
29-
<li>
30-
<button type="button" class="dropdown-item d-flex align-items-center active"
31-
data-bs-theme-value="light" aria-pressed="true">
32-
<svg class="bi me-2 opacity-50 theme-icon" fill="currentColor">
33-
<use href="#sun-fill"></use>
34-
</svg>
35-
{{t .Lang "Light"}}
36-
</button>
37-
</li>
38-
<li>
39-
<button type="button" class="dropdown-item d-flex align-items-center"
40-
data-bs-theme-value="dark" aria-pressed="false">
41-
<svg class="bi me-2 opacity-50 theme-icon" fill="currentColor">
42-
<use href="#moon-stars-fill"></use>
43-
</svg>
44-
{{t .Lang "Dark"}}
45-
</button>
46-
</li>
47-
<li>
48-
<button type="button" class="dropdown-item d-flex align-items-center"
49-
data-bs-theme-value="auto" aria-pressed="false">
50-
<svg class="bi me-2 opacity-50 theme-icon" fill="currentColor">
51-
<use href="#circle-half"></use>
52-
</svg>
53-
{{t .Lang "Auto"}}
54-
</button>
55-
</li>
56-
</ul>
57-
</li>
26+
</button>
27+
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="bd-theme-text">
28+
<li>
29+
<button type="button" class="dropdown-item d-flex align-items-center active"
30+
data-bs-theme-value="light" aria-pressed="true">
31+
<svg class="bi me-2 opacity-50 theme-icon" fill="currentColor">
32+
<use href="#sun-fill"></use>
33+
</svg>
34+
{{t .Lang "Light"}}
35+
</button>
36+
</li>
37+
<li>
38+
<button type="button" class="dropdown-item d-flex align-items-center"
39+
data-bs-theme-value="dark" aria-pressed="false">
40+
<svg class="bi me-2 opacity-50 theme-icon" fill="currentColor">
41+
<use href="#moon-stars-fill"></use>
42+
</svg>
43+
{{t .Lang "Dark"}}
44+
</button>
45+
</li>
46+
<li>
47+
<button type="button" class="dropdown-item d-flex align-items-center"
48+
data-bs-theme-value="auto" aria-pressed="false">
49+
<svg class="bi me-2 opacity-50 theme-icon" fill="currentColor">
50+
<use href="#circle-half"></use>
51+
</svg>
52+
{{t .Lang "Auto"}}
53+
</button>
54+
</li>
55+
</ul>
56+

Diff for: internal/webserver/embedded/views/partials/latest-highlights.html

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
<div class="col-9">
2-
<h2>{{t .Lang "Your highlights" }}</h2>
1+
<div class="row border-bottom mb-3">
2+
<div class="col-9">
3+
<h2>{{t .Lang "Your highlights" }}</h2>
4+
</div>
5+
6+
{{if gt (len .Highlights) 0}}
7+
<div class="col-3 text-end">
8+
<a href="/highlights">
9+
{{t .Lang "See all" }}
10+
</a>
11+
</div>
12+
{{end}}
313
</div>
414

515
{{if gt (len .Highlights) 0}}
6-
<div class="col-3 text-end">
7-
<a href="/highlights">
8-
{{t .Lang "See all" }}
9-
</a>
10-
</div>
11-
12-
<div class="row mt-3 pe-0 align-items-end">
16+
<div class="row pe-0 align-items-end">
1317
{{$lang := .Lang}}
1418
{{$emailSendingConfigured := .EmailSendingConfigured}}
1519
{{$session := .Session}}

0 commit comments

Comments
 (0)