Skip to content

Commit dbdb422

Browse files
committed
UX: Update mobile styling
1 parent c995fbf commit dbdb422

File tree

6 files changed

+83
-47
lines changed

6 files changed

+83
-47
lines changed

common/common.scss

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
@mixin dropdown() {
2-
position: absolute;
3-
background-color: $dropdown_background_color;
4-
border: 1px solid $dropdown_border_color;
5-
box-shadow: 0 12px 12px rgba(0, 0, 0, 0.15);
6-
z-index: 1000;
7-
padding: 0.5em;
8-
top: var(--header-offset);
9-
}
1+
@import 'mixins';
2+
@import 'buttons';
103

114
.custom-header-links {
125
.top-level-links {
@@ -16,10 +9,6 @@
169
align-items: center;
1710
gap: 1rem;
1811

19-
@media screen and (max-width: 712px) {
20-
display: none;
21-
}
22-
2312
.custom-header-link {
2413
color: $main_link_color;
2514
padding-block: 1rem;
@@ -93,28 +82,3 @@
9382
.title .custom-header-links.scrolling {
9483
display: none;
9584
}
96-
97-
.mobile-view {
98-
.top-level-links {
99-
@include dropdown;
100-
left: 0;
101-
right: 0;
102-
margin: 0 auto;
103-
flex-direction: column;
104-
align-items: flex-start;
105-
justify-content: flex-start;
106-
}
107-
108-
.custom-header-dropdown {
109-
display: block;
110-
position: initial;
111-
transform: scale(1);
112-
box-shadow: none;
113-
margin-top: 1rem;
114-
min-width: unset;
115-
116-
.custom-header-link-desc {
117-
display: none;
118-
}
119-
}
120-
}

desktop/desktop.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.custom-header-links {
2+
@media screen and (max-width: 712px) {
3+
display: none;
4+
}
5+
}

javascripts/discourse/widgets/custom-header-links.js.es6

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ createWidget('custom-header-links', {
77

88
buildClasses(attrs) {
99
const { scrolling } = attrs;
10+
const classes = [];
1011

1112
if (scrolling) {
12-
return ['scrolling'];
13+
classes.push('scrolling');
1314
}
15+
16+
return classes;
1417
},
1518

1619
transform(attrs) {
@@ -22,7 +25,7 @@ createWidget('custom-header-links', {
2225
},
2326

2427
defaultState() {
25-
const showLinks = !this.site.mobileView;
28+
let showLinks = !this.site.mobileView;
2629
const mobileView = this.site.mobileView;
2730

2831
return {
@@ -37,13 +40,15 @@ createWidget('custom-header-links', {
3740

3841
template: hbs`
3942
{{#if this.state.mobileView}}
40-
{{attach
41-
widget="button"
42-
attrs=(hash
43-
action="showHeaderLinks"
44-
icon="caret-square-down"
45-
)
46-
}}
43+
<span class="btn-custom-header-dropdown-mobile">
44+
{{attach
45+
widget="button"
46+
attrs=(hash
47+
action="showHeaderLinks"
48+
icon="caret-square-down"
49+
)
50+
}}
51+
</span>
4752
{{/if}}
4853
{{#if this.state.showLinks}}
4954
<ul class="top-level-links">

mobile/mobile.scss

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
.mobile-view {
2+
.top-level-links {
3+
@include dropdown;
4+
position: fixed;
5+
left: 0;
6+
margin: 0;
7+
top: var(--header-offset);
8+
width: 100%;
9+
flex-flow: row wrap;
10+
align-items: flex-start;
11+
justify-content: flex-start;
12+
13+
li {
14+
width: 100%;
15+
16+
@media screen and (min-width: 768px) {
17+
width: auto;
18+
}
19+
}
20+
}
21+
22+
.custom-header-dropdown {
23+
display: block;
24+
position: initial;
25+
transform: scale(1);
26+
box-shadow: none;
27+
margin-top: 1rem;
28+
min-width: unset;
29+
30+
.custom-header-link-desc {
31+
display: none;
32+
}
33+
}
34+
}

scss/buttons.scss

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.btn-custom-header-dropdown-mobile {
2+
.btn {
3+
background: none;
4+
font-size: var(--font-up-4);
5+
color: var(--header_primary-low-mid);
6+
7+
.d-icon {
8+
color: var(--header_primary-low-mid);
9+
}
10+
11+
&:hover {
12+
background: var(--primary-low);
13+
14+
.d-icon {
15+
color: var(--primary-high);
16+
}
17+
}
18+
}
19+
}

scss/mixins.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@mixin dropdown() {
2+
position: absolute;
3+
background-color: $dropdown_background_color;
4+
border: 1px solid $dropdown_border_color;
5+
box-shadow: 0 12px 12px rgba(0, 0, 0, 0.15);
6+
z-index: 1000;
7+
padding: 0.5em;
8+
top: var(--header-offset);
9+
}

0 commit comments

Comments
 (0)