Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge fixes #10

Merged
merged 20 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions common/common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,6 @@
}
}

&:hover {
color: $main_link_hover_color;

.custom-header-dropdown {
transform: scale(1);
transition-delay: 0s;
}

.custom-header-link-caret svg {
transform: rotate(90deg);
}
}

&.with-url {
cursor: pointer;
}
Expand All @@ -54,8 +41,8 @@
max-width: 280px;
list-style: none;
transform: scale(0);
transition: transform 0.2s ease;
transition-delay: 0.3s;
/*transition: transform 0.2s ease;*/
/*transition-delay: 0.3s;*/

&-link {
color: $dropdown_item_color;
Expand Down
19 changes: 18 additions & 1 deletion desktop/desktop.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,21 @@
@media screen and (max-width: 712px) {
display: none;
}
}

.top-level-links {
.custom-header-link {
&:hover {
color: $main_link_hover_color;

.custom-header-dropdown {
transform: scale(1);
transition-delay: 0s;
}

.custom-header-link-caret svg {
transform: rotate(90deg);
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default apiInitializer("0.11.1", (api) => {
const links_position =
settings.links_position === "right"
? "header-buttons:before"
: "home-logo:after";
: "header-contents:after";

api.decorateWidget(links_position, (helper) => {
const scrolling = helper.attrs.minimized;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ createWidget('custom-header-dropdown', {

click() {
if (this.site.mobileView) {
this.sendWidgetAction("showHeaderLinks"); // in mobile view, close menu on click
this.sendWidgetAction("toggleDropdown"); // in mobile view, close menu on click
}
DiscourseURL.routeTo(this.attrs.url);
},
Expand Down
25 changes: 23 additions & 2 deletions javascripts/discourse/widgets/custom-header-link.js.es6
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ createWidget("custom-header-link", {
tagName: "li.custom-header-link",
buildKey: (attrs) => `custom-header-link-${attrs.id}`,

defaultState() {
let showDropdown = false;

return {
showDropdown,
};
},

html(attrs) {
const iconHTML = buildIconHTML(attrs.icon);
const titleHTML = h("span.custom-header-link-title", attrs.title);
Expand Down Expand Up @@ -51,7 +59,7 @@ createWidget("custom-header-link", {
};
},

buildClasses(attrs) {
buildClasses(attrs, state) {
const classes = [];

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

if (state.showDropdown) {
classes.push("show-dropdown");
}

return classes;
},

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

clickOutside() {
this.state.showDropdown = false;
this.scheduleRerender();
},

toggleDropdown() {
this.state.showDropdown = !this.state.showDropdown;
},

click() {
if (this.site.mobileView) {
this.sendWidgetAction("showHeaderLinks"); // in mobile view, close menu on click
this.toggleDropdown();
}
DiscourseURL.routeTo(this.attrs.url);
},
Expand Down
39 changes: 21 additions & 18 deletions javascripts/discourse/widgets/custom-header-links.js.es6
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,36 @@ createWidget('custom-header-links', {
},

defaultState() {
let showLinks = !this.site.mobileView;
const mobileView = this.site.mobileView;
//let showLinks = !this.site.mobileView;
let showLinks = true;
//const mobileView = this.site.mobileView;
const mobileView = false;

return {
mobileView,
showLinks,
};
},

toggleHeaderLinks() {
this.state.showLinks = !this.state.showLinks;
if (this.state.showLinks) {
document.body.classList.add("dropdown-header-open");
} else {
document.body.classList.remove("dropdown-header-open");
}
},
// toggleHeaderLinks() {
// this.state.showLinks = !this.state.showLinks;
// if (this.state.showLinks) {
// document.body.classList.add("dropdown-header-open");
// } else {
// document.body.classList.remove("dropdown-header-open");
// }
// },

clickOutside() {
if (this.site.desktopView) {
return;
}
// clickOutside() {
// if (this.site.desktopView) {
// return;
// }

if (this.state.showLinks) {
this.sendWidgetAction("toggleHeaderLinks");
}
},
// if (this.state.showLinks) {
// this.sendWidgetAction("toggleHeaderLinks");
// return;
// }
// },

template: hbs`
{{#if this.state.mobileView}}
Expand Down
52 changes: 15 additions & 37 deletions mobile/mobile.scss
Original file line number Diff line number Diff line change
@@ -1,44 +1,22 @@
@import "mixins";

.mobile-view {
.top-level-links {
@include dropdown;
position: fixed;
left: 0;
margin: 0;
top: var(--header-offset);
width: 100%;
flex-flow: row wrap;
align-items: flex-start;
justify-content: flex-start;
overflow: scroll;
max-height: 90vh;

li {
width: 100%;

@media screen and (min-width: 768px) {
width: auto;
.custom-header-links {
.top-level-links {
.custom-header-link {
&.show-dropdown {
color: $main_link_hover_color;

.custom-header-dropdown {
transform: scale(1);
transition-delay: 0s;
}

.custom-header-link-caret svg {
transform: rotate(90deg);
}
}
}
}
}

.custom-header-dropdown {
display: block;
position: initial;
transform: scale(1);
box-shadow: none;
margin-top: 1rem;
min-width: unset;

.custom-header-link-desc {
display: none;
}
}

.dropdown-header-open {
overflow-y: hidden;
height: 100vh;
position: fixed;
}
}
Loading