Skip to content

Commit aeeb245

Browse files
committed
Show the burger menu by default and move menu items into it, as this is getting way too much
Signed-off-by: Kai Wagner <kai.wagner@percona.com>
1 parent 32c9683 commit aeeb245

File tree

8 files changed

+126
-32
lines changed

8 files changed

+126
-32
lines changed

app/assets/stylesheets/components/navigation.css

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,8 @@
197197
}
198198

199199
.nav-overflow-dropdown {
200-
display: none;
201-
position: relative;
202-
}
203-
204-
.nav-overflow-dropdown.is-visible {
205200
display: inline-flex;
201+
position: relative;
206202
}
207203

208204
.nav-overflow-toggle {

app/assets/stylesheets/components/settings.css

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,57 @@
118118
border-color: var(--color-border);
119119
}
120120

121+
.theme-choice {
122+
display: flex;
123+
align-items: center;
124+
justify-content: space-between;
125+
gap: var(--spacing-6);
126+
padding: var(--spacing-3) var(--spacing-4);
127+
border-radius: 999px;
128+
background: var(--color-bg-card);
129+
border: var(--border-width) solid var(--color-border);
130+
}
131+
132+
.theme-choice-label {
133+
font-weight: var(--font-weight-medium);
134+
color: var(--color-text-primary);
135+
}
136+
137+
.theme-choice-buttons {
138+
display: inline-flex;
139+
align-items: center;
140+
gap: var(--spacing-2);
141+
}
142+
143+
.theme-choice-button {
144+
display: inline-flex;
145+
align-items: center;
146+
gap: var(--spacing-2);
147+
padding: var(--spacing-2) var(--spacing-4);
148+
border-radius: 999px;
149+
border: var(--border-width) solid var(--color-border);
150+
background: var(--color-bg-page);
151+
color: var(--color-text-secondary);
152+
cursor: pointer;
153+
transition: background-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
154+
}
155+
156+
.theme-choice-button:hover {
157+
background: var(--color-bg-hover);
158+
box-shadow: var(--shadow-sm);
159+
transform: translateY(-1px);
160+
}
161+
162+
.theme-choice-button.is-active {
163+
background: var(--color-bg-button);
164+
color: var(--color-text-button);
165+
border-color: transparent;
166+
}
167+
168+
.theme-choice-button.is-active i {
169+
color: currentColor;
170+
}
171+
121172
.settings-page .button-secondary:hover {
122173
border-color: var(--color-primary-300);
123174
box-shadow: var(--shadow-sm);

app/assets/stylesheets/components/sidebar.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@
166166
}
167167
}
168168

169+
.sidebar .tags-list {
170+
padding-left: var(--spacing-3);
171+
}
172+
169173
.sidebar .attachments-list {
170174
list-style: none;
171175
padding-left: 0;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Controller } from "@hotwired/stimulus"
2+
3+
export default class extends Controller {
4+
connect() {
5+
this.onDocumentClick = this.handleDocumentClick.bind(this)
6+
document.addEventListener("click", this.onDocumentClick)
7+
}
8+
9+
disconnect() {
10+
document.removeEventListener("click", this.onDocumentClick)
11+
}
12+
13+
handleDocumentClick(event) {
14+
if (!this.element.open) return
15+
if (this.element.contains(event.target)) return
16+
this.element.removeAttribute("open")
17+
}
18+
}

app/javascript/controllers/theme_controller.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,26 @@ const STORAGE_KEY = "hackorum-theme"
44
const DEFAULT_THEME = "light"
55

