forked from paviliondev/discourse-dropdown-header
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom-header-links.gjs
More file actions
72 lines (65 loc) · 1.91 KB
/
custom-header-links.gjs
File metadata and controls
72 lines (65 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { tracked } from "@glimmer/tracking";
import Component from "@ember/component";
import { hash } from "@ember/helper";
import { action } from "@ember/object";
import { inject as service } from "@ember/service";
import DButton from "discourse/components/d-button";
import concatClass from "discourse/helpers/concat-class";
import closeOnClickOutside from "discourse/modifiers/close-on-click-outside";
import i18n from "discourse-common/helpers/i18n";
import CustomHeaderLink from "./custom-header-link";
export default class CustomHeaderLinks extends Component {
@service siteSettings;
@service site;
@tracked showLinks = !this.site.mobileView;
@action
toggleHeaderLinks() {
this.showLinks = !this.showLinks;
if (this.showLinks) {
document.body.classList.add("dropdown-header-open");
} else {
document.body.classList.remove("dropdown-header-open");
}
}
get headerLinks() {
return JSON.parse(settings.header_links);
}
<template>
<nav
class={{concatClass
"custom-header-links"
(if @outletArgs.minimized "scrolling")
}}
>
{{#if this.site.mobileView}}
<span class="btn-custom-header-dropdown-mobile">
<DButton
@icon="square-caret-down"
@title={{i18n "custom_header.discord"}}
@action={{this.toggleHeaderLinks}}
/>
</span>
{{/if}}
{{#if this.showLinks}}
<ul
class="top-level-links"
{{(if
this.site.mobileView
(modifier
closeOnClickOutside
this.toggleHeaderLinks
(hash target=this.element)
)
)}}
>
{{#each this.headerLinks as |item|}}
<CustomHeaderLink
@item={{item}}
@toggleHeaderLinks={{this.toggleHeaderLinks}}
/>
{{/each}}
</ul>
{{/if}}
</nav>
</template>
}