Skip to content

Commit 0a2126e

Browse files
author
Brian Stone
committed
Initial commit from create-react-styleguide v4.0.3
0 parents  commit 0a2126e

18 files changed

+291
-0
lines changed

.eslintignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/coverage
2+
/es
3+
/lib
4+
/styleguide
5+
jest.config.js
6+
styleguide.config.js

.eslintrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": ["plugin:zillow/recommended", "plugin:zillow/jest"]
3+
}

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/coverage
2+
/es
3+
/lib
4+
/node_modules
5+
/styleguide
6+
npm-debug.log*

CONTRIBUTING.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## Prerequisites
2+
3+
[Node.js](http://nodejs.org/) >= v4 must be installed.
4+
5+
## Installation
6+
7+
- Running `npm install` in the component's root directory will install everything you need for development.
8+
9+
## Demo Development Server
10+
11+
- `npm start` will run a development server with the style guide components at [http://localhost:6060](http://localhost:6060).
12+
13+
## Running Tests
14+
15+
- `npm test` will run the tests once.
16+
17+
- `npm run test:coverage` will run the tests and produce a coverage report in `coverage/`.
18+
19+
- `npm run test:update` will update the test snapshots.
20+
21+
- `npm run test:watch` will run the tests on every change.
22+
23+
## Building
24+
25+
- `npm run build` will build the component for publishing to npm and also bundle the demo app.
26+
27+
- `npm run clean` will delete built resources.

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# drywall Style Guide
2+
3+
Describe drywall here.

babel.config.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
presets: [['zillow', { modules: false }]],
3+
env: {
4+
cjs: {
5+
presets: ['zillow'],
6+
},
7+
test: {
8+
presets: ['zillow'],
9+
},
10+
},
11+
};

docs/introduction.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Provide extra Markdown documentation using the [`sections`](https://react-styleguidist.js.org/docs/components.html#sections) configuration from
2+
[react-styleguidist](https://react-styleguidist.js.org/). You can remove this introduction by deleting the sections key from `styleguide.config.js`.

jest.config.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const { createJestConfig } = require('create-react-styleguide');
2+
3+
module.exports = createJestConfig({
4+
/* your own config shallowly merged */
5+
setupFilesAfterEnv: ['jest-styled-components'],
6+
});

package.json

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"name": "drywall",
3+
"version": "1.0.0",
4+
"description": "drywall React component",
5+
"main": "lib/index.js",
6+
"module": "es/index.js",
7+
"sideEffects": false,
8+
"files": [
9+
"es",
10+
"lib",
11+
"src",
12+
"docs",
13+
"styleguide.config.js"
14+
],
15+
"scripts": {
16+
"build": "create-react-styleguide script build",
17+
"build:watch": "create-react-styleguide script build:watch",
18+
"build:styleguide": "create-react-styleguide script build:styleguide",
19+
"clean": "create-react-styleguide script clean",
20+
"eslint": "create-react-styleguide script eslint",
21+
"eslint:fix": "create-react-styleguide script eslint:fix",
22+
"start": "create-react-styleguide script start",
23+
"test": "create-react-styleguide script test",
24+
"test:coverage": "create-react-styleguide script test:coverage",
25+
"test:update": "create-react-styleguide script test:update",
26+
"test:watch": "create-react-styleguide script test:watch",
27+
"prepublishOnly": "create-react-styleguide script prepublishOnly"
28+
},
29+
"husky": {
30+
"hooks": {
31+
"pre-commit": "npm run eslint && npm run test"
32+
}
33+
},
34+
"dependencies": {
35+
"prop-types": "^15.7.2",
36+
"styled-components": "^4.2.0"
37+
},
38+
"peerDependencies": {
39+
"react": "16.x"
40+
},
41+
"devDependencies": {
42+
"babel-plugin-styled-components": "^1.10.0",
43+
"babel-preset-zillow": "^4.0.3",
44+
"create-react-styleguide": "^4.0.3",
45+
"eslint-plugin-jest": "^22.4.1",
46+
"eslint-plugin-zillow": "^3.1.0",
47+
"husky": "^1.3.1",
48+
"jest-styled-components": "^6.3.1",
49+
"react": "^16.8.6",
50+
"react-dom": "^16.8.6",
51+
"react-test-renderer": "^16.8.6"
52+
},
53+
"author": "[email protected]",
54+
"homepage": "",
55+
"license": "MIT",
56+
"repository": "",
57+
"keywords": [
58+
"react-component"
59+
]
60+
}

src/__tests__/index.test.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import React from 'react';
2+
import renderer from 'react-test-renderer';
3+
import Button, { StyledButton } from '../components/Button/Button';
4+
import Bootstrap from '../themes';
5+
6+
describe('Themed Styled Button', () => {
7+
it('displays a button with requested text', () => {
8+
const component = renderer.create(<StyledButton theme={Bootstrap}>Click Me!</StyledButton>);
9+
expect(component.toJSON()).toMatchSnapshot();
10+
});
11+
12+
it('displays a secondary button with requested text', () => {
13+
const component = renderer.create(
14+
<StyledButton theme={Bootstrap} type="secondary">
15+
⊙_ʘ
16+
</StyledButton>
17+
);
18+
expect(component.toJSON()).toMatchSnapshot();
19+
});
20+
});
21+
22+
describe('Themed Button', () => {
23+
it('displays a button with requested text', () => {
24+
const component = renderer.create(<Button theme={Bootstrap}>Click Me!</Button>);
25+
expect(component.toJSON()).toMatchSnapshot();
26+
});
27+
28+
it('displays a secondary button with requested text', () => {
29+
const component = renderer.create(
30+
<Button theme={Bootstrap} type="secondary">
31+
⊙_ʘ
32+
</Button>
33+
);
34+
expect(component.toJSON()).toMatchSnapshot();
35+
});
36+
});

src/components/Button/Button.jsx

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import styled from 'styled-components';
4+
5+
export const StyledButton = styled.button`
6+
${props => props.theme.Button};
7+
`;
8+
const Button = props => <StyledButton {...props} />;
9+
10+
Button.propTypes = {
11+
/** Button content */
12+
children: PropTypes.node.isRequired,
13+
/** Button type */
14+
type: PropTypes.oneOf(['primary', 'secondary']),
15+
/** Enable outline buttons */
16+
outline: PropTypes.bool,
17+
};
18+
19+
Button.defaultProps = {
20+
type: 'primary',
21+
outline: false,
22+
};
23+
24+
export default Button;

src/components/Button/Button.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Button types:
2+
3+
```jsx
4+
<div>
5+
<Button>Primary</Button> <Button type="secondary">Secondary</Button>
6+
</div>
7+
```
8+
9+
Outline buttons:
10+
11+
```jsx
12+
<div>
13+
<Button outline={true}>Primary</Button> <Button outline type="secondary">Secondary</Button>
14+
</div>
15+
```

src/components/Button/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './Button';

src/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './components/Button';

src/styleguidist/ThemeWrapper.jsx

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import React from 'react';
2+
import { ThemeProvider } from 'styled-components';
3+
import theme from '../themes';
4+
5+
export default props => <ThemeProvider {...props} theme={theme} />;

src/themes/Bootstrap/index.js

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/* eslint-disable no-confusing-arrow */
2+
3+
import { css } from 'styled-components';
4+
5+
const ButtonDefault = css`
6+
color: #fff;
7+
background-color: #6c747d;
8+
border-color: #6c757d;
9+
10+
&:hover {
11+
color: #fff;
12+
background-color: #5a6268;
13+
border-color: #545b62;
14+
}
15+
`;
16+
17+
const ButtonPrimary = css`
18+
color: #fff;
19+
background-color: #007bff;
20+
border-color: #007bff;
21+
22+
&:hover {
23+
color: #fff;
24+
background-color: #0069d9;
25+
border-color: #0062cc;
26+
}
27+
`;
28+
29+
const ButtonDefaultOutline = css`
30+
color: #6c757d;
31+
background-color: transparent;
32+
border-color: #6c757d;
33+
34+
&:hover {
35+
background-color: #6c757d;
36+
}
37+
`;
38+
39+
const ButtonPrimaryOutline = css`
40+
color: #007bff;
41+
background-color: transparent;
42+
border-color: #007bff;
43+
44+
&:hover {
45+
background-color: #007bff;
46+
}
47+
`;
48+
49+
const Button = css`
50+
display: inline-block;
51+
font-weight: 400;
52+
text-align: center;
53+
white-space: nowrap;
54+
vertical-align: middle;
55+
user-select: none;
56+
border: 1px solid transparent;
57+
padding: 0.375rem 0.75rem;
58+
font-size: 1rem;
59+
line-height: 1.5;
60+
border-radius: 0.25rem;
61+
transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out;
62+
63+
${props => (!props.outline && props.type === 'primary' ? ButtonPrimary : ButtonDefault)}
64+
${props => (props.outline && props.type === 'primary' ? ButtonPrimaryOutline : '')}
65+
${props => (props.outline && props.type !== 'primary' ? ButtonDefaultOutline : '')}
66+
`;
67+
68+
export default {
69+
Button,
70+
};

src/themes/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// The default export will be the theme used by the styleguide
2+
export { default } from './Bootstrap';

styleguide.config.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const path = require('path');
2+
const { createStyleguideConfig } = require('create-react-styleguide');
3+
4+
module.exports = createStyleguideConfig({
5+
/* your own config shallowly merged */
6+
sections: [{
7+
name: 'Introduction',
8+
content: 'docs/introduction.md'
9+
}],
10+
styleguideComponents: {
11+
Wrapper: path.join(__dirname, 'src/styleguidist/ThemeWrapper'),
12+
},
13+
});

0 commit comments

Comments
 (0)