-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathHeader.jsx
132 lines (124 loc) · 3.82 KB
/
Header.jsx
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/**
* Header component.
* @module components/theme/Header/Header
*/
import React, { Component } from 'react';
import { Button, Container, Dropdown, Segment } from 'semantic-ui-react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { getVocabulary } from '@plone/volto/actions';
import { Icon } from '@plone/volto/components';
import HamburgerIcon from '@plone-collective/volto-educal-theme/../theme/themes/educal/assets/icons/Hamburger.svg';
import {
// Anontools,
// LanguageSelector,
Logo,
Navigation,
SearchWidget,
} from '@plone/volto/components';
const vocabulary = 'plone.app.vocabularies.Keywords';
/**
* Header component class.
* @class Header
* @extends Component
*/
class Header extends Component {
/**
* Property types.
* @property {Object} propTypes Property types.
* @static
*/
static propTypes = {
getVocabulary: PropTypes.func.isRequired,
pathname: PropTypes.string.isRequired,
token: PropTypes.string,
vocabularyItems: PropTypes.array.isRequired,
};
/**
* Default properties.
* @property {Object} defaultProps Default properties.
* @static
*/
static defaultProps = {
token: null,
};
componentWillReceiveProps(nextProps) {
if (nextProps.token && nextProps.token !== this.props.token) {
this.props.getVocabulary({ vocabNameOrURL: vocabulary });
}
}
/**
* Render method.
* @method render
* @returns {string} Markup for the component.
*/
render() {
return (
<Segment basic className="header-wrapper" role="banner">
<Container>
<div className="headerRoot">
<div className="headerLeft">
<div id="headerSiteLogo" className="logo">
<Logo />
</div>
<div className="headerLeftSeparator"></div>
{this.props.token && this.props.vocabularyItems.length > 0 ? (
<div className="headerCategoryContainer">
<div className="categoryIcon">
<Icon name={HamburgerIcon} size="16px" />
</div>
<div className="categoryPlaceholder">
<Dropdown text="Category" simple>
<Dropdown.Menu>
{this.props.vocabularyItems.map((item) => {
const label = item.label ? item.label : item.value;
return (
<Dropdown.Item
key={label}
text={label}
as="a"
href={`/search?Subject=${label}`}
/>
);
})}
</Dropdown.Menu>
</Dropdown>
</div>
</div>
) : null}
</div>
<div className="headerRight">
<div id="headerMenu">
<Navigation pathname={this.props.pathname} />
</div>
<div className="tools-search-wrapper headerSearch">
<SearchWidget />
</div>
<div className="headerButton">
<Button
primary
as="a"
// Add 'href' as per your requirements
// href="/login"
>
Try for free
</Button>
</div>
</div>
</div>
{/* <Anontools /> */}
</Container>
</Segment>
);
}
}
export default connect(
(state) => ({
token: state.userSession.token,
vocabularyItems:
state.vocabularies[vocabulary] && state.vocabularies[vocabulary].items
? state.vocabularies[vocabulary].items
: [],
}),
{ getVocabulary },
)(Header);