Skip to content

Commit 7cf6a59

Browse files
committed
Adds initial work on theme structure.
Adds initial work theme colors, spacing, radius and typography. Adds typography sizes WIP - Feedback Adds rebass Adds initial theme changes Adds theme provider to stories Moves stories to ts Adds button variants and placeholder colors Visualizes palette Adds font weights, space, radius and buttons Cleans up variants file Updates palette display Moves theme to root Cleans up some type definitions
1 parent 24e3729 commit 7cf6a59

20 files changed

+621
-37
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
node_modules
2-
build
2+
storybook-static
3+
build
4+
lib

.storybook/config.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
1+
import React from 'react';
2+
import { ThemeProvider } from 'styled-components'
13
import { configure } from '@storybook/react';
24
import { setAddon, addDecorator } from '@storybook/react';
35
import JSXAddon from 'storybook-addon-jsx';
46
import { withInfo } from '@storybook/addon-info';
57

8+
import { Theme } from "../theme/index";
9+
610
setAddon(JSXAddon);
711
addDecorator(withInfo);
12+
addDecorator(story => (
13+
<ThemeProvider theme={Theme}>
14+
{story()}
15+
</ThemeProvider>
16+
))
817

918
// automatically import all files ending in *.stories.js
10-
const req = require.context('../src', true, /.stories.js$/);
19+
const req = require.context('../src', true, /\.stories\.tsx$/);
1120
function loadStories() {
1221
req.keys().forEach(req);
1322
}

.storybook/webpack.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ const styledComponentsTransformer = createStyledComponentsTransformer();
55

66
module.exports = ({ config, mode }) => {
77
config.module.rules.push({
8-
test: /\.tsx?$/,
9-
include: path.resolve(__dirname, "../src"),
8+
test: /\.(ts|tsx)$/,
9+
include: [path.resolve(__dirname, "../src"), path.resolve(__dirname, "../theme")],
1010
use: [
1111
{
1212
loader: require.resolve("awesome-typescript-loader"),

package-lock.json

+184
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
"main": "index.js",
55
"license": "MIT",
66
"devDependencies": {
7+
"@babel/core": "^7.4.3",
78
"@storybook/addon-actions": "^5.0.10",
89
"@storybook/addon-info": "^5.0.10",
910
"@storybook/addon-links": "^5.0.10",
1011
"@storybook/addons": "^5.0.10",
1112
"@storybook/react": "^5.0.10",
1213
"@types/jest": "^23.3.10",
1314
"@types/react-test-renderer": "^16.0.3",
15+
"@types/rebass": "^3.0.3",
1416
"@types/storybook__react": "^4.0.1",
1517
"@types/styled-components": "^4.1.2",
1618
"awesome-typescript-loader": "^5.2.1",
@@ -28,12 +30,13 @@
2830
"dependencies": {
2931
"react": "^16.6.3",
3032
"react-dom": "^16.6.3",
33+
"rebass": "^3.1.0",
3134
"styled-components": "^4.1.2"
3235
},
3336
"scripts": {
3437
"storybook": "start-storybook -p 6006",
3538
"build-storybook": "build-storybook",
36-
"check-types": "tsc",
39+
"compile": "tsc",
3740
"test": "jest"
3841
}
39-
}
42+
}

src/button/__tests__/button.test.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import { Button } from "../index";
55

66
describe("Button test suite", () => {
77
test("Snapshot test", () => {
8-
const tree = renderer.create(<Button>Facebook</Button>).toJSON();
8+
const tree = renderer
9+
.create(<Button variant="primary">Facebook</Button>)
10+
.toJSON();
911

1012
expect(tree).toMatchSnapshot();
1113
});

src/button/button.stories.js

-18
This file was deleted.

src/button/button.stories.tsx

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import * as React from "react";
2+
import { storiesOf } from "@storybook/react";
3+
4+
import { Button } from "./index";
5+
6+
const stories = storiesOf("Button", module);
7+
8+
stories
9+
.add("Primary", () => <Button variant="primary">Hello TypeScript</Button>, {
10+
info: { inline: true }
11+
})
12+
.add(
13+
"Secondary",
14+
() => <Button variant="secondary">Hello TypeScript</Button>,
15+
{
16+
info: { inline: true }
17+
}
18+
)
19+
.add(
20+
"Disabled",
21+
() => (
22+
<Button variant="primary" isDisabled={true}>
23+
Hello TypeScript
24+
</Button>
25+
),
26+
{
27+
info: { inline: true }
28+
}
29+
);

src/button/index.tsx

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import * as React from "react";
2-
import styled from "styled-components";
3-
4-
const StyledButton = styled.button`
5-
background-color: blue;
6-
font-size: 20px;
7-
`;
2+
import { Button as BaseButton } from "rebass";
83

94
export interface Props {
105
/** Children to be rendered. */
@@ -15,16 +10,25 @@ export interface Props {
1510
* @default false
1611
*/
1712
isDisabled?: boolean;
13+
/**
14+
* Type of display that the button should be shown.
15+
*
16+
* @default primary
17+
*/
18+
variant: string;
1819
}
1920

2021
function Button(props: Props) {
2122
return (
22-
<StyledButton disabled={props.isDisabled}>{props.children}</StyledButton>
23+
<BaseButton variant={props.variant} disabled={props.isDisabled}>
24+
{props.children}
25+
</BaseButton>
2326
);
2427
}
2528

2629
Button.defaultProps = {
27-
isDisabled: false
30+
isDisabled: false,
31+
variant: "primary"
2832
};
2933

3034
export { Button };

0 commit comments

Comments
 (0)