Skip to content

Commit d284801

Browse files
authored
Rework the sidebar collapsing mechanism (#101)
Signed-off-by: Kai Wagner <kai.wagner@percona.com>
1 parent d93cc48 commit d284801

7 files changed

Lines changed: 48 additions & 15 deletions

File tree

app/assets/stylesheets/base/root.css

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ body.sidebar-resizing {
6262
}
6363

6464
body.sidebar-collapsed .page-layout.with-sidebar {
65-
grid-template-columns: 0 var(--sidebar-resizer-width) minmax(0, 1fr);
65+
grid-template-columns: 0 0 minmax(0, 1fr);
6666
}
6767

6868
body.sidebar-collapsed .layout-sidebar {
@@ -71,8 +71,7 @@ body.sidebar-collapsed .layout-sidebar {
7171
}
7272

7373
body.sidebar-collapsed .layout-sidebar-resizer {
74-
border-left: var(--border-width) solid var(--color-border);
75-
justify-self: start;
74+
display: none;
7675
}
7776

7877
body.sidebar-collapsed .page-layout.with-sidebar > main.container {

app/assets/stylesheets/components/sidebar.css

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,56 @@
1414
justify-content: center;
1515
}
1616

17-
.sidebar-collapse-button {
17+
.topics-table th.topic-title .sidebar-burger-button,
18+
.topic-title-with-star .sidebar-burger-button {
19+
display: none;
20+
margin-right: var(--spacing-2);
21+
}
22+
23+
.sidebar-toggle-bar {
24+
display: flex;
25+
justify-content: flex-end;
26+
padding: var(--spacing-2) var(--spacing-3);
27+
position: sticky;
28+
top: var(--nav-height);
29+
z-index: 10;
30+
background: var(--color-bg-sidebar);
31+
border-bottom: var(--border-width) solid var(--color-border);
32+
}
33+
34+
.sidebar-burger-button {
1835
border: none;
1936
background: var(--color-bg-card);
2037
color: var(--color-text-secondary);
21-
width: 28px;
22-
height: 28px;
38+
width: 32px;
39+
height: 32px;
2340
border-radius: 999px;
2441
box-shadow: var(--shadow-sm);
2542
cursor: pointer;
2643
display: inline-flex;
2744
align-items: center;
2845
justify-content: center;
46+
font-size: 14px;
2947
transition: transform var(--transition-fast), background-color var(--transition-fast);
3048
z-index: 1;
3149
}
3250

33-
.sidebar-collapse-button:hover {
51+
.sidebar-burger-button:hover {
3452
background: var(--color-bg-hover);
3553
transform: scale(1.05);
3654
}
3755

56+
57+
@media (max-width: 900px) {
58+
.sidebar-toggle-bar {
59+
display: none;
60+
}
61+
}
62+
3863
@media (max-width: 720px) {
3964
.layout-sidebar-resizer {
4065
width: 18px;
4166
}
42-
43-
.sidebar-collapse-button {
44-
width: 48px;
45-
height: 48px;
46-
}
4767
}
4868

4969
@media (max-width: 900px) {

app/assets/stylesheets/components/topics.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@
8686
font-size: var(--font-size-base);
8787
}
8888

89+
body.sidebar-collapsed .topics-table th.topic-title .sidebar-burger-button {
90+
display: inline-flex;
91+
}
92+
8993
.topics-table {
9094
& table {
9195
width: 100%;

app/assets/stylesheets/layouts/topic-view.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
margin-top: var(--spacing-4);
1414
}
1515

16+
body.sidebar-collapsed .topic-title-with-star .sidebar-burger-button {
17+
display: inline-flex;
18+
}
19+
1620
.topic-title-section {
1721
margin-bottom: var(--spacing-5);
1822

app/views/layouts/application.html.slim

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,11 @@ html data-theme="light"
127127
- if content_for?(:sidebar)
128128
.page-layout.with-sidebar data-sidebar-target="layout"
129129
.layout-sidebar#layout-sidebar data-sidebar-target="sidebar" data-action="click->sidebar#closeOnNavigate"
130+
.sidebar-toggle-bar
131+
button.sidebar-burger-button type="button" aria-label="Toggle sidebar" data-action="click->sidebar#toggle"
132+
i.fa-solid.fa-bars aria-hidden="true"
130133
= yield :sidebar
131134
.layout-sidebar-resizer data-sidebar-target="resizer" role="separator" aria-orientation="vertical" aria-label="Resize sidebar" data-action="mousedown->sidebar#startResize touchstart->sidebar#startResize"
132-
button.sidebar-collapse-button type="button" aria-label="Toggle sidebar" data-action="click->sidebar#toggle" data-sidebar-target="toggleButton"
133-
span data-sidebar-target="toggleIcon"
134135
.layout-sidebar-overlay data-sidebar-target="overlay" data-action="click->sidebar#closeMobile"
135136
main.container
136137
- flash.each do |type, message|

app/views/topics/index.html.slim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
table
77
thead
88
tr
9-
th.topic-title Topic
9+
th.topic-title
10+
button.sidebar-burger-button type="button" aria-label="Expand sidebar" data-action="click->sidebar#toggle"
11+
i.fa-solid.fa-bars aria-hidden="true"
12+
| Topic
1013
th.activity-header Activity
1114
th.participants-header Participants
1215
tbody#topics

app/views/topics/show.html.slim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@
166166
.topic-header
167167
.topic-title-section
168168
.topic-title-with-star
169+
button.sidebar-burger-button type="button" aria-label="Expand sidebar" data-action="click->sidebar#toggle"
170+
i.fa-solid.fa-bars aria-hidden="true"
169171
- if user_signed_in?
170172
= render "star_button", topic: @topic, starred: @is_starred
171173
h1 = @topic.title

0 commit comments

Comments
 (0)