Skip to content

Commit 760b309

Browse files
initial commit
0 parents  commit 760b309

File tree

21 files changed

+28922
-0
lines changed

21 files changed

+28922
-0
lines changed

.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["react", "es2015", "stage-0"]
3+
}

.eslintrc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
extends: airbnb
2+
rules:
3+
max-len: [1, 120, 4]
4+
no-multi-spaces: 0
5+
react/require-extension: 0
6+
react/forbid-prop-types: 0
7+
react/jsx-filename-extension: [1, { extensions: [.test.js, .jsx] }]
8+
react/require-default-props: 0
9+
globals:
10+
document: true
11+
foo: true
12+
window: true
13+
describe: true
14+
it: true
15+
expect: true

.yarnclean

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# test directories
2+
__tests__
3+
test
4+
tests
5+
powered-test
6+
7+
# asset directories
8+
docs
9+
doc
10+
website
11+
images
12+
assets
13+
14+
# examples
15+
example
16+
examples
17+
18+
# code coverage directories
19+
coverage
20+
.nyc_output
21+
22+
# build scripts
23+
Makefile
24+
Gulpfile.js
25+
Gruntfile.js
26+
27+
# configs
28+
.tern-project
29+
.gitattributes
30+
.editorconfig
31+
.*ignore
32+
.eslintrc
33+
.jshintrc
34+
.flowconfig
35+
.documentup.json
36+
.yarn-metadata.json
37+
.*.yml
38+
*.yml
39+
40+
# misc
41+
*.gz
42+
*.md

npm-debug.log

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
0 info it worked if it ends with ok
2+
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'test' ]
3+
2 info using [email protected]
4+
3 info using [email protected]
5+
4 verbose run-script [ 'pretest', 'test', 'posttest' ]
6+
5 info lifecycle [email protected]~pretest: [email protected]
7+
6 silly lifecycle [email protected]~pretest: no script for pretest, continuing
8+
7 info lifecycle [email protected]~test: [email protected]
9+
8 verbose lifecycle [email protected]~test: unsafe-perm in lifecycle true
10+
9 verbose lifecycle [email protected]~test: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/vincentbollaert/Sites/open-sauces/super-simple-flex-grid-react/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin:/usr/local/bin
11+
10 verbose lifecycle [email protected]~test: CWD: /Users/vincentbollaert/Sites/open-sauces/super-simple-flex-grid-react
12+
11 silly lifecycle [email protected]~test: Args: [ '-c', 'mocha -w test/helpers/browser.js src/**/*.test.js' ]
13+
12 silly lifecycle [email protected]~test: Returned: code: 1 signal: null
14+
13 info lifecycle [email protected]~test: Failed to exec test script
15+
14 verbose stack Error: [email protected] test: `mocha -w test/helpers/browser.js src/**/*.test.js`
16+
14 verbose stack Exit status 1
17+
14 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:279:16)
18+
14 verbose stack at emitTwo (events.js:106:13)
19+
14 verbose stack at EventEmitter.emit (events.js:192:7)
20+
14 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
21+
14 verbose stack at emitTwo (events.js:106:13)
22+
14 verbose stack at ChildProcess.emit (events.js:192:7)
23+
14 verbose stack at maybeClose (internal/child_process.js:890:16)
24+
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
25+
15 verbose pkgid [email protected]
26+
16 verbose cwd /Users/vincentbollaert/Sites/open-sauces/super-simple-flex-grid-react
27+
17 error Darwin 14.5.0
28+
18 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "test"
29+
19 error node v7.5.0
30+
20 error npm v4.1.2
31+
21 error code ELIFECYCLE
32+
22 error [email protected] test: `mocha -w test/helpers/browser.js src/**/*.test.js`
33+
22 error Exit status 1
34+
23 error Failed at the [email protected] test script 'mocha -w test/helpers/browser.js src/**/*.test.js'.
35+
23 error Make sure you have the latest version of node.js and npm installed.
36+
23 error If you do, this is most likely a problem with the super-simple-flex-grid-react package,
37+
23 error not with npm itself.
38+
23 error Tell the author that this fails on your system:
39+
23 error mocha -w test/helpers/browser.js src/**/*.test.js
40+
23 error You can get information on how to open an issue for this project with:
41+
23 error npm bugs super-simple-flex-grid-react
42+
23 error Or if that isn't available, you can get their info via:
43+
23 error npm owner ls super-simple-flex-grid-react
44+
23 error There is likely additional logging output above.
45+
24 verbose exit [ 1, true ]

