-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
PrimaryNav.js
137 lines (122 loc) · 3.18 KB
/
PrimaryNav.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
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
133
134
135
136
137
import styled from '@emotion/styled';
import { colors, gridSize } from '@arch-ui/theme';
import { ItemElement } from './common';
export const PRIMARY_NAV_GUTTER = gridSize * 2;
export const NavGroupIcons = styled.div({
alignItems: 'center',
alignSelf: 'stretch',
display: 'flex',
justifyContent: 'space-between',
});
export const PrimaryNav = styled.nav({
boxSizing: 'border-box',
display: 'flex',
flexDirection: 'column',
height: '100vh',
position: 'fixed',
zIndex: 2,
});
export const PrimaryNavScrollArea = styled.div(({ hasScroll, isBottom, isScrollable }) => {
const divider = {
backgroundColor: 'rgba(9, 30, 66, 0.1)',
content: '" "',
height: 2,
left: PRIMARY_NAV_GUTTER,
right: PRIMARY_NAV_GUTTER,
position: 'absolute',
};
const before = hasScroll ? { ...divider, top: 0 } : null;
const after = isScrollable && !isBottom ? { ...divider, bottom: 0 } : null;
return {
boxSizing: 'border-box',
flex: 1,
overflowY: 'auto',
overflowX: 'hidden',
minWidth: 140,
paddingBottom: PRIMARY_NAV_GUTTER,
width: '100%',
':before': before,
':after': after,
};
});
export const BrandItem = styled.h2({
fontSize: 18,
fontWeight: 500,
margin: 0,
paddingBottom: PRIMARY_NAV_GUTTER,
});
export const PrimaryNavItem = styled(ItemElement)(({ depth, isSelected, mouseIsOverNav }) => {
const selectedStyles = isSelected
? {
'&, :hover, :active, :focus': {
':after': {
backgroundColor: colors.primary,
},
},
}
: {};
return {
border: 0,
borderRight: '1px solid transparent',
color: isSelected ? colors.N90 : mouseIsOverNav ? colors.N70 : colors.N40,
display: 'block',
marginBottom: 2,
overflow: 'hidden',
padding: PRIMARY_NAV_GUTTER,
paddingLeft: depth ? PRIMARY_NAV_GUTTER * depth : PRIMARY_NAV_GUTTER,
position: 'relative',
textDecoration: 'none',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
transition: 'color 110ms',
flexGrow: 1,
flexBasis: '100%',
':hover, :focus': {
backgroundColor: colors.N10,
textDecoration: 'none',
},
':active': {
backgroundColor: colors.N10,
},
':after': {
borderRadius: 2,
bottom: 2,
content: '" "',
pointerEvents: 'none',
position: 'absolute',
right: 6,
top: 2,
transition: 'background-color 110ms',
width: 4,
},
...selectedStyles,
};
});
export const NavIcon = styled(ItemElement)(({ mouseIsOverNav }) => {
return {
color: mouseIsOverNav ? colors.N70 : colors.N40,
padding: PRIMARY_NAV_GUTTER,
textDecoration: 'none',
flexGrow: 1,
flexBasis: '100%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
':hover, :focus': {
backgroundColor: colors.N10,
textDecoration: 'none',
},
':active': {
backgroundColor: colors.N10,
},
};
});
export const PrimaryNavHeading = styled.h3(({ depth }) => ({
color: colors.N40,
fontSize: '0.85em',
fontWeight: 'bold',
marginTop: '2em',
paddingLeft: depth ? PRIMARY_NAV_GUTTER * depth : PRIMARY_NAV_GUTTER,
paddingRight: PRIMARY_NAV_GUTTER,
textTransform: 'uppercase',
}));