66
export default class extends Controller {
7-
static targets = ["icon", "label"]
7+
static targets = ["icon", "label", "button"]
88

99
connect() {
1010
this.applyInitialTheme()
1111
}
1212

1313
toggle(event) {
14-
event.preventDefault()
14+
if (event && event.type !== "change") {
15+
event.preventDefault()
16+
}
1517
const nextTheme = this.currentTheme === "dark" ? "light" : "dark"
1618
this.setTheme(nextTheme)
1719
}
1820

21+
select(event) {
22+
event.preventDefault()
23+
const { themeValue } = event.currentTarget.dataset
24+
this.setTheme(themeValue)
25+
}
26+
1927
applyInitialTheme() {
2028
const storedTheme = window.localStorage.getItem(STORAGE_KEY)
2129
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches
@@ -47,6 +55,12 @@ export default class extends Controller {
4755

4856
this.element.setAttribute("aria-pressed", theme === "dark")
4957
this.element.setAttribute("title", `Switch to ${theme === "dark" ? "light" : "dark"} mode`)
58+
59+
if (this.hasButtonTarget) {
60+
this.buttonTargets.forEach((button) => {
61+
button.classList.toggle("is-active", button.dataset.themeValue === theme)
62+
})
63+
}
5064
}
5165

5266
get currentTheme() {

app/views/layouts/application.html.slim

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ html data-theme="light"
4343
span Please set a username in Settings.
4444
- starred_active = controller_name == "topics" && action_name == "index" && params[:filter].to_s == "starred_by_me"
4545
nav.main-navigation
46-
.nav-container data-controller="nav-overflow" data-nav-overflow-target="container"
46+
.nav-container
4747
.nav-brand
4848
- if content_for?(:sidebar)
4949
button.nav-burger type="button" aria-label="Toggle sidebar" data-action="click->sidebar#toggleMobile"
@@ -68,9 +68,6 @@ html data-theme="light"
6868
= link_to "Statistics", stats_path, class: "nav-link"
6969
= link_to "Reports", reports_path, class: "nav-link"
7070
= link_to "Help", help_index_path, class: "nav-link"
71-
button.nav-link.theme-toggle type="button" aria-label="Toggle theme" data-controller="theme" data-action="click->theme#toggle"
72-
i.fas.fa-moon data-theme-target="icon"
73-
span data-theme-target="label" Theme
7471
- if user_signed_in?
7572
- if current_user&.person&.default_alias
7673
= link_to current_user.person.default_alias.name, person_path(current_user.person.default_alias.email), class: "nav-link nav-user"
@@ -93,38 +90,39 @@ html data-theme="light"
9390
i.fa-regular.fa-bell
9491
- if unread.positive?
9592
span.nav-badge = unread
96-
.nav-menu data-nav-overflow-target="menu"
93+
.nav-menu
9794
.nav-links
98-
= link_to "Topics", topics_path, class: "nav-link", data: { "nav-overflow-target": "item" }
95+
= link_to "Topics", topics_path, class: "nav-link"
9996
- search_link = content_for?(:search_sidebar) ? "#search" : topics_path(anchor: "search")
100-
= link_to "Search", search_link, class: "nav-link", data: { "nav-overflow-target": "item" }
101-
= link_to "Statistics", stats_path, class: "nav-link", data: { "nav-overflow-target": "item" }
102-
= link_to "Reports", reports_path, class: "nav-link", data: { "nav-overflow-target": "item" }
103-
= link_to "Help", help_index_path, class: "nav-link", data: { "nav-overflow-target": "item" }
97+
= link_to "Search", search_link, class: "nav-link"
98+
= link_to "Reports", reports_path, class: "nav-link"
10499
.nav-right
105-
button.nav-link.theme-toggle type="button" aria-label="Toggle theme" data-controller="theme" data-action="click->theme#toggle" data-nav-overflow-target="item"
106-
i.fas.fa-moon data-theme-target="icon"
107-
span data-theme-target="label" Theme
108100
.nav-auth
109101
- if user_signed_in?
110102
- if current_user&.person&.default_alias
111-
= link_to current_user.person.default_alias.name, person_path(current_user.person.default_alias.email), class: "nav-link nav-user", data: { "nav-overflow-target": "item" }
103+
= link_to current_user.person.default_alias.name, person_path(current_user.person.default_alias.email), class: "nav-link nav-user"
112104
- unread = activity_unread_count
113-
= link_to activities_path, class: "nav-link nav-link-activity", title: "Activity", data: { "nav-overflow-target": "item" } do
105+
= link_to activities_path, class: "nav-link nav-link-activity", title: "Activity" do
114106
i.fa-regular.fa-bell
115107
- if unread.positive?
116108
span.nav-badge = unread
117-
= link_to "Settings", settings_root_path, class: "nav-link", data: { "nav-overflow-target": "item" }
118-
- if current_admin?
119-
= link_to "Admin", admin_root_path, class: "nav-link", data: { "nav-overflow-target": "item" }
120-
= button_to "Sign out", session_path, method: :delete, class: "nav-link", form: { style: 'display:inline', data: { "nav-overflow-target": "item" } }, data: { turbo: false }
121109
- else
122-
= link_to "Sign in", new_session_path, class: "nav-link", data: { "nav-overflow-target": "item" }
123-
= link_to "Register", new_registration_path, class: "nav-link", data: { "nav-overflow-target": "item" }
124-
details.nav-overflow-dropdown data-nav-overflow-target="overflow"
125-
summary.nav-link.nav-overflow-toggle aria-label="More" data-action="click->sidebar#closeMenuOnNavigate"
110+
= link_to "Sign in", new_session_path, class: "nav-link"
111+
= link_to "Register", new_registration_path, class: "nav-link"
112+
details.nav-overflow-dropdown data-controller="nav-dropdown"
113+
summary.nav-link.nav-overflow-toggle aria-label="Menu" data-action="click->sidebar#closeMenuOnNavigate"
126114
i.fa-solid.fa-bars
127-
.nav-overflow-menu data-nav-overflow-target="overflowMenu"
115+
.nav-overflow-menu
116+
= link_to "Statistics", stats_path, class: "nav-link"
117+
= link_to "Help", help_index_path, class: "nav-link"
118+
- if user_signed_in?
119+
= link_to "Settings", settings_root_path, class: "nav-link"
120+
- if current_admin?
121+
= link_to "Admin", admin_root_path, class: "nav-link"
122+
= button_to "Sign out", session_path, method: :delete, class: "nav-link", form: { style: 'display:inline' }, data: { turbo: false }
123+
- else
124+
= link_to "Sign in", new_session_path, class: "nav-link"
125+
= link_to "Register", new_registration_path, class: "nav-link"
128126

129127
- if content_for?(:sidebar)
130128
.page-layout.with-sidebar data-sidebar-target="layout"

app/views/settings/profiles/show.html.slim

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@
1111
= f.text_field :username, placeholder: "your_name", value: current_user.username
1212
= f.submit "Save username", class: "button-primary"
1313

14+
.settings-section
15+
h2 Appearance
16+
p.settings-hint Choose your preferred theme.
17+
.theme-choice data-controller="theme"
18+
span.theme-choice-label Theme
19+
.theme-choice-buttons
20+
button.theme-choice-button type="button" data-theme-value="light" data-theme-target="button" data-action="click->theme#select"
21+
i.fa-solid.fa-sun aria-hidden="true"
22+
span Light
23+
button.theme-choice-button type="button" data-theme-value="dark" data-theme-target="button" data-action="click->theme#select"
24+
i.fa-regular.fa-moon aria-hidden="true"
25+
span Dark
26+
1427
.settings-section
1528
h2 Mention Settings
1629
p.settings-hint Control who can @mention you in notes.

app/views/topics/_sidebar.html.slim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@
3737
- if user_signed_in? && @available_note_tags.present?
3838
.sidebar-section
3939
h3.sidebar-heading My tags
40-
ul.quick-filters
40+
ul.quick-filters.tags-list
4141
- @available_note_tags.each do |tag, count|
4242
li = link_to "##{tag} (#{count})", topics_path(note_tag: tag)

0 commit comments

Comments
 (0)