Skip to content
This repository was archived by the owner on Apr 26, 2019. It is now read-only.

Commit 7e1e504

Browse files
marijohannessenGitHub Enterprise
authored and
GitHub Enterprise
committed
Pages creation, routes, side nav structure (#866)
* started setting up environment * added eslint and tested out routes: * added fonts back in * added routes and site nav structure * fixed some routes and added box-sizing * refactored the sidenav * refactored more * refactored the side nav * removed dist files * added assets to gitignore * removed assets * put it back but its ignored * updated favicon * fixed fonts
1 parent 05b692c commit 7e1e504

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+594
-90
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ coverage
66

77
# production
88
build
9+
dist
910

1011
# misc
1112
.DS_Store

.sass-lint.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Linter Options
2+
options:
3+
# Don't merge default rules
4+
merge-default-rules: false
5+
# File Options
6+
files:
7+
ignore:
8+
- 'src/assets/fonts/font-face.scss'
9+
# Rule Configuration
10+
rules:
11+
# Extends and Mixins
12+
extends-before-mixins: 1
13+
extends-before-declarations: 1
14+
placeholder-in-extend: 1
15+
mixins-before-declarations: 1
16+
# Spaces and Lines
17+
one-declaration-per-line: 1
18+
final-newline: 1
19+
indentation: 1
20+
space-before-brace: 1
21+
space-after-comma: 1
22+
space-around-operator: 1
23+
empty-line-between-blocks:
24+
- 1
25+
- include: true
26+
- allow-single-line-rulesets: true
27+
# Other
28+
leading-zero: 1
29+
trailing-semicolon: 1
30+
quotes:
31+
- 1
32+
- style: single
33+
# Not Allowed
34+
no-color-keywords: 2
35+
no-misspelled-properties: 2
36+
no-ids: 2
37+
no-important: 2
38+
no-empty-rulesets: 2
39+
no-duplicate-properties: 1
40+
# Units
41+
property-units:
42+
- global: ['rem', 'px']

HELP.md

Whitespace-only changes.

config/webpack.config.dev.js

-14
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,7 @@ module.exports = {
131131
cacheDirectory: true
132132
}
133133
},
134-
// "postcss" loader applies autoprefixer to our CSS.
135-
// "css" loader resolves paths in CSS and adds assets as dependencies.
136134
// "style" loader turns CSS into JS modules that inject <style> tags.
137-
// In production, we use a plugin to extract that CSS to a file, but
138-
// in development "style" loader enables hot editing of CSS.
139135
{
140136
test: /\.(css|scss)$/,
141137
loader: 'style!css?importLoaders=1!postcss!sass'
@@ -177,24 +173,14 @@ module.exports = {
177173
new InterpolateHtmlPlugin({
178174
PUBLIC_URL: publicUrl
179175
}),
180-
// Generates an `index.html` file with the <script> injected.
181176
new HtmlWebpackPlugin({
182177
inject: true,
183178
template: paths.appHtml,
184179
}),
185-
// Makes some environment variables available to the JS code, for example:
186-
// if (process.env.NODE_ENV === 'development') { ... }. See `./env.js`.
187180
new webpack.DefinePlugin(env),
188181
// This is necessary to emit hot updates (currently CSS only):
189182
new webpack.HotModuleReplacementPlugin(),
190-
// Watcher doesn't work well if you mistype casing in a path so we use
191-
// a plugin that prints an error when you attempt to do this.
192-
// See https://github.com/facebookincubator/create-react-app/issues/240
193183
new CaseSensitivePathsPlugin(),
194-
// If you require a missing module and then `npm install` it, you still have
195-
// to restart the development server for Webpack to discover it. This plugin
196-
// makes the discovery automatic so you don't have to restart.
197-
// See https://github.com/facebookincubator/create-react-app/issues/186
198184
new WatchMissingNodeModulesPlugin(paths.appNodeModules),
199185
new CopyWebpackPlugin([
200186
{

package.json

+5-14
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"dependencies": {
5353
"@console/bluemix-components": "^6.11.5",
5454
"@console/bluemix-components-react": "^1.2.0",
55+
"classnames": "^2.2.5",
5556
"markdown-loader": "^0.1.7",
5657
"react": "^15.4.2",
5758
"react-dom": "^15.4.2",
@@ -95,10 +96,6 @@
9596
]
9697
},
9798
"eslintConfig": {
98-
"globals": {
99-
"window": true,
100-
"document": true
101-
},
10299
"parser": "babel-eslint",
103100
"extends": "airbnb",
104101
"rules": {
@@ -107,21 +104,15 @@
107104
130,
108105
4
109106
],
107+
"react/jsx-filename-extension": 0,
110108
"no-underscore-dangle": 0,
111109
"react/prefer-stateless-function": 0,
112110
"react/require-default-props": 0,
113-
"react/jsx-filename-extension": [
114-
1,
115-
{
116-
"extensions": [
117-
".js",
118-
".jsx"
119-
]
120-
}
121-
]
111+
"react/prop-types": 0,
112+
"jsx-a11y/no-static-element-interactions": 0
122113
},
123114
"env": {
124-
"jest": true
115+
"browser": true
125116
}
126117
}
127118
}

public/favicon.ico

7.96 KB
Binary file not shown.

public/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
work correctly both with client-side routing and a non-root public URL.
1414
Learn how to configure a non-root public URL by running `npm run build`.
1515
-->
16-
<title>React App</title>
16+
<title>Carbon Design System</title>
1717
</head>
1818
<body>
1919
<div id="root"></div>

src/assets/svg/bluemix-icons.svg

+1
Loading

src/components/SideNav/SideNav.js

+53-18
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,60 @@
11
import React from 'react';
22
import { Link } from 'react-router';
33

4-
const SideNav = () => (
5-
<div className="side-nav">
6-
<Link to="/" className="side-nav__logo">
7-
Carbon <br /><span>Design System</span>
8-
</Link>
9-
<ul className="side-nav__menu">
10-
<li className="menu-item">
11-
<p className="menu-item__heading">Getting Started</p>
4+
import Icon from '@console/bluemix-components-react/dist/components/Icon';
5+
6+
import SiteNavStructure from '../../data/site-nav-structure.json';
7+
import SideNavItem from '../SideNavItem/SideNavItem';
8+
9+
class SideNav extends React.Component {
10+
renderSubNavItems = (subnav, parentItem) =>
11+
Object.keys(subnav).map(subNavItem =>
12+
<SideNavItem key={subNavItem} className="sub-nav__item">
13+
<Link className="sub-nav__item-link" to={`/${parentItem}/${subNavItem}`}>{subnav[subNavItem]}</Link>
14+
</SideNavItem>,
15+
);
16+
17+
renderSubNav = (subnav, parentItem) => {
18+
const subNavItems = this.renderSubNavItems(subnav, parentItem);
19+
return (
20+
<SideNavItem key={parentItem} className="menu-item">
21+
<p className="menu-item__heading">{SiteNavStructure[parentItem].title}
22+
<Icon className="menu-item__arrow" name="caret--down" description="Menu arrow icon" />
23+
</p>
1224
<ul className="menu__sub-nav">
13-
<li className="sub-nav__item">
14-
<Link className="sub-nav__item-link" to="/designers">Designers</Link>
15-
</li>
16-
<li className="sub-nav__item">
17-
<Link className="sub-nav__item-link" to="/developers">Developers</Link>
18-
</li>
25+
{subNavItems}
26+
</ul>
27+
</SideNavItem>
28+
);
29+
}
30+
31+
renderSiteItems = navItems =>
32+
Object.keys(navItems).map((navItem) => {
33+
const navItemObj = navItems[navItem];
34+
if (navItemObj.subnav) {
35+
return this.renderSubNav(navItemObj.subnav, navItem);
36+
}
37+
return (
38+
<SideNavItem key={navItem} className="menu-item">
39+
<Link className="menu-item__heading" to={navItem}>{navItemObj.title}</Link>
40+
</SideNavItem>
41+
);
42+
});
43+
44+
render() {
45+
const navItems = this.renderSiteItems(SiteNavStructure);
46+
47+
return (
48+
<div className="side-nav">
49+
<Link to="/" className="side-nav__logo">
50+
Carbon <br /><span>Design System</span>
51+
</Link>
52+
<ul className="side-nav__menu">
53+
{navItems}
1954
</ul>
20-
</li>
21-
</ul>
22-
</div>
23-
);
55+
</div>
56+
);
57+
}
58+
}
2459

2560
export default SideNav;

src/components/SideNav/sidenav.scss

+45-21
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
.side-nav {
22
@include font-smoothing;
33
font-size: rem(14px);
4-
background-color: $dark-bg-color;
4+
background-color: #1d3649; // color not in our library
55
border-right: 2px solid $color__navy-gray-3;
6-
width: 12.438rem;
6+
width: rem(245px);
77
height: 100%;
88
padding: 1rem 1.25rem 2rem 1.5rem;
99
position: fixed;
@@ -26,6 +26,36 @@
2626
}
2727
}
2828

29+
.menu__sub-nav {
30+
list-style: none;
31+
padding-left: 0;
32+
max-height: 0;
33+
overflow: hidden;
34+
transition: .3s;
35+
36+
.sub-nav__item {
37+
text-transform: capitalize;
38+
margin-left: 0;
39+
padding: .5rem;
40+
color: $color__navy-gray-8;
41+
42+
&:hover {
43+
color: $color__blue-30;
44+
}
45+
46+
&:first-child {
47+
margin-top: 1rem;
48+
}
49+
50+
&-link {
51+
color: inherit;
52+
text-decoration: none;
53+
cursor: pointer;
54+
font-weight: normal;
55+
}
56+
}
57+
}
58+
2959
.side-nav__menu {
3060
list-style: none;
3161
padding-left: 0;
@@ -34,6 +64,10 @@
3464
border-top: 1px solid $color__blue-20;
3565
padding: 1.5rem 0;
3666

67+
&:hover {
68+
color: $color__blue-30;
69+
}
70+
3771
&:last-child {
3872
border-bottom: 1px solid $color__blue-20;
3973
}
@@ -49,36 +83,26 @@
4983
font-weight: 600;
5084
letter-spacing: 2px;
5185
margin-bottom: 0;
86+
text-decoration: none;
5287
}
5388

5489
&__arrow {
5590
height: rem(10px);
5691
width: rem(10px);
5792
fill: $color__gray-3;
5893
margin-right: .5rem;
94+
transition: .3s;
5995
}
60-
}
61-
}
6296

