forked from YuktiMutreja/project2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEpicMenu.js
63 lines (52 loc) · 1.73 KB
/
EpicMenu.js
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
import React, { Component } from 'react';
import './EpicMenu.css';
import searchIcon from './search-icon.png';
class EpicMenu extends Component {
constructor() {
super();
this.state = {
showForm: false
};
}
showForm() {
this.setState({
showForm: !this.state.showForm
});
}
render() {
let searchForm = this.state.showForm ? (
<form className="menu__search-form" method="POST">
<input className="menu__search-input" placeholder="Type and hit enter" />
</form>
) : '';
let linksMarkup = this.props.links.map((link, index) => {
let linkMarkup = link.active ? (
<a className="menu__link menu__link--active" href={link.link}>{link.label}</a>
) : (
<a className="menu__link" href={link.link}>{link.label}</a>
);
return (
<li key={index} className="menu__list-item">
{linkMarkup}
</li>
);
});
return (
<nav className="menu">
<h1 style={{
backgroundImage: 'url(' + this.props.logo + ')'
}} className="menu__logo">Epic Co.</h1>
<div className="menu__right">
<ul className="menu__list">
{linksMarkup}
</ul>
<button onClick={this.showForm.bind(this)} style={{
backgroundImage: 'url(' + searchIcon + ')'
}} className="menu__search-button"></button>
{searchForm}
</div>
</nav>
);
}
}
export default EpicMenu;