Skip to content

Commit 3037c80

Browse files
authored
feature/UIDS-185 move Header, SidebarNav, SidebarView into DS (#186)
* moves original header and sidebar_nav into DS * fix PropTypes & scss imports in components * update scss theme imports * add NavLink, react-router-dom dependency * moves original sidebar_view into DS * adds timing.scss variables to theme * updates scss import on SidebarView component * adds react-modal, keyCodes, fix PropTypes in SidebarView * create anchors.scss * move Header, SidebarNav, SidebarView into Layout
1 parent 558e362 commit 3037c80

21 files changed

+613
-4
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "@user-interviews/ui-design-system",
33
"version": "1.14.1",
44
"dependencies": {
5+
"react-router-dom": "^5.2.0",
56
"react-select": "^3.0.8",
67
"react-transition-group": "^4.3.0",
78
"uuid": "^7.0.2"
@@ -94,6 +95,7 @@
9495
"react": "^16.12.0",
9596
"react-copy-to-clipboard": "^5.0.2",
9697
"react-dom": "^16.12.0",
98+
"react-modal": "^3.12.1",
9799
"react-popper": "^2.2.3",
98100
"react-test-renderer": "^16.12.0",
99101
"react-tracking": "^7.3.0",

scss/anchors.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// This should be included directly on the a element
2+
@mixin ui-remove-anchor-styles($color: inherit) {
3+
color: $color;
4+
5+
&:active, &:focus, &:hover {
6+
color: $color;
7+
outline: none;
8+
text-decoration: none;
9+
}
10+
}

scss/navbar.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
$ui-header-height: 4.5rem;
12
$ui-navbar-height: 3rem;
23
$ui-navbar-height-mobile: $ui-navbar-height;

scss/theme.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@import './anchors';
12
@import './borders';
23
@import './box_shadow';
34
@import './buttons';
@@ -7,6 +8,7 @@
78
@import './lists';
89
@import './navbar';
910
@import './spacing';
11+
@import './timing.scss';
1012
@import './typography';
1113
@import './z_stack';
1214

scss/timing.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Timing functions
2+
3+
$ux-ease-in-circ: cubic-bezier(0.6, 0.04, 0.98, 0.335);
4+
$ux-ease-out-circ: cubic-bezier(0.075, 0.82, 0.165, 1);
5+
6+
// Durations
7+
8+
$ux-duration-brief: 80ms;
9+
$ux-duration-short: 160ms;
10+
$ux-duration-long: 240ms;

src/Layout/Header/Controls.jsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react';
2+
3+
const Controls = props => (
4+
<div className="Header__controls">
5+
{props.children}
6+
</div>
7+
);
8+
9+
export default Controls;

src/Layout/Header/Header.jsx

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
4+
import Controls from './Controls';
5+
6+
import './Header.scss';
7+
8+
const Header = ({
9+
controls,
10+
isMobileView,
11+
isSidebarOpen,
12+
titleComponent,
13+
onToggleSidebarRequest,
14+
}) => (
15+
<div className="Header">
16+
{titleComponent}
17+
<Controls>
18+
{!isMobileView && controls}
19+
{isMobileView && (
20+
<button
21+
className="btn btn-primary btn-outline-neutral"
22+
type="button"
23+
onClick={onToggleSidebarRequest}
24+
>
25+
{isSidebarOpen ? 'Close' : 'Menu'}
26+
</button>
27+
)}
28+
</Controls>
29+
</div>
30+
);
31+
32+
Header.propTypes = {
33+
controls: PropTypes.arrayOf(PropTypes.node),
34+
isMobileView: PropTypes.bool.isRequired,
35+
isSidebarOpen: PropTypes.bool.isRequired,
36+
titleComponent: PropTypes.node,
37+
onToggleSidebarRequest: PropTypes.func.isRequired,
38+
};
39+
40+
Header.defaultProps = {
41+
controls: undefined,
42+
titleComponent: undefined,
43+
};
44+
45+
export default Header;

src/Layout/Header/Header.scss

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@import '../../scss/theme.scss';
2+
3+
.Header {
4+
align-items: center;
5+
background: $ux-gray-900;
6+
color: $ux-white;
7+
display: flex;
8+
height: $ui-header-height;
9+
padding: $ux-spacing-40;
10+
11+
> div:first-child {
12+
@include font-type-60--bold;
13+
flex-grow: 1;
14+
}
15+
16+
&__controls {
17+
> :not(:last-child) {
18+
margin-right: $ux-spacing-20;
19+
}
20+
}
21+
}

src/Layout/Header/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './Header';
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
4+
import './SidebarNav.scss';
5+
6+
const SidebarNav = ({ controls, isMobileView, content }) => (
7+
<div className="Layout__sidebar-nav">
8+
{content}
9+
10+
{controls && isMobileView && (
11+
<div className="Layout__sidebar-nav__mobile-controls">
12+
{controls}
13+
</div>
14+
)}
15+
</div>
16+
);
17+
18+
SidebarNav.propTypes = {
19+
content: PropTypes.node.isRequired,
20+
controls: PropTypes.arrayOf(PropTypes.node),
21+
isMobileView: PropTypes.bool.isRequired,
22+
};
23+
24+
SidebarNav.defaultProps = {
25+
controls: undefined,
26+
};
27+
28+
export default SidebarNav;

0 commit comments

Comments
 (0)