63-
.menu__sub-nav {
64-
list-style: none;
65-
padding-left: 0;
97+
&__open {
6698

67-
.sub-nav__item {
68-
text-transform: capitalize;
69-
margin-left: 0;
70-
padding: .5rem;
71-
color: $color__navy-gray-8;
72-
73-
&:first-child {
74-
margin-top: 1rem;
75-
}
99+
& .menu__sub-nav {
100+
max-height: 30rem;
101+
}
76102

77-
&-link {
78-
color: inherit;
79-
text-decoration: none;
80-
cursor: pointer;
81-
font-weight: normal;
103+
& .menu-item__arrow {
104+
transform: rotate(-180deg);
105+
}
82106
}
83107
}
84108
}
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import React from 'react';
2+
import classnames from 'classnames';
3+
4+
class SideNavItem extends React.Component {
5+
state = {
6+
open: this.props.open,
7+
}
8+
9+
handleClick = (evt) => {
10+
const targetIsSubItem = evt.target.classList.contains('sub-nav__item-link');
11+
if (!targetIsSubItem) {
12+
const open = !this.state.open;
13+
this.setState({ open });
14+
}
15+
}
16+
17+
render() {
18+
const classNames = classnames({
19+
'menu-item__open': this.state.open,
20+
},
21+
this.props.className,
22+
);
23+
return (
24+
<li className={classNames} onClick={this.handleClick}>
25+
{this.props.children}
26+
</li>
27+
);
28+
}
29+
}
30+
31+
export default SideNavItem;

0 commit comments

Comments
 (0)