package.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"name": "super-simple-flex-grid-react",
3+
"version": "1.0.0",
4+
"description": "A react super simple flex grid",
5+
"main": "src/FlexGrid",
6+
"scripts": {
7+
"webpack": "webpack-dev-server --progress --watch",
8+
"build": "webpack",
9+
"test": "mocha -w test/helpers/browser.js src/**/*.test.js"
10+
},
11+
"repository": "git+https://github.com/open-sauces/super-simple-flex-grid-react.git",
12+
"author": "Vincent Bollaert",
13+
"license": "MIT",
14+
"bugs": {
15+
"url": "https://github.com/open-sauces/super-simple-flex-grid-react/issues"
16+
},
17+
"homepage": "https://github.com/open-sauces/super-simple-flex-grid-react#readme",
18+
"dependencies": {
19+
"babel": "^6.5.2",
20+
"babel-core": "^6.22.1",
21+
"babel-loader": "^6.2.10",
22+
"babel-plugin-transform-runtime": "^6.22.0",
23+
"babel-polyfill": "^6.22.0",
24+
"babel-preset-es2015": "^6.22.0",
25+
"babel-preset-react": "^6.22.0",
26+
"babel-preset-stage-0": "^6.22.0",
27+
"chai": "^3.5.0",
28+
"chai-enzyme": "^0.6.1",
29+
"classnames": "^2.2.5",
30+
"css-loader": "^0.26.1",
31+
"enzyme": "^2.7.1",
32+
"eslint": "^3.13.0",
33+
"eslint-config-airbnb": "^14.1.0",
34+
"eslint-config-airbnb-base": "^11.0.0",
35+
"eslint-import-resolver-webpack": "^0.8.0",
36+
"eslint-plugin-jsx-a11y": "^4.0.0",
37+
"eslint-plugin-react": "^6.10.0",
38+
"html-webpack-plugin": "^2.28.0",
39+
"jsdom": "^9.10.0",
40+
"mocha": "^3.2.0",
41+
"postcss-loader": "^1.2.2",
42+
"react": "^15.4.2",
43+
"react-addons-test-utils": "^15.4.2",
44+
"react-dom": "^15.4.2",
45+
"sass-loader": "^4.1.1",
46+
"style-loader": "^0.13.1",
47+
"super-simple-flex-grid": "^1.0.6",
48+
"webpack": "^2.2.1",
49+
"webpack-dev-server": "^2.3.0"
50+
}
51+
}

