Skip to content

Commit c6bf487

Browse files
authored
Merge pull request #10 from angusmcleod/main
Merge fixes
2 parents f3561ce + 615482d commit c6bf487

File tree

7 files changed

+81
-75
lines changed

7 files changed

+81
-75
lines changed

common/common.scss

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,6 @@
2929
}
3030
}
3131

32-
&:hover {
33-
color: $main_link_hover_color;
34-
35-
.custom-header-dropdown {
36-
transform: scale(1);
37-
transition-delay: 0s;
38-
}
39-
40-
.custom-header-link-caret svg {
41-
transform: rotate(90deg);
42-
}
43-
}
44-
4532
&.with-url {
4633
cursor: pointer;
4734
}
@@ -54,8 +41,8 @@
5441
max-width: 280px;
5542
list-style: none;
5643
transform: scale(0);
57-
transition: transform 0.2s ease;
58-
transition-delay: 0.3s;
44+
/*transition: transform 0.2s ease;*/
45+
/*transition-delay: 0.3s;*/
5946

6047
&-link {
6148
color: $dropdown_item_color;

desktop/desktop.scss

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,21 @@
22
@media screen and (max-width: 712px) {
33
display: none;
44
}
5-
}
5+
6+
.top-level-links {
7+
.custom-header-link {
8+
&:hover {
9+
color: $main_link_hover_color;
10+
11+
.custom-header-dropdown {
12+
transform: scale(1);
13+
transition-delay: 0s;
14+
}
15+
16+
.custom-header-link-caret svg {
17+
transform: rotate(90deg);
18+
}
19+
}
20+
}
21+
}
22+
}

javascripts/discourse/api-initializers/dropdown-header.js.es6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default apiInitializer("0.11.1", (api) => {
1010
const links_position =
1111
settings.links_position === "right"
1212
? "header-buttons:before"
13-
: "home-logo:after";
13+
: "header-contents:after";
1414

1515
api.decorateWidget(links_position, (helper) => {
1616
const scrolling = helper.attrs.minimized;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ createWidget('custom-header-dropdown', {
2525

2626
click() {
2727
if (this.site.mobileView) {
28-
this.sendWidgetAction("showHeaderLinks"); // in mobile view, close menu on click
28+
this.sendWidgetAction("toggleDropdown"); // in mobile view, close menu on click
2929
}
3030
DiscourseURL.routeTo(this.attrs.url);
3131
},

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

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ createWidget("custom-header-link", {
99
tagName: "li.custom-header-link",
1010
buildKey: (attrs) => `custom-header-link-${attrs.id}`,
1111

12+
defaultState() {
13+
let showDropdown = false;
14+
15+
return {
16+
showDropdown,
17+
};
18+
},
19+
1220
html(attrs) {
1321
const iconHTML = buildIconHTML(attrs.icon);
1422
const titleHTML = h("span.custom-header-link-title", attrs.title);
@@ -51,7 +59,7 @@ createWidget("custom-header-link", {
5159
};
5260
},
5361

54-
buildClasses(attrs) {
62+
buildClasses(attrs, state) {
5563
const classes = [];
5664

5765
if (attrs.url) {
@@ -62,6 +70,10 @@ createWidget("custom-header-link", {
6270
classes.push("has-dropdown");
6371
}
6472

73+
if (state.showDropdown) {
74+
classes.push("show-dropdown");
75+
}
76+
6577
return classes;
6678
},
6779

@@ -108,9 +120,18 @@ createWidget("custom-header-link", {
108120
return h("span.custom-header-link-caret", iconNode("caret-down"));
109121
},
110122

123+
clickOutside() {
124+
this.state.showDropdown = false;
125+
this.scheduleRerender();
126+
},
127+
128+
toggleDropdown() {
129+
this.state.showDropdown = !this.state.showDropdown;
130+
},
131+
111132
click() {
112133
if (this.site.mobileView) {
113-
this.sendWidgetAction("showHeaderLinks"); // in mobile view, close menu on click
134+
this.toggleDropdown();
114135
}
115136
DiscourseURL.routeTo(this.attrs.url);
116137
},

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

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,36 @@ createWidget('custom-header-links', {
2525
},
2626

2727
defaultState() {
28-
let showLinks = !this.site.mobileView;
29-
const mobileView = this.site.mobileView;
28+
//let showLinks = !this.site.mobileView;
29+
let showLinks = true;
30+
//const mobileView = this.site.mobileView;
31+
const mobileView = false;
3032

3133
return {
3234
mobileView,
3335
showLinks,
3436
};
3537
},
3638

37-
toggleHeaderLinks() {
38-
this.state.showLinks = !this.state.showLinks;
39-
if (this.state.showLinks) {
40-
document.body.classList.add("dropdown-header-open");
41-
} else {
42-
document.body.classList.remove("dropdown-header-open");
43-
}
44-
},
39+
// toggleHeaderLinks() {
40+
// this.state.showLinks = !this.state.showLinks;
41+
// if (this.state.showLinks) {
42+
// document.body.classList.add("dropdown-header-open");
43+
// } else {
44+
// document.body.classList.remove("dropdown-header-open");
45+
// }
46+
// },
4547

46-
clickOutside() {
47-
if (this.site.desktopView) {
48-
return;
49-
}
48+
// clickOutside() {
49+
// if (this.site.desktopView) {
50+
// return;
51+
// }
5052

51-
if (this.state.showLinks) {
52-
this.sendWidgetAction("toggleHeaderLinks");
53-
}
54-
},
53+
// if (this.state.showLinks) {
54+
// this.sendWidgetAction("toggleHeaderLinks");
55+
// return;
56+
// }
57+
// },
5558

5659
template: hbs`
5760
{{#if this.state.mobileView}}

mobile/mobile.scss

Lines changed: 15 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,22 @@
11
@import "mixins";
22

33
.mobile-view {
4-
.top-level-links {
5-
@include dropdown;
6-
position: fixed;
7-
left: 0;
8-
margin: 0;
9-
top: var(--header-offset);
10-
width: 100%;
11-
flex-flow: row wrap;
12-
align-items: flex-start;
13-
justify-content: flex-start;
14-
overflow: scroll;
15-
max-height: 90vh;
16-
17-
li {
18-
width: 100%;
19-
20-
@media screen and (min-width: 768px) {
21-
width: auto;
4+
.custom-header-links {
5+
.top-level-links {
6+
.custom-header-link {
7+
&.show-dropdown {
8+
color: $main_link_hover_color;
9+
10+
.custom-header-dropdown {
11+
transform: scale(1);
12+
transition-delay: 0s;
13+
}
14+
15+
.custom-header-link-caret svg {
16+
transform: rotate(90deg);
17+
}
18+
}
2219
}
2320
}
2421
}
25-
26-
.custom-header-dropdown {
27-
display: block;
28-
position: initial;
29-
transform: scale(1);
30-
box-shadow: none;
31-
margin-top: 1rem;
32-
min-width: unset;
33-
34-
.custom-header-link-desc {
35-
display: none;
36-
}
37-
}
38-
39-
.dropdown-header-open {
40-
overflow-y: hidden;
41-
height: 100vh;
42-
position: fixed;
43-
}
4422
}

0 commit comments

Comments
 (0)