Skip to content
This repository has been archived by the owner on Apr 16, 2021. It is now read-only.

Commit

Permalink
Merge 7f00770 into 6d3de43
Browse files Browse the repository at this point in the history
  • Loading branch information
colbycheeze committed Sep 9, 2016
2 parents 6d3de43 + 7f00770 commit 0072f1a
Show file tree
Hide file tree
Showing 36 changed files with 792 additions and 539 deletions.
17 changes: 9 additions & 8 deletions .storybook/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,16 @@ const env = process.env.NODE_ENV || 'development';
webpackConfig.plugins = [
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify(env),
NODE_ENV: JSON.stringify(env),
},
'NODE_ENV': env,
'__DEV__': env === 'development',
'__PROD__': env === 'production',
'__TEST__': env === 'test',
'__DEBUG__': env === 'development' && !argv.no_debug,
'__COVERAGE__': !argv.watch && env === 'test',
'__BASENAME__': JSON.stringify(process.env.BASENAME || ''),
NODE_ENV: env,
__DEV__: env === 'development',
__PROD__: env === 'production',
__TEST__: env === 'test',
__DEBUG__: env === 'development' && !argv.no_debug,
__COVERAGE__: !argv.watch && env === 'test',
__BASENAME__: JSON.stringify(process.env.BASENAME || ''),
__CONTROLLER_API__: JSON.stringify('https://fake-controller.net'),
}),
];

Expand Down
8 changes: 8 additions & 0 deletions config/ava.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
import { argv } from 'yargs';
import fs from 'fs';
import config from '../config';
import injectTapEventPlugin from 'react-tap-event-plugin';