src/FlexGrid/FlexCell/FlexCell.jsx

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import React, { PropTypes } from 'react';
2+
import classnames from 'classnames';
3+
import classList from 'super-simple-flex-grid/src/style.scss';
4+
5+
const testClassList = prop => ({
6+
center: 'test-center',
7+
centerH: 'test-center-h',
8+
centerV: 'test-center-v',
9+
startH: 'test-start-h',
10+
endH: 'test-end-h',
11+
startV: 'test-start-v',
12+
endV: 'test-end-v',
13+
spaceAround: 'test-space-around',
14+
spaceBetween: 'test-space-between',
15+
grow: `test-grow-${prop}`,
16+
shrink: 'test-shrink',
17+
ellipsis: 'test-ellipsis',
18+
noMargin: 'test-no-margin',
19+
});
20+
21+
const FlexCell = ({
22+
customClass,
23+
children,
24+
center,
25+
centerH,
26+
centerV,
27+
startH,
28+
startV,
29+
endH,
30+
endV,
31+
spaceAround,
32+
spaceBetween,
33+
grow,
34+
shrink,
35+
ellipsis,
36+
noMargin,
37+
}) => {
38+
const flexCellClass = 'flex-row__cell';
39+
const setClass = modifier => `${flexCellClass}--${modifier}`;
40+
41+
const flexCellClassWithModifier = classnames(flexCellClass, {
42+
[customClass]: customClass,
43+
[setClass(classList.center || testClassList().center)]: center,
44+
[setClass(classList.centerH || testClassList().centerH)]: centerH,
45+
[setClass(classList.centerV || testClassList().centerV)]: centerV,
46+
[setClass(classList.startH || testClassList().startH)]: startH,
47+
[setClass(classList.endH || testClassList().endH)]: endH,
48+
[setClass(classList.startV || testClassList().startV)]: startV,
49+
[setClass(classList.endV || testClassList().endV)]: endV,
50+
[setClass(classList.spaceAround || testClassList().spaceAround)]: spaceAround,
51+
[setClass(classList.spaceBetween || testClassList().spaceBetween)]: spaceBetween,
52+
[setClass(`${classList.grow || testClassList(grow).grow}`)]: grow,
53+
[setClass(classList.shrink || testClassList().shrink)]: shrink,
54+
[setClass(classList.ellipsis || testClassList().ellipsis)]: ellipsis,
55+
[setClass(classList.noMargin || testClassList().noMargin)]: noMargin,
56+
});
57+
58+
return (
59+
<div className={flexCellClassWithModifier}>
60+
{!ellipsis && children}
61+
{
62+
ellipsis &&
63+
<div className={`${flexCellClass}--${classnames(classList.ellipsisContent)}`}>
64+
{children}
65+
</div>
66+
}
67+
</div>
68+
);
69+
};
70+
71+
FlexCell.propTypes = {
72+
customClass: PropTypes.string,
73+
children: PropTypes.any,
74+
center: PropTypes.bool,
75+
centerH: PropTypes.bool,
76+
centerV: PropTypes.bool,
77+
startH: PropTypes.bool,
78+
startV: PropTypes.bool,
79+
endH: PropTypes.bool,
80+
endV: PropTypes.bool,
81+
spaceAround: PropTypes.bool,
82+
spaceBetween: PropTypes.bool,
83+
grow: PropTypes.string,
84+
shrink: PropTypes.bool,
85+
ellipsis: PropTypes.bool,
86+
noMargin: PropTypes.bool,
87+
};
88+
89+
export { testClassList };
90+
export default FlexCell;
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import React from 'react';
2+
import chai, { expect } from 'chai';
3+
import { shallow } from 'enzyme';
4+
import chaiEnzyme from 'chai-enzyme';
5+
6+
import FlexCell, { testClassList } from './FlexCell';
7+
8+
chai.use(chaiEnzyme());
9+
10+
11+
describe('<FlexCell />', () => {
12+
const baseElementClass = 'flex-row__cell';
13+
const baseElementSelector = `.${baseElementClass}`;
14+
const determineElementClass = modifier => `${baseElementClass} ${baseElementClass}--${modifier}`;
15+
16+
it('Renders children prop', () => {
17+
const childProp = 'Child';
18+
const wrapper = shallow(<FlexCell>{childProp}</FlexCell>);
19+
expect(wrapper.find(baseElementSelector)).to.have.text(childProp);
20+
});
21+
22+
it('Renders center prop', () => {
23+
const wrapper = shallow(<FlexCell center />);
24+
expect(wrapper.find(baseElementSelector)).to.have.className(determineElementClass(testClassList().center));
25+
});
26+
27+
it('Renders centerH prop', () => {
28+
const wrapper = shallow(<FlexCell centerH />);
29+
expect(wrapper.find(baseElementSelector)).to.have.className(determineElementClass(testClassList().centerH));
30+
});
31+
32+
it('Renders centerV prop', () => {
33+
const wrapper = shallow(<FlexCell centerV />);
34+
expect(wrapper.find(baseElementSelector)).to.have.className(determineElementClass(testClassList().centerV));
35+
});
36+
37+
it('Renders startH prop', () => {
38+
const wrapper = shallow(<FlexCell startH />);
39+
expect(wrapper.find(baseElementSelector)).to.have.className(determineElementClass(testClassList().startH));
40+
});
41+
42+
it('Renders endH prop', () => {
43+
const wrapper = shallow(<FlexCell endH />);
44+
expect(wrapper.find(baseElementSelector)).to.have.className(determineElementClass(testClassList().endH));
45+
});
46+
47+
it('Renders startV prop', () => {
48+
const wrapper = shallow(<FlexCell startV />);
49+
expect(wrapper.find(baseElementSelector)).to.have.className(determineElementClass(testClassList().startV));
50+
});
51+
52+
it('Renders endV prop', () => {
53+
const wrapper = shallow(<FlexCell endV />);
54+
expect(wrapper.find(baseElementSelector)).to.have.className(determineElementClass(testClassList().endV));
55+
});
56+
57+
it('Renders spaceAround prop', () => {
58+
const wrapper = shallow(<FlexCell spaceAround />);
59+
expect(wrapper.find(baseElementSelector)).to.have.className(determineElementClass(testClassList().spaceAround));
60+
});
61+
62+
it('Renders spaceBetween prop', () => {
63+
const wrapper = shallow(<FlexCell spaceBetween />);
64+
expect(wrapper.find(baseElementSelector)).to.have.className(determineElementClass(testClassList().spaceBetween));
65+
});
66+
67+
it('Renders grow prop', () => {
68+
const wrapper = shallow(<FlexCell grow={'2'} />);
69+
expect(wrapper.find(baseElementSelector)).to.have.className(determineElementClass(testClassList(2).grow));
70+
});
71+
72+
it('Renders shrink prop', () => {
73+
const wrapper = shallow(<FlexCell shrink />);
74+
expect(wrapper.find(baseElementSelector)).to.have.className(determineElementClass(testClassList().shrink));
75+
});
76+
77+
it('Renders ellipsis prop', () => {
78+
const wrapper = shallow(<FlexCell ellipsis />);
79+
expect(wrapper.find(baseElementSelector)).to.have.className(determineElementClass(testClassList().ellipsis));
80+
});
81+
82+
it('Renders noMargin prop', () => {
83+
const wrapper = shallow(<FlexCell noMargin />);
84+
expect(wrapper.find(baseElementSelector)).to.have.className(determineElementClass(testClassList().noMargin));
85+
});
86+
});

