Skip to content

Commit b48579e

Browse files
committed
✨ Add Prototyping Sandbox Components to Common
1 parent 6998149 commit b48579e

File tree

101 files changed

+3712
-176
lines changed

Some content is hidden

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

101 files changed

+3712
-176
lines changed

packages/common/package.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
"scripts": {
1414
"build": "yarn build:lib",
1515
"build:dev": "yarn build",
16-
"build:lib": "yarn clean && yarn tsc && yarn babel src --out-dir lib && yarn cpx \"src/**/*.{css,svg,png,jpg}\" lib",
16+
"build:lib": "yarn clean && yarn tsc && yarn babel src --out-dir lib && yarn cpx \"src/**/*.{css,svg,png,jpg,woff,woff2}\" lib",
1717
"build:storybook": "build-storybook -c .storybook -o public",
1818
"clean": "rimraf lib && yarn rimraf node_modules/@types/react-native",
1919
"lint": "eslint --ext .js,.ts,.tsx src",
2020
"prepublish": "yarn build",
21-
"start": "(yarn tsc --watch & yarn babel src --out-dir lib --watch & yarn cpx \"src/**/*.{css,svg,png,jpg}\" lib --watch)",
21+
"start": "(yarn tsc --watch & yarn babel src --out-dir lib --watch & yarn cpx \"src/**/*.{css,svg,png,jpg,woff,woff2}\" lib --watch)",
2222
"start:storybook": "start-storybook",
2323
"test": "cross-env NODE_ENV=test jest",
2424
"typecheck": "tsc --noEmit"
@@ -43,7 +43,7 @@
4343
"@babel/plugin-transform-flow-strip-types": "^7.0.0",
4444
"@babel/polyfill": "^7.4.4",
4545
"@codesandbox/notifications": "^1.0.6",
46-
"@codesandbox/template-icons": "^1.0.1",
46+
"@codesandbox/template-icons": "^1.0.2",
4747
"@sentry/browser": "^5.9.0",
4848
"@tippy.js/react": "^2.1.1",
4949
"babel-plugin-preval": "^3.0.1",
@@ -62,7 +62,7 @@
6262
"react": "^16.8.6",
6363
"react-icons": "^2.2.7",
6464
"react-input-autosize": "^2.2.1",
65-
"react-router-dom": "^4.3.1",
65+
"react-router-dom": "^5.0.1",
6666
"react-spring": "^8.0.25",
6767
"react-textarea-autosize": "^6.1.0",
6868
"semver": "^5.6.0",
@@ -90,8 +90,6 @@
9090
"@types/react": "^16.8.12",
9191
"@types/react-icons": "^2.2.7",
9292
"@types/storybook__addon-actions": "^3.4.3",
93-
"@types/storybook__addon-knobs": "^5.0.3",
94-
"@types/storybook__react": "^4.0.2",
9593
"@types/styled-components": "^4.1.13",
9694
"babel-jest": "^24.8.0",
9795
"babel-loader": "^8.0.6",

packages/common/src/components/Button/index.stories.tsx renamed to packages/common/src/components/Button/Button.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import { storiesOf } from '@storybook/react';
33
import { action } from '@storybook/addon-actions';
44
import { text, boolean } from '@storybook/addon-knobs';
5-
import { Button } from '.';
5+
import { Button } from './Button';
66

77
storiesOf('components/Button', module)
88
.add('Basic button with text', () => (

packages/common/src/components/Button/index.test.tsx renamed to packages/common/src/components/Button/Button.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'jest-styled-components';
22
import React from 'react';
33
import mountWithTheme from '../../test/themeMount';
4-
import { Button } from '.';
4+
import { Button } from './Button';
55

66
describe('<Button /> rendering', () => {
77
it('no props', () => {
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import React from 'react';
2+
import { Link, ILinkProps } from '../Link';
3+
import { Base, ButtonIcon } from './elements';
4+
5+
export interface IButtonProps extends ILinkProps {
6+
Icon?: React.ReactType;
7+
href?: string;
8+
small?: boolean;
9+
block?: boolean;
10+
onClick?: (event: React.MouseEvent) => void;
11+
disabled?: boolean;
12+
type?: 'button' | 'reset' | 'submit';
13+
secondary?: boolean;
14+
red?: boolean;
15+
danger?: boolean;
16+
}
17+
18+
export const Button: React.FC<IButtonProps> = React.forwardRef<
19+
HTMLAnchorElement,
20+
IButtonProps
21+
>(({ Icon, children, ...props }, ref) => (
22+
<Base
23+
ref={ref}
24+
{...(props.to || props.href
25+
? {
26+
forwardedAs: props.to ? Link : `a`,
27+
...props,
28+
}
29+
: props)}
30+
>
31+
{Icon && (
32+
<ButtonIcon>
33+
<Icon />
34+
</ButtonIcon>
35+
)}
36+
{children}
37+
</Base>
38+
));
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`<Button /> rendering Danger Button 1`] = `ReactWrapper {}`;
4+
5+
exports[`<Button /> rendering Href Button 1`] = `ReactWrapper {}`;
6+
7+
exports[`<Button /> rendering Secondary Button 1`] = `ReactWrapper {}`;
8+
9+
exports[`<Button /> rendering Small Button 1`] = `ReactWrapper {}`;
10+
11+
exports[`<Button /> rendering block Button 1`] = `ReactWrapper {}`;
12+
13+
exports[`<Button /> rendering no props 1`] = `ReactWrapper {}`;

0 commit comments

Comments
 (0)