Object.keys(config.globals).forEach(key => {
if(typeof (config.globals[key]) === 'string') {
config.globals[key] = config.globals[key].replace(/['"]+/g, '');
};
});

Object.assign(global, config.globals);

Expand All @@ -28,3 +35,4 @@ require.extensions['.html'] = (module, filename) => {
global.document = require('jsdom').jsdom(require('../src/index.html'));
global.window = document.defaultView;
global.navigator = window.navigator;
injectTapEventPlugin(); // for component tests using onTouchTap event
7 changes: 3 additions & 4 deletions config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const config = {
// ----------------------------------
// Controller Service Configuration
// ----------------------------------
controller_service : process.env.CONTROLLER_SERVICE || 'https://not.set.net',
controller_service : process.env.CONTROLLER_SERVICE,

// ----------------------------------
// Compiler Configuration
Expand Down Expand Up @@ -72,6 +72,7 @@ Edit at Your Own Risk
// Environment
// ------------------------------------
// N.B.: globals added here must _also_ be added to .eslintrc

config.globals = {
'process.env' : {
'NODE_ENV' : JSON.stringify(config.env),
Expand All @@ -83,9 +84,7 @@ config.globals = {
'__DEBUG__' : config.env === 'development' && !argv.no_debug,
'__COVERAGE__' : !argv.watch && config.env === 'test',
'__BASENAME__' : JSON.stringify(process.env.BASENAME || ''),
'__CONTROLLER_API__' : config.env === 'test' ?
`${config.controller_service}/api/v1` :
JSON.stringify(`${config.controller_service}/api/v1`),
'__CONTROLLER_API__' : JSON.stringify(config.controller_service || ''),
};

// ------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
"command": "node_modules/.bin/nyc node --harmony-proxies ./node_modules/.bin/ava",
"env": {
"NODE_ENV": "test",
"NODE_PATH": "src"
"NODE_PATH": "src",
"CONTROLLER_SERVICE": "https://fake-controller.net"
}
}
},
Expand Down
29 changes: 10 additions & 19 deletions src/components/GlobalNav/GlobalNav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,23 @@ import React from 'react';
import IconButton from 'material-ui/IconButton';
import { Toolbar, ToolbarGroup, ToolbarTitle, ToolbarSeparator } from 'material-ui/Toolbar';
import { Icon } from 'react-fa';
import { palette } from 'styles/muiTheme';
import RoleSwitcher from './RoleSwitcher';
import { Link } from 'react-router';
import RoleSwitcher from 'containers/RoleSwitcherContainer';
import classes from './GlobalNav.scss';

const styles = {
toolbar: {
backgroundColor: palette.primary1Color,
},
separator: {
backgroundColor: 'rgb(184, 222, 228)',
margin: '0px 12px 0px 24px',
},
paragraph: {
paddingLeft: '2rem',
fontSize: '0.9rem',
},
title: {
color: palette.alternateTextColor,
fontSize: '1rem',
margin: '0px 0.75rem 0px 2rem',
},
};

export const GlobalNav = () => (
<div className={classes.globalNav}>
<Toolbar style={styles.toolbar}>
<Toolbar>
<ToolbarGroup firstChild>
<ToolbarTitle text="Logistics Wizard" className={classes.title} style={styles.title} />
<Link to="/">
<ToolbarTitle text="Logistics Wizard" className={classes.title} />
</Link>
</ToolbarGroup>

<ToolbarGroup>
Expand All @@ -40,12 +30,13 @@ export const GlobalNav = () => (
className={classes.github}
/>
</IconButton>
<p className="flow-text" style={styles.paragraph}>Demo Settings</p>
<ToolbarTitle text="Demo Settings" className={classes.title} />
</ToolbarGroup>
</Toolbar>
</div>
);

GlobalNav.propTypes = {};
GlobalNav.propTypes = {
};

export default GlobalNav;
42 changes: 4 additions & 38 deletions src/components/GlobalNav/GlobalNav.scss
Original file line number Diff line number Diff line change
@@ -1,49 +1,15 @@
/* GlobalNav Styles */
.globalNav {
p {
color: rgb(255, 255, 255);
}
}
@import '~styles/base/colors';

.title {
padding-left: 2rem;
}

.separator {
background-color: rgb(184, 222, 228);
color: $alternateTextColor;
}

.github {
font-size: 1.9rem;
color: rgb(184, 222, 228);
color: $primary3Color;

&:hover {
color: rgb(255, 255, 255);
}
}

/* RoleSwitcher Styles */
.stack {
position: relative;
cursor: pointer;
margin-right: 30px;

.user {
font-size: 1.2rem;
color: rgb(15, 147, 166);
line-height: 3.3rem;
margin-left: .3rem;
}

&:hover {
.circle {
color: rgb(255, 255, 255);
}
}

.circle {
font-size: 1.9rem;
color: rgb(184, 222, 228);
line-height: 3.3rem;
color: $alternateTextColor;
}
}
20 changes: 18 additions & 2 deletions src/components/GlobalNav/GlobalNav.story.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,31 @@ import { storiesOf } from '@kadira/storybook';
import GlobalNav from './GlobalNav';
import RoleSwitcher from './RoleSwitcher';

const users = [
{
id: 1,
role: 'supplychainmanager',
loggedIn: true,
},
{
id: 2,
role: 'retailstoremanager',
location: 'Austin, TX',
},
];

storiesOf('GlobalNav', module)
.addDecorator((story) => (
<div style={{ width: '100vw' }}>
{story()}
</div>
))
.add('Default', () => (
.add('Not Logged in', () => (
<GlobalNav />
))
.add('Logged in', () => (
<GlobalNav users={users} />
))
.add('Role Switcher', () => (
<RoleSwitcher open />
<RoleSwitcher users={users} />
));
28 changes: 8 additions & 20 deletions src/components/GlobalNav/GlobalNav.test.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,22 @@
import test from 'ava';
import React from 'react';
import { shallow } from 'enzyme';
// import { Icon } from 'react-fa';
import GlobalNav from './GlobalNav';


const setup = () => {
// const spies = {
// clicky: sinon.spy(),
// };
// const props = {
// customProp: 'Test',
// clicky: spies.clicky,
// };
const spies = {
};
const props = {
};
const component = shallow(<GlobalNav />);

return { component };
return { component, props, spies };
};

test('(Component) Has expected elements.', t => {
const { component } = setup();

// t.is(component.find('Icon'), 1,
// 'contains React-FA Github Icons.');
// t.true(component.contains('<RoleSwitcher />'),
// 'contains RoleSwitcher component.');
// t.true(component.contains('<Toolbar />'),
// 'contains Toolbar component.');

t.is(component.find('Icon').length, 1);
t.is(component.find('RoleSwitcher').length, 1);
t.is(component.find('Toolbar').length, 1);
t.is(component.find('Connect(RoleSwitcher)').length, 1);
t.is(component.find('Link').length, 1);
t.is(component.find('Link').first().props().to, '/');
});
84 changes: 0 additions & 84 deletions src/components/GlobalNav/RoleItem.jsx

This file was deleted.

0 comments on commit 0072f1a

Please sign in to comment.