src/FlexGrid/FlexRow/FlexRow.jsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React, { PropTypes } from 'react';
2+
import classnames from 'classnames';
3+
4+
const FlexRow = ({ children, customClass }) => {
5+
const flexRowClass = classnames('flex-row', {
6+
[customClass]: customClass,
7+
});
8+
9+
return (
10+
<div className={flexRowClass}>
11+
{children}
12+
</div>
13+
);
14+
};
15+
16+
FlexRow.propTypes = {
17+
children: PropTypes.any,
18+
customClass: PropTypes.string,
19+
};
20+
21+
export default FlexRow;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import React from 'react';
2+
import chai, { expect } from 'chai';
3+
import { shallow } from 'enzyme';
4+
import chaiEnzyme from 'chai-enzyme';
5+
import FlexRow from './FlexRow';
6+
7+
chai.use(chaiEnzyme());
8+
9+
10+
describe('<FlexRow />', () => {
11+
const elementSelector = '.flex-row';
12+
13+
it('Renders children prop', () => {
14+
const childProp = 'Child';
15+
const wrapper = shallow(<FlexRow>{childProp}</FlexRow>);
16+
expect(wrapper.find(elementSelector)).to.have.text(childProp);
17+
});
18+
19+
it('Renders customClass prop', () => {
20+
const customClass = 'custom-class';
21+
const wrapper = shallow(<FlexRow customClass={customClass} />);
22+
expect(wrapper.find(elementSelector)).to.have.className(customClass);
23+
});
24+
});

src/FlexGrid/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { default as FlexRow } from './FlexRow/FlexRow';
2+
export { default as FlexCell } from './FlexCell/FlexCell';

0 commit comments

Comments
 (0)