Skip to content

Commit db81368

Browse files
Gargronhiyuki2578
authored andcommitted
Fix page body not being scrollable in admin layout (mastodon#11893)
Hide navigation behind hamburger icon on small screens in admin layout
1 parent fe2c5e3 commit db81368

4 files changed

Lines changed: 142 additions & 29 deletions

File tree

app/javascript/packs/public.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,16 @@ function main() {
247247

248248
input.readonly = oldReadOnly;
249249
});
250+
251+
delegate(document, '.sidebar__toggle__icon', 'click', () => {
252+
const target = document.querySelector('.sidebar ul');
253+
254+
if (target.style.display === 'block') {
255+
target.style.display = 'none';
256+
} else {
257+
target.style.display = 'block';
258+
}
259+
});
250260
}
251261

252262
loadPolyfills().then(main).catch(error => {

app/javascript/styles/mastodon/admin.scss

Lines changed: 116 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,66 @@ $content-width: 840px;
55
.admin-wrapper {
66
display: flex;
77
justify-content: center;
8-
height: 100%;
8+
width: 100%;
9+
min-height: 100vh;
910

1011
.sidebar-wrapper {
11-
flex: 1 1 $sidebar-width;
12-
height: 100%;
13-
background: $ui-base-color;
14-
display: flex;
15-
justify-content: flex-end;
12+
min-height: 100vh;
13+
overflow: hidden;
14+
pointer-events: none;
15+
flex: 1 1 auto;
16+
17+
&__inner {
18+
display: flex;
19+
justify-content: flex-end;
20+
background: $ui-base-color;
21+
height: 100%;
22+
}
1623
}
1724

1825
.sidebar {
1926
width: $sidebar-width;
20-
height: 100%;
2127
padding: 0;
22-
overflow-y: auto;
28+
pointer-events: auto;
29+
30+
&__toggle {
31+
display: none;
32+
background: lighten($ui-base-color, 8%);
33+
height: 48px;
34+
35+
&__logo {
36+
flex: 1 1 auto;
37+
38+
a {
39+
display: inline-block;
40+
padding: 15px;
41+
}
42+
43+
svg {
44+
fill: $primary-text-color;
45+
height: 20px;
46+
position: relative;
47+
bottom: -2px;
48+
}
49+
}
50+
51+
&__icon {
52+
display: block;
53+
color: $darker-text-color;
54+
text-decoration: none;
55+
flex: 0 0 auto;
56+
font-size: 20px;
57+
padding: 15px;
58+
}
59+
60+
a {
61+
&:hover,
62+
&:focus,
63+
&:active {
64+
background: lighten($ui-base-color, 12%);
65+
}
66+
}
67+
}
2368

2469
.logo {
2570
display: block;
@@ -52,6 +97,9 @@ $content-width: 840px;
5297
transition: all 200ms linear;
5398
transition-property: color, background-color;
5499
border-radius: 4px 0 0 4px;
100+
white-space: nowrap;
101+
overflow: hidden;
102+
text-overflow: ellipsis;
55103

56104
i.fa {
57105
margin-right: 5px;
@@ -99,12 +147,30 @@ $content-width: 840px;
99147
}
100148

101149
.content-wrapper {
102-
flex: 2 1 $content-width;
103-
overflow: auto;
150+
box-sizing: border-box;
151+
width: 100%;
152+
max-width: $content-width;
153+
flex: 1 1 auto;
154+
}
155+
156+
@media screen and (max-width: $content-width + $sidebar-width) {
157+
.sidebar-wrapper--empty {
158+
display: none;
159+
}
160+
161+
.sidebar-wrapper {
162+
width: $sidebar-width;
163+
flex: 0 0 auto;
164+
}
165+
}
166+
167+
@media screen and (max-width: $no-columns-breakpoint) {
168+
.sidebar-wrapper {
169+
width: 100%;
170+
}
104171
}
105172

106173
.content {
107-
max-width: $content-width;
108174
padding: 20px 15px;
109175
padding-top: 60px;
110176
padding-left: 25px;
@@ -123,6 +189,12 @@ $content-width: 840px;
123189
padding-bottom: 40px;
124190
border-bottom: 1px solid lighten($ui-base-color, 8%);
125191
margin-bottom: 40px;
192+
193+
@media screen and (max-width: $no-columns-breakpoint) {
194+
border-bottom: 0;
195+
padding-bottom: 0;
196+
font-weight: 700;
197+
}
126198
}
127199

128200
h3 {
@@ -147,7 +219,7 @@ $content-width: 840px;
147219
font-size: 16px;
148220
color: $secondary-text-color;
149221
line-height: 28px;
150-
font-weight: 400;
222+
font-weight: 500;
151223
}
152224

153225
.fields-group h6 {
@@ -176,7 +248,7 @@ $content-width: 840px;
176248

177249
& > p {
178250
font-size: 14px;
179-
line-height: 18px;
251+
line-height: 21px;
180252
color: $secondary-text-color;
181253
margin-bottom: 20px;
182254

@@ -208,20 +280,42 @@ $content-width: 840px;
208280

209281
@media screen and (max-width: $no-columns-breakpoint) {
210282
display: block;
211-
overflow-y: auto;
212-
-webkit-overflow-scrolling: touch;
213283

214-
.sidebar-wrapper,
215-
.content-wrapper {
216-
flex: 0 0 auto;
217-
height: auto;
218-
overflow: initial;
284+
.sidebar-wrapper {
285+
min-height: 0;
219286
}
220287

221288
.sidebar {
222289
width: 100%;
223290
padding: 0;
224291
height: auto;
292+
293+
&__toggle {
294+
display: flex;
295+
}
296+
297+
& > ul {
298+
display: none;
299+
}
300+
301+
ul a,
302+
ul ul a {
303+
border-radius: 0;
304+
border-bottom: 1px solid lighten($ui-base-color, 4%);
305+
transition: none;
306+
307+
&:hover {
308+
transition: none;
309+
}
310+
}
311+
312+
ul ul {
313+
border-radius: 0;
314+
}
315+
316+
ul .simple-navigation-active-leaf a {
317+
border-bottom-color: $ui-highlight-color;
318+
}
225319
}
226320
}
227321
}
@@ -270,10 +364,10 @@ body,
270364

271365
.filter-subset {
272366
flex: 0 0 auto;
273-
margin: 0 40px 10px 0;
367+
margin: 0 40px 20px 0;
274368

275369
&:last-child {
276-
margin-bottom: 20px;
370+
margin-bottom: 30px;
277371
}
278372

279373
ul {

app/javascript/styles/mastodon/basics.scss

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,6 @@ body {
8686

8787
&.admin {
8888
background: darken($ui-base-color, 4%);
89-
position: fixed;
90-
width: 100%;
91-
height: 100%;
9289
padding: 0;
9390
}
9491

app/views/layouts/admin.html.haml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,21 @@
44
- content_for :content do
55
.admin-wrapper
66
.sidebar-wrapper
7-
.sidebar
8-
= link_to root_path do
9-
= image_pack_tag 'logo.svg', class: 'logo', alt: 'Mastodon'
7+
.sidebar-wrapper__inner
8+
.sidebar
9+
= link_to root_path do
10+
= image_pack_tag 'logo.svg', class: 'logo', alt: 'Mastodon'
11+
12+
.sidebar__toggle
13+
.sidebar__toggle__logo
14+
= link_to root_path do
15+
= svg_logo_full
16+
17+
= link_to '#', class: 'sidebar__toggle__icon' do
18+
= fa_icon 'bars'
19+
20+
= render_navigation
1021

11-
= render_navigation
1222
.content-wrapper
1323
.content
1424
%h2= yield :page_title
@@ -17,4 +27,6 @@
1727

1828
= yield
1929

30+
.sidebar-wrapper.sidebar-wrapper--empty
31+
2032
= render template: 'layouts/application'

0 commit comments

Comments
 (0)