Newer
Older
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
73
export interface MainMenu {
label: string;
url: string;
menuLinkId: string;
}
import {Component, Host, h, Element, Prop, State, Watch, Listen} from '@stencil/core';
@Component({
tag: 'hy-menu-main-group',
styleUrl: 'hy-menu-main-group.scss',
shadow: true,
})
export class HyMenuMainGroup {
@Element() el: HTMLElement;
@Prop() dataMainMenu: MainMenu[] | string;
@Prop() isMobile: boolean = false;
@State() isMenuOpen: boolean = false;
private _dataMainMenu: MainMenu[];
@Watch('dataMainMenu')
dataMainMenuWatcher(data: MainMenu[] | string) {
this._dataMainMenu = typeof data === 'string' ? JSON.parse(data) : data;
}
@Listen('click')
handleComponentClick(event) {
this.isMenuOpen = !this.isMenuOpen;
event.stopPropagation();
}
componentWillRender() {
this.dataMainMenuWatcher(this.dataMainMenu);
}
render() {
const white = 'var(--grayscale-white)';
return this.isMobile ? (
<div>Mobile Main Menu in Groups</div>
) : (
<Host
class={{
'menu--main-group': true,
'menu--main-group__is-open': this.isMenuOpen,
}}
>
<button
class={{
'menu--main-group__toggle': true,
'is-open': this.isMenuOpen,
}}
//aria-label={this.isMenuOpen ? this._labels['close'] : this._labels['open']}
>
<hy-icon class={'menu--main-group__globe-icon'} icon={'hy-icon-globe'} size={14} fill={white} />
<span>University main menu</span>
<hy-icon class={'menu--main-group__toggle__caret'} icon={'hy-icon-caret-down'} size={8} fill={white} />
</button>
<div
class={{
'menu--language__dropdown': true,
'is-open': this.isMenuOpen,
}}
>
{this._dataMainMenu.map((item) => {
return <a href={item.url}>{item.label}</a>;
})}
</div>
</Host>
);
}
}