Total Complexity | 1 |
Complexity/F | 0 |
Lines of Code | 54 |
Function Count | 0 |
Duplicated Lines | 0 |
Ratio | 0 % |
Coverage | 100% |
Changes | 0 |
1 | import React from 'react' |
||
2 | import PropTypes from 'prop-types' |
||
3 | import styled from 'styled-components/macro' |
||
4 | import { Translate } from 'react-localize-redux' |
||
5 | |||
6 | 3 | const NavItem = ({ page, isSelected, setSelectedPage }) => { |
|
7 | 31 | return isSelected ? ( |
|
8 | <SelectedContainer> |
||
9 | <Translate id={page.name} /> |
||
10 | </SelectedContainer> |
||
11 | ) : ( |
||
12 | <Container |
||
13 | data-test-id="nav-link" |
||
14 | href={page.url} |
||
15 | onClick={() => { |
||
16 | 1 | setSelectedPage(page.name) |
|
17 | }} |
||
18 | > |
||
19 | <Translate id={page.name} /> |
||
20 | </Container> |
||
21 | ) |
||
22 | } |
||
23 | |||
24 | 3 | NavItem.propTypes = { |
|
25 | page: PropTypes.shape({ |
||
26 | url: PropTypes.string, |
||
27 | name: PropTypes.string |
||
28 | }), |
||
29 | isSelected: PropTypes.bool, |
||
30 | setSelectedPage: PropTypes.func |
||
31 | } |
||
32 | |||
33 | export default NavItem |
||
34 | |||
35 | const Container = styled.a` |
||
36 | 29 | line-height: ${props => props.theme.navContentMinHeight}; |
|
37 | 29 | font-size: ${props => props.theme.fontSizes.XL}; |
|
38 | transition: color 0.5s; |
||
39 | |||
40 | &:hover { |
||
41 | 29 | color: ${props => props.theme.colors.colorDarken}; |
|
42 | border: none; |
||
43 | } |
||
44 | |||
45 | @media screen and (max-width: 800px) { |
||
46 | line-height: 2; |
||
47 | border-bottom: none; |
||
48 | } |
||
49 | ` |
||
50 | const SelectedContainer = styled(Container)` |
||
51 | 1 | color: ${props => props.theme.colors.colorDarken} !important; |
|
52 | border: none; |
||
53 | ` |
||
54 |