-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.ts
44 lines (36 loc) · 988 Bytes
/
index.ts
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
import { provide, tag, Tag } from '@storefront/core';
import NavigationDisplay from '../navigation-display';
@provide('navigationHeader', (props) => props)
@tag('gb-navigation-header', require('./index.html'), require('./index.css'))
class NavigationHeader {
props: NavigationHeader.Props = <any>{
icons: {},
};
init() {
this.setIcon();
}
onUpdate() {
this.setIcon();
}
setIcon() {
this.state = { ...this.state, icon: this.toggleIcon() };
}
toggleIcon() {
const { isActive, icons } = this.props;
return isActive ? icons.toggleOpen : icons.toggleClosed;
}
}
interface NavigationHeader extends Tag<NavigationHeader.Props, NavigationHeader.State> {}
namespace NavigationHeader {
export interface Props extends Tag.Props {
icons: NavigationDisplay.Icons;
label: string;
isActive: boolean;
collapse: boolean;
onToggle: () => void;
}
export interface State {
icon: string;
}
}
export default NavigationHeader;