This repository was archived by the owner on Jan 22, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathNavItem.jsx
More file actions
76 lines (67 loc) · 2.13 KB
/
NavItem.jsx
File metadata and controls
76 lines (67 loc) · 2.13 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
73
74
75
76
import React from 'react';
import Radium from 'radium';
@Radium
export default class NavItem extends React.Component {
displayName = 'Navigation bar item'
static propTypes = {
onClick: React.PropTypes.func,
link: React.PropTypes.string,
title: React.PropTypes.string,
style: React.PropTypes.object,
itemStyle: React.PropTypes.object
}
getStyles = () => {
return {
base: {
position: 'relative',
display: 'block',
boxSizing: 'border-box',
'@media (min-width: 768px)': {
float: 'left'
}
},
link: {
paddingTop: '10px',
paddingBottom: '10px',
paddingLeft: '15px',
paddingRight: '15px',
lineHeight: '20px',
position: 'relative',
display: 'block',
boxSizing: 'border-box',
textDecoration: 'none',
backgroundColor: 'transparent',
color: '#777',
':hover': {
color: '#333',
backgroundColor: 'transparent'
},
':focus': {
color: '#333',
backgroundColor: 'transparent'
},
'@media (min-width: 768px)': {
paddingTop: '15px',
paddingBottom: '15px'
}
}
};
}
clickHandler(event) {
if (typeof(this.props.onClick) !== 'undefined') {
event.preventDefault();
this.props.onClick();
return false;
}
return true;
}
render() {
const defStyle = this.getStyles();
const {style, link, title, itemStyle} = this.props;
return (
<li ref="list" style={[defStyle.base, style && style]}>
<a ref="link" onClick={(event) => { return this.clickHandler(event); }} href={link} style={[defStyle.link, itemStyle && itemStyle]}>{title}</a>
</li>
);
}
}