-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(complib) Add dev server for component docs
- Loading branch information
Showing
12 changed files
with
1,075 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// @flow | ||
import * as React from 'react' | ||
|
||
export type ButtonProps = { | ||
/** click handler */ | ||
onClick: (event: SyntheticEvent<>) => void, | ||
/** title attribute */ | ||
title?: string, | ||
/** disabled attribute (setting disabled removes onClick) */ | ||
disabled?: bool, | ||
/** classes to apply */ | ||
className?: string, | ||
/** contents of the button */ | ||
children?: React.Node | ||
} | ||
|
||
/** | ||
* Basic, unstyled button. You probably want to use a styled button | ||
* instead. All buttons take the same props. | ||
* | ||
* If you need access to the ButtonProps type, you can: | ||
* ```js | ||
* import {type ButtonProps} from '@opentrons/components' | ||
* ``` | ||
*/ | ||
export default function Button (props: ButtonProps) { | ||
const {disabled} = props | ||
const onClick = !disabled && props.onClick | ||
|
||
return ( | ||
<button | ||
disabled={disabled} | ||
onClick={onClick} | ||
title={props.title} | ||
className={props.className} | ||
> | ||
{props.children} | ||
</button> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// @flow | ||
import * as React from 'react' | ||
import classnames from 'classnames' | ||
|
||
import Button, {type ButtonProps} from './Button' | ||
import styles from './buttons.css' | ||
|
||
/** | ||
* Primary application button. Fills its container and has a dark | ||
* background with white text | ||
*/ | ||
export default function PrimaryButton (props: ButtonProps) { | ||
const className = classnames(styles.button_primary, props.className) | ||
|
||
return ( | ||
<Button {...props} className={className}> | ||
{props.children} | ||
</Button> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Basic usage: | ||
|
||
```js | ||
<div style={{width: '16rem'}}> | ||
<PrimaryButton onClick={() => alert('you clicked me')}> | ||
{'Click for alert'} | ||
</PrimaryButton> | ||
</div> | ||
``` | ||
|
||
Disabled: | ||
|
||
```js | ||
<div style={{width: '16rem'}}> | ||
<PrimaryButton onClick={() => alert("can't click me")} disabled> | ||
{"Can't click"} | ||
</PrimaryButton> | ||
</div> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
.button { | ||
padding: 0.5rem 1.5rem; | ||
border: none; | ||
text-transform: uppercase; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// @flow | ||
// button components | ||
|
||
import Button from './Button' | ||
import PrimaryButton from './PrimaryButton' | ||
|
||
export * from './Button' | ||
export {Button, PrimaryButton} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
All available icons: | ||
|
||
```js | ||
// import {ALERT, BACK, REFRESH, etc.} from @opentrons/components | ||
const { | ||
ALERT, BACK, REFRESH, SPINNER, USB, WIFI, FLASK, CHECKED, UNCHECKED, EXPAND | ||
} = require('./icon-data') | ||
|
||
;<div> | ||
<Icon width='64px' name={ALERT} /> | ||
<Icon width='64px' name={BACK} /> | ||
<Icon width='64px' name={REFRESH} /> | ||
<Icon width='64px' name={SPINNER} /> | ||
<Icon width='64px' name={USB} /> | ||
<Icon width='64px' name={WIFI} /> | ||
<Icon width='64px' name={FLASK} /> | ||
<Icon width='64px' name={CHECKED} /> | ||
<Icon width='64px' name={UNCHECKED} /> | ||
<Icon width='64px' name={EXPAND} /> | ||
</div> | ||
``` | ||
|
||
Spin any icon! | ||
|
||
```js | ||
// import {REFRESH, SPINNER} from @opentrons/components | ||
const {REFRESH, SPINNER} = require('./icon-data') | ||
|
||
;<div> | ||
<Icon width='64px' name={SPINNER} spin /> | ||
<Icon width='64px' name={REFRESH} spin /> | ||
</div> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use strict' | ||
|
||
const path = require('path') | ||
|
||
// TODO(mc, 2017-12-22): Create common webpack config | ||
const {babel, localCss} = require('../app/webpack/rules') | ||
|
||
module.exports = { | ||
webpackConfig: { | ||
module: { | ||
rules: [babel, localCss] | ||
} | ||
}, | ||
showUsage: true, | ||
showCode: true, | ||
// TODO(mc, 2017-12-22): generate these sections automatically by walking src | ||
sections: [ | ||
{ | ||
name: 'Buttons', | ||
components: 'src/buttons/[A-Z]*.js' | ||
}, | ||
{ | ||
name: 'Icons', | ||
components: 'src/icons/[A-Z]*.js' | ||
} | ||
], | ||
getComponentPathLine (componentPath) { | ||
const name = path.basename(componentPath, '.js') | ||
|
||
return `import {${name}} from '@opentrons/components'` | ||
} | ||
} |
Oops, something went wrong.