orcs-design-system 3.1.42 → 3.1.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -54,6 +54,12 @@ var MultiValueRemove = function MultiValueRemove(props) {
|
|
|
54
54
|
})
|
|
55
55
|
}));
|
|
56
56
|
};
|
|
57
|
+
MultiValueRemove.propTypes = {
|
|
58
|
+
innerProps: PropTypes.shape({
|
|
59
|
+
// add innerProps validation here
|
|
60
|
+
}),
|
|
61
|
+
data: PropTypes.object.isRequired
|
|
62
|
+
};
|
|
57
63
|
var SELECT_TYPES = {
|
|
58
64
|
creatable: CreatableSelect,
|
|
59
65
|
async: AsyncSelect,
|
|
@@ -9,71 +9,42 @@ import { themeGet } from "@styled-system/theme-get";
|
|
|
9
9
|
import PropTypes from "prop-types";
|
|
10
10
|
import Icon from "../Icon";
|
|
11
11
|
import Popover from "../Popover";
|
|
12
|
-
var
|
|
12
|
+
var getSharedNavItemStyles = function getSharedNavItemStyles(props) {
|
|
13
|
+
var getThemeStyle = function getThemeStyle(style) {
|
|
14
|
+
return themeGet(style)(props);
|
|
15
|
+
};
|
|
16
|
+
return "\n cursor: pointer;\n padding: ".concat(getThemeStyle("space.s"), ";\n text-decoration: none;\n border-radius: ").concat(getThemeStyle("radii.2"), ";\n width: 100%;\n position: relative;\n border: none;\n path {\n transition: ").concat(getThemeStyle("transition.transitionDefault"), ";\n fill: ").concat(getThemeStyle("colors.greyDarker"), ";\n }\n font-family: ").concat(getThemeStyle("fonts.main"), ";\n \n display: flex;\n align-items: center;\n justify-content: center;\n transition: ").concat(getThemeStyle("transition.transitionDefault"), ";\n background-color: transparent;\n font-size: 1.4rem;\n font-weight: ").concat(getThemeStyle("fontWeights.1"), "; \n\n &:hover, &:focus {\n color: ").concat(getThemeStyle("colors.primary"), ";\n path {\n fill: ").concat(getThemeStyle("colors.primary"), ";\n }\n \n }\n @media screen and (max-width: 900px) {\n width: auto;\n max-height:30px;\n height: 30px;\n }\n &:focus {\n outline: 0;\n color: ").concat(getThemeStyle("colors.primary"), ";\n path {\n fill: ").concat(getThemeStyle("colors.primary"), ";\n }\n }");
|
|
17
|
+
};
|
|
18
|
+
var getActiveStyles = function getActiveStyles(props) {
|
|
19
|
+
var getThemeStyle = function getThemeStyle(style) {
|
|
20
|
+
return themeGet(style)(props);
|
|
21
|
+
};
|
|
22
|
+
if (!props.active) return "";
|
|
23
|
+
var primaryColor = getThemeStyle("colors.primary");
|
|
24
|
+
if (props["aria-expanded"]) {
|
|
25
|
+
return "\n color: ".concat(primaryColor, ";\n\n path {\n fill: ").concat(primaryColor, ";\n }\n :after {\n height: 100%;\n position: absolute;\n right: calc(-").concat(getThemeStyle("space.r"), " - 2px);\n content: \"\";\n border-right: 3px solid ").concat(primaryColor, ";\n z-index: 5;\n }\n\n @media screen and (max-width: 900px) {\n :after {\n border-top: 3px solid ").concat(primaryColor, ";\n border-right: none;\n top: -").concat(getThemeStyle("space.r"), ";\n right:0;\n width: 100%;\n }\n }\n ");
|
|
26
|
+
}
|
|
27
|
+
return "\n background-color: ".concat(primaryColor, ";\n path {\n fill: ").concat(getThemeStyle("colors.white"), ";\n }\n\n &:hover, &:focus {\n path {\n fill: ").concat(getThemeStyle("colors.white"), ";\n }\n }\n &:focus {\n path {\n fill: ").concat(getThemeStyle("colors.white"), ";\n }\n }\n");
|
|
28
|
+
};
|
|
29
|
+
var SideNavItemLink = styled.div.withConfig({
|
|
13
30
|
displayName: "NavItem__SideNavItemLink",
|
|
14
31
|
componentId: "sc-hkm2u8-0"
|
|
15
|
-
})(function (props) {
|
|
16
|
-
return
|
|
17
|
-
"& > a": {
|
|
18
|
-
cursor: "pointer",
|
|
19
|
-
padding: "s",
|
|
20
|
-
textDecoration: "none",
|
|
21
|
-
borderRadius: themeGet("radii.2")(props),
|
|
22
|
-
width: "100%",
|
|
23
|
-
path: {
|
|
24
|
-
transition: themeGet("transition.transitionDefault")(props),
|
|
25
|
-
fill: themeGet("colors.greyDarker")(props)
|
|
26
|
-
},
|
|
27
|
-
fontFamily: themeGet("fonts.main")(props),
|
|
28
|
-
position: "relative",
|
|
29
|
-
display: "flex",
|
|
30
|
-
alignItems: "center",
|
|
31
|
-
justifyContent: "center",
|
|
32
|
-
// width: "100%",
|
|
33
|
-
transition: themeGet("transition.transitionDefault")(props),
|
|
34
|
-
bg: "transparent",
|
|
35
|
-
fontSize: "1.4rem",
|
|
36
|
-
fontWeight: themeGet("fontWeights.1")(props),
|
|
37
|
-
"&:hover, &:focus": {
|
|
38
|
-
path: {
|
|
39
|
-
fill: themeGet("colors.primary")(props)
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
"@media screen and (max-width: 900px)": {
|
|
43
|
-
width: "auto"
|
|
44
|
-
},
|
|
45
|
-
"&:focus": {
|
|
46
|
-
outline: "0",
|
|
47
|
-
color: themeGet("colors.primary")(props),
|
|
48
|
-
path: {
|
|
49
|
-
fill: themeGet("colors.primary")(props)
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
});
|
|
32
|
+
})(["& > a{", " ", "}"], function (props) {
|
|
33
|
+
return getSharedNavItemStyles(props);
|
|
54
34
|
}, function (props) {
|
|
55
|
-
return props
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
"&:focus": {
|
|
67
|
-
path: {
|
|
68
|
-
fill: themeGet("colors.white")(props)
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
});
|
|
35
|
+
return getActiveStyles(props);
|
|
36
|
+
});
|
|
37
|
+
var SideNavItem = styled("button").withConfig({
|
|
38
|
+
displayName: "NavItem__SideNavItem",
|
|
39
|
+
componentId: "sc-hkm2u8-1"
|
|
40
|
+
})(["", " ", ""], function (props) {
|
|
41
|
+
return getSharedNavItemStyles(props);
|
|
42
|
+
}, function (props) {
|
|
43
|
+
return getActiveStyles(props);
|
|
73
44
|
});
|
|
74
45
|
var BadgeNumber = styled("div").withConfig({
|
|
75
46
|
displayName: "NavItem__BadgeNumber",
|
|
76
|
-
componentId: "sc-hkm2u8-
|
|
47
|
+
componentId: "sc-hkm2u8-2"
|
|
77
48
|
})(function (props) {
|
|
78
49
|
return css({
|
|
79
50
|
position: "absolute",
|
|
@@ -93,7 +64,7 @@ var BadgeNumber = styled("div").withConfig({
|
|
|
93
64
|
});
|
|
94
65
|
var BadgeDot = styled("div").withConfig({
|
|
95
66
|
displayName: "NavItem__BadgeDot",
|
|
96
|
-
componentId: "sc-hkm2u8-
|
|
67
|
+
componentId: "sc-hkm2u8-3"
|
|
97
68
|
})(function (props) {
|
|
98
69
|
return css({
|
|
99
70
|
position: "absolute",
|
|
@@ -107,14 +78,16 @@ var BadgeDot = styled("div").withConfig({
|
|
|
107
78
|
});
|
|
108
79
|
var SideNavItemPopover = styled(Popover).withConfig({
|
|
109
80
|
displayName: "NavItem__SideNavItemPopover",
|
|
110
|
-
componentId: "sc-hkm2u8-
|
|
81
|
+
componentId: "sc-hkm2u8-4"
|
|
111
82
|
})(function (props) {
|
|
112
83
|
return css({
|
|
113
|
-
|
|
84
|
+
height: "30px",
|
|
114
85
|
marginBottom: props.bottomAligned ? "0" : "s",
|
|
115
86
|
marginTop: props.bottomAligned ? "s" : "0",
|
|
116
|
-
"
|
|
117
|
-
|
|
87
|
+
"@media screen and (min-width: 900px)": {
|
|
88
|
+
":nth-child(1 of .bottom-aligned) ": {
|
|
89
|
+
marginTop: props.bottomAligned && "auto"
|
|
90
|
+
}
|
|
118
91
|
},
|
|
119
92
|
"&:hover,&:focus-within": {
|
|
120
93
|
"& .popoverText": {
|
|
@@ -151,63 +124,15 @@ var SideNavItemPopover = styled(Popover).withConfig({
|
|
|
151
124
|
}
|
|
152
125
|
});
|
|
153
126
|
});
|
|
154
|
-
var SideNavItem = styled("button").withConfig({
|
|
155
|
-
displayName: "NavItem__SideNavItem",
|
|
156
|
-
componentId: "sc-hkm2u8-4"
|
|
157
|
-
})(function (props) {
|
|
158
|
-
return css({
|
|
159
|
-
fontFamily: themeGet("fonts.main")(props),
|
|
160
|
-
position: "relative",
|
|
161
|
-
display: "flex",
|
|
162
|
-
alignItems: "center",
|
|
163
|
-
justifyContent: "center",
|
|
164
|
-
width: "100%",
|
|
165
|
-
borderRadius: themeGet("radii.2")(props),
|
|
166
|
-
transition: themeGet("transition.transitionDefault")(props),
|
|
167
|
-
bg: "transparent",
|
|
168
|
-
cursor: "pointer",
|
|
169
|
-
border: "none",
|
|
170
|
-
padding: "s",
|
|
171
|
-
fontSize: "1.4rem",
|
|
172
|
-
fontWeight: themeGet("fontWeights.1")(props),
|
|
173
|
-
color: themeGet("colors.greyDarker")(props),
|
|
174
|
-
path: {
|
|
175
|
-
transition: themeGet("transition.transitionDefault")(props),
|
|
176
|
-
fill: themeGet("colors.greyDarker")(props)
|
|
177
|
-
},
|
|
178
|
-
"&:hover, &:focus": {
|
|
179
|
-
outline: "0",
|
|
180
|
-
color: themeGet("colors.primary")(props),
|
|
181
|
-
path: {
|
|
182
|
-
fill: themeGet("colors.primary")(props)
|
|
183
|
-
}
|
|
184
|
-
},
|
|
185
|
-
"@media screen and (max-width: 900px)": {
|
|
186
|
-
width: "auto"
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
}, function (props) {
|
|
190
|
-
return props.active && css({
|
|
191
|
-
bg: themeGet("colors.primary")(props),
|
|
192
|
-
path: {
|
|
193
|
-
fill: themeGet("colors.white")(props)
|
|
194
|
-
},
|
|
195
|
-
"&:hover, &:focus": {
|
|
196
|
-
path: {
|
|
197
|
-
fill: themeGet("colors.white")(props)
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
});
|
|
202
127
|
var NavItem = function NavItem(_ref) {
|
|
203
128
|
var item = _ref.item,
|
|
204
129
|
Component = _ref.Component,
|
|
205
|
-
|
|
130
|
+
isActive = _ref.isActive,
|
|
206
131
|
handleItemClick = _ref.handleItemClick,
|
|
207
132
|
navItemRefs = _ref.navItemRefs;
|
|
208
133
|
// Use the ternary operator to render the appropriate component based on actionType
|
|
209
134
|
var accessibilityProps = _objectSpread(_objectSpread({}, item.actionType === "component" && {
|
|
210
|
-
"aria-expanded":
|
|
135
|
+
"aria-expanded": isActive ? "true" : "false"
|
|
211
136
|
}), {}, {
|
|
212
137
|
"aria-label": item.name
|
|
213
138
|
});
|
|
@@ -216,11 +141,11 @@ var NavItem = function NavItem(_ref) {
|
|
|
216
141
|
text: item.name,
|
|
217
142
|
textAlign: "center",
|
|
218
143
|
width: "124px",
|
|
219
|
-
active:
|
|
144
|
+
active: isActive,
|
|
220
145
|
bottomAligned: item.bottomAligned
|
|
221
146
|
}, item.actionType === "link" ? /*#__PURE__*/React.createElement(SideNavItemLink, {
|
|
222
147
|
key: item.index,
|
|
223
|
-
active:
|
|
148
|
+
active: isActive,
|
|
224
149
|
bottomAligned: item.bottomAligned,
|
|
225
150
|
onClick: function onClick() {
|
|
226
151
|
return handleItemClick(item);
|
|
@@ -234,7 +159,7 @@ var NavItem = function NavItem(_ref) {
|
|
|
234
159
|
icon: ["far", item.iconName]
|
|
235
160
|
}))) : /*#__PURE__*/React.createElement(SideNavItem, _extends({
|
|
236
161
|
key: item.index,
|
|
237
|
-
active:
|
|
162
|
+
active: isActive,
|
|
238
163
|
onClick: function onClick() {
|
|
239
164
|
return handleItemClick(item);
|
|
240
165
|
},
|
|
@@ -250,7 +175,7 @@ var NavItem = function NavItem(_ref) {
|
|
|
250
175
|
NavItem.propTypes = {
|
|
251
176
|
item: PropTypes.object,
|
|
252
177
|
Component: PropTypes.elementType,
|
|
253
|
-
|
|
178
|
+
isActive: PropTypes.bool,
|
|
254
179
|
handleItemClick: PropTypes.func,
|
|
255
180
|
navItemRefs: PropTypes.object
|
|
256
181
|
};
|
|
@@ -273,10 +198,10 @@ NavItem.__docgenInfo = {
|
|
|
273
198
|
},
|
|
274
199
|
"required": false
|
|
275
200
|
},
|
|
276
|
-
"
|
|
201
|
+
"isActive": {
|
|
277
202
|
"description": "",
|
|
278
203
|
"type": {
|
|
279
|
-
"name": "
|
|
204
|
+
"name": "bool"
|
|
280
205
|
},
|
|
281
206
|
"required": false
|
|
282
207
|
},
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types */
|
|
1
2
|
import React from "react";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { BrowserRouter as Router, Route, Link } from "react-router-dom";
|
|
3
|
+
import SideNav from "./index";
|
|
4
|
+
import { BrowserRouter as Router, Route, Link, useLocation, matchPath, Switch, Redirect, useParams } from "react-router-dom";
|
|
5
5
|
import { H5, P } from "../Typography";
|
|
6
6
|
import Box from "../Box";
|
|
7
|
-
import
|
|
7
|
+
import { far } from "@fortawesome/free-regular-svg-icons";
|
|
8
|
+
import { library } from "@fortawesome/fontawesome-svg-core";
|
|
9
|
+
import Flex from "../Flex";
|
|
10
|
+
import Spacer from "../Spacer/index";
|
|
11
|
+
import Card from "../Card/index";
|
|
12
|
+
library.add(far);
|
|
8
13
|
export default {
|
|
9
14
|
title: "Components/SideNav",
|
|
10
15
|
decorators: [function (storyFn) {
|
|
@@ -14,121 +19,168 @@ export default {
|
|
|
14
19
|
}],
|
|
15
20
|
component: SideNav
|
|
16
21
|
};
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
var makeLinkComponent = function makeLinkComponent(path) {
|
|
23
|
+
return function (_ref) {
|
|
24
|
+
var children = _ref.children,
|
|
25
|
+
item = _ref.item;
|
|
26
|
+
return /*#__PURE__*/React.createElement(Link, {
|
|
27
|
+
to: path,
|
|
28
|
+
"aria-label": item.name
|
|
29
|
+
}, children);
|
|
30
|
+
};
|
|
24
31
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
32
|
+
var makePanelComponent = function makePanelComponent(name, children) {
|
|
33
|
+
return function () {
|
|
34
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(H5, {
|
|
35
|
+
fontWeight: "bold",
|
|
36
|
+
mb: "r"
|
|
37
|
+
}, name), /*#__PURE__*/React.createElement(P, null, name, " content"), children);
|
|
38
|
+
};
|
|
28
39
|
};
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
mb: "r"
|
|
33
|
-
}, "Notifications"), /*#__PURE__*/React.createElement(P, null, "Notifications content"));
|
|
40
|
+
var Teams = function Teams() {
|
|
41
|
+
var params = useParams();
|
|
42
|
+
return /*#__PURE__*/React.createElement("div", null, "Team ", params.teamId, " route");
|
|
34
43
|
};
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
},
|
|
44
|
+
var PageCard = function PageCard(_ref2) {
|
|
45
|
+
var children = _ref2.children;
|
|
46
|
+
return /*#__PURE__*/React.createElement(Spacer, {
|
|
47
|
+
px: "r"
|
|
48
|
+
}, /*#__PURE__*/React.createElement(Card, null, children));
|
|
40
49
|
};
|
|
41
|
-
var
|
|
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
|
-
|
|
50
|
+
var SideBarWithConfig = function SideBarWithConfig() {
|
|
51
|
+
var location = useLocation();
|
|
52
|
+
var items = [{
|
|
53
|
+
iconName: "building",
|
|
54
|
+
name: "Home",
|
|
55
|
+
component: makeLinkComponent("/"),
|
|
56
|
+
actionType: "link",
|
|
57
|
+
isActive: matchPath(location.pathname, {
|
|
58
|
+
path: "/",
|
|
59
|
+
exact: true
|
|
60
|
+
})
|
|
61
|
+
}, {
|
|
62
|
+
iconName: "user",
|
|
63
|
+
name: "My profile",
|
|
64
|
+
component: makeLinkComponent("/profile"),
|
|
65
|
+
actionType: "link",
|
|
66
|
+
isActive: matchPath(location.pathname, {
|
|
67
|
+
path: "/profile"
|
|
68
|
+
})
|
|
69
|
+
}, {
|
|
70
|
+
iconName: "id-card",
|
|
71
|
+
name: "Search Page",
|
|
72
|
+
component: makeLinkComponent("/search"),
|
|
73
|
+
actionType: "link",
|
|
74
|
+
isActive: matchPath(location.pathname, {
|
|
75
|
+
path: "/search"
|
|
76
|
+
})
|
|
77
|
+
}, {
|
|
78
|
+
iconName: "snowflake",
|
|
79
|
+
name: "Filter",
|
|
80
|
+
hide: !matchPath(location.pathname, {
|
|
81
|
+
path: "/search"
|
|
82
|
+
}),
|
|
83
|
+
// Specify hide if you want to hide this item
|
|
84
|
+
component: makePanelComponent("Filter"),
|
|
85
|
+
actionType: "component",
|
|
86
|
+
// Use 'component' for a component
|
|
87
|
+
pageSpecific: matchPath(location.pathname, {
|
|
88
|
+
path: "/search"
|
|
89
|
+
}),
|
|
90
|
+
isExpandedByDefault: true
|
|
91
|
+
}, {
|
|
92
|
+
iconName: "sun",
|
|
93
|
+
name: "People",
|
|
94
|
+
hide: !matchPath(location.pathname, {
|
|
95
|
+
path: "/profile"
|
|
96
|
+
}),
|
|
97
|
+
// Specify hide if you want to hide this item
|
|
98
|
+
component: makePanelComponent("People"),
|
|
99
|
+
actionType: "component",
|
|
100
|
+
// Use 'component' for a component
|
|
101
|
+
pageSpecific: matchPath(location.pathname, {
|
|
102
|
+
path: "/profile"
|
|
103
|
+
}),
|
|
104
|
+
isExpandedByDefault: true
|
|
105
|
+
}, {
|
|
106
|
+
iconName: "bell",
|
|
107
|
+
name: "Notifications",
|
|
108
|
+
badgeNumber: "3",
|
|
109
|
+
// Specify a badgeNumber if you want to have a count on this item
|
|
110
|
+
component: makePanelComponent("Notifications"),
|
|
111
|
+
actionType: "component" // Use 'component' for a component
|
|
112
|
+
}, {
|
|
113
|
+
iconName: "chart-bar",
|
|
114
|
+
name: "Browse teams",
|
|
115
|
+
large: true,
|
|
116
|
+
// Specify large if you want the expanded sidebar to be wider
|
|
117
|
+
component: makePanelComponent("BrowseTeams", /*#__PURE__*/React.createElement(Flex, {
|
|
118
|
+
flexDirection: "column"
|
|
119
|
+
}, ["Team 1", "Team 2", "Team 3"].map(function (team) {
|
|
120
|
+
return /*#__PURE__*/React.createElement(Link, {
|
|
121
|
+
to: "/teams/".concat(team),
|
|
122
|
+
key: team
|
|
123
|
+
}, team);
|
|
124
|
+
}))),
|
|
125
|
+
actionType: "component" // Use 'component' for a component
|
|
126
|
+
}, {
|
|
127
|
+
iconName: "cog",
|
|
128
|
+
name: "Settings",
|
|
129
|
+
hide: true,
|
|
130
|
+
// Specify hide if you want to hide this item
|
|
131
|
+
bottomAligned: true,
|
|
132
|
+
component: makePanelComponent("Settings"),
|
|
133
|
+
actionType: "component" // Use 'component' for a component
|
|
134
|
+
}, {
|
|
135
|
+
iconName: "calendar-alt",
|
|
136
|
+
name: "Calendar",
|
|
137
|
+
pageSpecific: true,
|
|
138
|
+
// Specify pageSpecific if you want this item to appear below a divider line separating common nav items from page/route specific items
|
|
139
|
+
component: makePanelComponent("Calendar"),
|
|
140
|
+
actionType: "component" // Use 'component' for a component
|
|
141
|
+
}, {
|
|
142
|
+
iconName: "star",
|
|
143
|
+
name: "Announcements",
|
|
144
|
+
badgeDot: true,
|
|
145
|
+
// Specify if you want to have a blue notification dot on this item
|
|
146
|
+
bottomAligned: true,
|
|
147
|
+
// Specify bottomAligned if this item should appear at bottom of SideNav
|
|
148
|
+
component: makePanelComponent("Announcements"),
|
|
149
|
+
actionType: "component" // Use 'component' for a component
|
|
150
|
+
}, {
|
|
151
|
+
iconName: "times-circle",
|
|
152
|
+
name: "Logout",
|
|
153
|
+
bottomAligned: true,
|
|
154
|
+
// Specify bottomAligned if this item should appear at bottom of SideNav
|
|
155
|
+
onClick: function onClick() {
|
|
156
|
+
return alert("Logout function");
|
|
157
|
+
},
|
|
158
|
+
// Specify the onClick function for the button
|
|
159
|
+
actionType: "button" // Use 'button' for a button with onClick event
|
|
160
|
+
}
|
|
161
|
+
// Add more items as needed...
|
|
162
|
+
];
|
|
163
|
+
return /*#__PURE__*/React.createElement(Flex, null, /*#__PURE__*/React.createElement(SideNav, {
|
|
125
164
|
items: items,
|
|
126
165
|
sideNavHeight: "500px"
|
|
127
|
-
})
|
|
166
|
+
}), /*#__PURE__*/React.createElement(Switch, null, /*#__PURE__*/React.createElement(Route, {
|
|
167
|
+
exact: true,
|
|
168
|
+
path: "/"
|
|
169
|
+
}, /*#__PURE__*/React.createElement(PageCard, null, /*#__PURE__*/React.createElement("div", null, "Home"))), /*#__PURE__*/React.createElement(Route, {
|
|
170
|
+
path: "/profile"
|
|
171
|
+
}, /*#__PURE__*/React.createElement(PageCard, null, /*#__PURE__*/React.createElement("div", null, "Profile route"))), /*#__PURE__*/React.createElement(Route, {
|
|
172
|
+
path: "/teams/:teamId"
|
|
173
|
+
}, /*#__PURE__*/React.createElement(PageCard, null, /*#__PURE__*/React.createElement(Teams, null))), /*#__PURE__*/React.createElement(Redirect, {
|
|
174
|
+
from: "/iframe.html",
|
|
175
|
+
to: "/"
|
|
176
|
+
})));
|
|
177
|
+
};
|
|
178
|
+
export var SidebarNavigation = function SidebarNavigation() {
|
|
179
|
+
return /*#__PURE__*/React.createElement(Router, null, /*#__PURE__*/React.createElement(SideBarWithConfig, null));
|
|
128
180
|
};
|
|
129
|
-
|
|
130
|
-
|
|
181
|
+
SidebarNavigation.storyName = "Sidebar Navigation";
|
|
182
|
+
SidebarNavigation.__docgenInfo = {
|
|
131
183
|
"description": "",
|
|
132
184
|
"methods": [],
|
|
133
|
-
"displayName": "
|
|
185
|
+
"displayName": "SidebarNavigation"
|
|
134
186
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
4
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
5
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
6
|
import React, { useRef, useState, useEffect } from "react";
|
|
@@ -12,11 +12,12 @@ import Icon from "../Icon";
|
|
|
12
12
|
import Popover from "../Popover";
|
|
13
13
|
import Divider from "../Divider";
|
|
14
14
|
import NavItem from "./NavItem";
|
|
15
|
+
var SMALL_SCREEN_BREAKPOINT = 900;
|
|
15
16
|
var SideNavWrapper = styled("div").withConfig({
|
|
16
17
|
displayName: "SideNav__SideNavWrapper",
|
|
17
18
|
componentId: "sc-1heo0i9-0"
|
|
18
19
|
})(function (props) {
|
|
19
|
-
return css({
|
|
20
|
+
return css(_defineProperty({
|
|
20
21
|
bg: themeGet("colors.white")(props),
|
|
21
22
|
color: themeGet("colors.greyDarkest")(props),
|
|
22
23
|
minHeight: props.sideNavHeight,
|
|
@@ -28,28 +29,27 @@ var SideNavWrapper = styled("div").withConfig({
|
|
|
28
29
|
boxShadow: themeGet("shadows.boxDefault")(props),
|
|
29
30
|
display: "flex",
|
|
30
31
|
alignItems: "stretch",
|
|
31
|
-
alignContent: "stretch"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
});
|
|
32
|
+
alignContent: "stretch"
|
|
33
|
+
}, "@media screen and (max-width: ".concat(SMALL_SCREEN_BREAKPOINT, "px)"), {
|
|
34
|
+
borderRadius: "0",
|
|
35
|
+
width: "100%",
|
|
36
|
+
height: "auto",
|
|
37
|
+
minWidth: "auto",
|
|
38
|
+
maxWidth: "initial",
|
|
39
|
+
minHeight: "initial",
|
|
40
|
+
maxHeight: themeGet("appScale.sidebarMobileHeight")(props),
|
|
41
|
+
position: "fixed",
|
|
42
|
+
bottom: "0",
|
|
43
|
+
left: "0",
|
|
44
|
+
zIndex: "6",
|
|
45
|
+
flexDirection: "column-reverse"
|
|
46
|
+
}));
|
|
47
47
|
});
|
|
48
48
|
var SideNavItems = styled("div").withConfig({
|
|
49
49
|
displayName: "SideNav__SideNavItems",
|
|
50
50
|
componentId: "sc-1heo0i9-1"
|
|
51
51
|
})(function (props) {
|
|
52
|
-
return css({
|
|
52
|
+
return css(_defineProperty({
|
|
53
53
|
minWidth: themeGet("appScale.navBarSize")(props),
|
|
54
54
|
minHeight: "inherit",
|
|
55
55
|
height: "100%",
|
|
@@ -59,20 +59,19 @@ var SideNavItems = styled("div").withConfig({
|
|
|
59
59
|
alignItems: "center",
|
|
60
60
|
justifyContent: "flex-start",
|
|
61
61
|
textAlign: "center",
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
});
|
|
62
|
+
position: "relative"
|
|
63
|
+
}, "@media screen and (max-width: ".concat(SMALL_SCREEN_BREAKPOINT, "px)"), {
|
|
64
|
+
height: "calc(".concat(themeGet("space.r")(props), " * 2 + 30px)"),
|
|
65
|
+
flexDirection: "row",
|
|
66
|
+
justifyContent: "space-around",
|
|
67
|
+
alignItems: "center"
|
|
68
|
+
}));
|
|
70
69
|
});
|
|
71
70
|
var PanelControlTooltip = styled(Popover).withConfig({
|
|
72
71
|
displayName: "SideNav__PanelControlTooltip",
|
|
73
72
|
componentId: "sc-1heo0i9-2"
|
|
74
73
|
})(function (props) {
|
|
75
|
-
return css({
|
|
74
|
+
return css(_defineProperty(_defineProperty({
|
|
76
75
|
alignSelf: "center",
|
|
77
76
|
position: props.hideExpandedControl ? "absolute" : "relative",
|
|
78
77
|
right: props.hideExpandedControl ? "r" : "initial",
|
|
@@ -85,14 +84,12 @@ var PanelControlTooltip = styled(Popover).withConfig({
|
|
|
85
84
|
justifyContent: "center",
|
|
86
85
|
"&:focus": {
|
|
87
86
|
outline: "0"
|
|
88
|
-
},
|
|
89
|
-
"@media screen and (max-width: 900px)": {
|
|
90
|
-
border: "none"
|
|
91
|
-
},
|
|
92
|
-
"& .popoverText": {
|
|
93
|
-
marginTop: props.hideExpandedControl ? "0" : "s"
|
|
94
87
|
}
|
|
95
|
-
})
|
|
88
|
+
}, "@media screen and (max-width: ".concat(SMALL_SCREEN_BREAKPOINT, "px)"), {
|
|
89
|
+
border: "none"
|
|
90
|
+
}), "& .popoverText", {
|
|
91
|
+
marginTop: props.hideExpandedControl ? "0" : "s"
|
|
92
|
+
}));
|
|
96
93
|
});
|
|
97
94
|
var PanelControl = styled("button").withConfig({
|
|
98
95
|
displayName: "SideNav__PanelControl",
|
|
@@ -116,7 +113,7 @@ var SideNavExpanded = styled("div").withConfig({
|
|
|
116
113
|
displayName: "SideNav__SideNavExpanded",
|
|
117
114
|
componentId: "sc-1heo0i9-4"
|
|
118
115
|
})(function (props) {
|
|
119
|
-
return css({
|
|
116
|
+
return css(_defineProperty({
|
|
120
117
|
position: "relative",
|
|
121
118
|
display: props.active ? "block" : "none",
|
|
122
119
|
minWidth: props.large ? "calc(" + themeGet("appScale.sidebarMaxWidthLarge")(props) + " - " + themeGet("appScale.navBarSize")(props) + ")" : "calc(" + themeGet("appScale.sidebarMaxWidth")(props) + " - " + themeGet("appScale.navBarSize")(props) + ")",
|
|
@@ -127,16 +124,15 @@ var SideNavExpanded = styled("div").withConfig({
|
|
|
127
124
|
borderLeft: "solid 1px ".concat(themeGet("colors.greyLighter")(props)),
|
|
128
125
|
"&:focus": {
|
|
129
126
|
outline: "0"
|
|
130
|
-
},
|
|
131
|
-
"@media screen and (max-width: 900px)": {
|
|
132
|
-
width: "100%",
|
|
133
|
-
minWidth: "initial",
|
|
134
|
-
maxWidth: "initial",
|
|
135
|
-
borderLeft: "none",
|
|
136
|
-
borderBottom: "solid 1px ".concat(themeGet("colors.greyLighter")(props)),
|
|
137
|
-
height: "calc(" + themeGet("appScale.sidebarMobileHeight")(props) + " - " + themeGet("appScale.navBarSize")(props) + ")"
|
|
138
127
|
}
|
|
139
|
-
})
|
|
128
|
+
}, "@media screen and (max-width: ".concat(SMALL_SCREEN_BREAKPOINT, "px)"), {
|
|
129
|
+
width: "100%",
|
|
130
|
+
minWidth: "initial",
|
|
131
|
+
maxWidth: "initial",
|
|
132
|
+
borderLeft: "none",
|
|
133
|
+
borderBottom: "solid 1px ".concat(themeGet("colors.greyLighter")(props)),
|
|
134
|
+
height: "calc(" + themeGet("appScale.sidebarMobileHeight")(props) + " - " + themeGet("appScale.navBarSize")(props) + ")"
|
|
135
|
+
}));
|
|
140
136
|
});
|
|
141
137
|
var SideNav = function SideNav(_ref) {
|
|
142
138
|
var items = _ref.items,
|
|
@@ -145,14 +141,18 @@ var SideNav = function SideNav(_ref) {
|
|
|
145
141
|
_useState2 = _slicedToArray(_useState, 2),
|
|
146
142
|
expandedItem = _useState2[0],
|
|
147
143
|
setExpandedItem = _useState2[1];
|
|
148
|
-
var _useState3 = useState(null),
|
|
149
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
150
|
-
activeItem = _useState4[0],
|
|
151
|
-
setActiveItem = _useState4[1];
|
|
152
144
|
|
|
153
145
|
// Initialize a ref for SideNavExpanded
|
|
154
146
|
var expandedRef = useRef(null);
|
|
155
147
|
var navItemRefs = useRef({});
|
|
148
|
+
var firstExpandedItemByDefault = items.findIndex(function (item) {
|
|
149
|
+
return item.isExpandedByDefault && !item.hide;
|
|
150
|
+
});
|
|
151
|
+
useEffect(function () {
|
|
152
|
+
if (firstExpandedItemByDefault >= 0) {
|
|
153
|
+
setExpandedItem(firstExpandedItemByDefault);
|
|
154
|
+
}
|
|
155
|
+
}, [firstExpandedItemByDefault]);
|
|
156
156
|
var handleItemClick = function handleItemClick(item) {
|
|
157
157
|
var itemIndex = item.index,
|
|
158
158
|
actionType = item.actionType,
|
|
@@ -163,10 +163,6 @@ var SideNav = function SideNav(_ref) {
|
|
|
163
163
|
} else {
|
|
164
164
|
setExpandedItem(itemIndex === expandedItem ? null : itemIndex);
|
|
165
165
|
onButtonClick && onButtonClick(item);
|
|
166
|
-
itemIndex === expandedItem && navItemRefs.current && navItemRefs.current[itemIndex] && navItemRefs.current[itemIndex].focus();
|
|
167
|
-
}
|
|
168
|
-
if (actionType !== "button") {
|
|
169
|
-
setActiveItem(itemIndex === activeItem ? null : itemIndex);
|
|
170
166
|
}
|
|
171
167
|
};
|
|
172
168
|
|
|
@@ -185,12 +181,13 @@ var SideNav = function SideNav(_ref) {
|
|
|
185
181
|
var bottomAlignedItems = allItems.filter(function (item) {
|
|
186
182
|
return item.bottomAligned;
|
|
187
183
|
});
|
|
188
|
-
var
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
184
|
+
var _useState3 = useState(window.innerWidth),
|
|
185
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
186
|
+
windowWidth = _useState4[0],
|
|
187
|
+
setWindowWidth = _useState4[1];
|
|
188
|
+
var isSmallScreen = windowWidth < SMALL_SCREEN_BREAKPOINT;
|
|
192
189
|
var handleResize = function handleResize() {
|
|
193
|
-
|
|
190
|
+
setWindowWidth(window.innerWidth);
|
|
194
191
|
};
|
|
195
192
|
var debounceResize = function debounceResize() {
|
|
196
193
|
return setTimeout(handleResize, 300);
|
|
@@ -227,7 +224,7 @@ var SideNav = function SideNav(_ref) {
|
|
|
227
224
|
key: item.index,
|
|
228
225
|
item: item,
|
|
229
226
|
Component: Component,
|
|
230
|
-
|
|
227
|
+
isActive: item.actionType === "link" ? item.isActive : expandedItem == item.index,
|
|
231
228
|
handleItemClick: handleItemClick,
|
|
232
229
|
navItemRefs: navItemRefs
|
|
233
230
|
});
|
|
@@ -243,40 +240,46 @@ var SideNav = function SideNav(_ref) {
|
|
|
243
240
|
};
|
|
244
241
|
return /*#__PURE__*/React.createElement(SideNavWrapper, {
|
|
245
242
|
sideNavHeight: sideNavHeight
|
|
246
|
-
}, /*#__PURE__*/React.createElement(SideNavItems, null, orderedItems.map(renderItem)),
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
243
|
+
}, /*#__PURE__*/React.createElement(SideNavItems, null, orderedItems.map(renderItem)), allItems.map(function (item, index) {
|
|
244
|
+
if (item.actionType !== "component") return null;
|
|
245
|
+
if (index !== expandedItem || item.hide) return null;
|
|
246
|
+
return /*#__PURE__*/React.createElement(SideNavExpanded, {
|
|
247
|
+
key: item.name,
|
|
248
|
+
ref: expandedRef,
|
|
249
|
+
tabIndex: "0",
|
|
250
|
+
sideNavHeight: sideNavHeight,
|
|
251
|
+
active: expandedItem,
|
|
252
|
+
large: item.large
|
|
253
|
+
}, item.component(), /*#__PURE__*/React.createElement(PanelControlTooltip, {
|
|
254
|
+
width: "80px",
|
|
255
|
+
textAlign: "center",
|
|
256
|
+
hideExpandedControl: true,
|
|
257
|
+
direction: "left",
|
|
258
|
+
text: "Hide panel"
|
|
259
|
+
}, /*#__PURE__*/React.createElement(PanelControl, {
|
|
260
|
+
onClick: function onClick() {
|
|
261
|
+
return handleItemClick(item);
|
|
262
|
+
},
|
|
263
|
+
"aria-label": "toggle panel",
|
|
264
|
+
onBlur: function onBlur() {
|
|
265
|
+
return handleBlur(item);
|
|
266
|
+
}
|
|
267
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
268
|
+
icon: ["fas", isSmallScreen ? "chevron-down" : "chevron-left"]
|
|
269
|
+
}))));
|
|
270
|
+
}));
|
|
271
271
|
};
|
|
272
272
|
SideNav.propTypes = {
|
|
273
273
|
sideNavHeight: PropTypes.string.isRequired,
|
|
274
274
|
// Used to specify the height of the sideNav
|
|
275
|
+
initiallyExpandedItemIndex: PropTypes.number,
|
|
276
|
+
// Used to specify the index of the item that should be expanded by default
|
|
275
277
|
items: PropTypes.arrayOf(PropTypes.shape({
|
|
276
278
|
iconName: PropTypes.string.isRequired,
|
|
277
279
|
name: PropTypes.string.isRequired,
|
|
278
280
|
badgeNumber: PropTypes.string,
|
|
279
281
|
badgeDot: PropTypes.bool,
|
|
282
|
+
hide: PropTypes.bool,
|
|
280
283
|
large: PropTypes.bool,
|
|
281
284
|
bottomAligned: PropTypes.bool,
|
|
282
285
|
actionType: PropTypes.oneOf(["component", "link", "button"]).isRequired,
|
|
@@ -298,6 +301,13 @@ SideNav.__docgenInfo = {
|
|
|
298
301
|
},
|
|
299
302
|
"required": true
|
|
300
303
|
},
|
|
304
|
+
"initiallyExpandedItemIndex": {
|
|
305
|
+
"description": "",
|
|
306
|
+
"type": {
|
|
307
|
+
"name": "number"
|
|
308
|
+
},
|
|
309
|
+
"required": false
|
|
310
|
+
},
|
|
301
311
|
"items": {
|
|
302
312
|
"description": "",
|
|
303
313
|
"type": {
|
|
@@ -321,6 +331,10 @@ SideNav.__docgenInfo = {
|
|
|
321
331
|
"name": "bool",
|
|
322
332
|
"required": false
|
|
323
333
|
},
|
|
334
|
+
"hide": {
|
|
335
|
+
"name": "bool",
|
|
336
|
+
"required": false
|
|
337
|
+
},
|
|
324
338
|
"large": {
|
|
325
339
|
"name": "bool",
|
|
326
340
|
"required": false
|