-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #345 from ConsenSys/development
merge v0.9.5 release
- Loading branch information
Showing
13 changed files
with
144 additions
and
202 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 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 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 |
---|---|---|
@@ -1,26 +1,51 @@ | ||
# Select documentation | ||
|
||
Use the `Select` component when you want your users to select an option from a list. `Select` provides a styled version of the HTML `<select>`. | ||
`Select` provides a styled version of the HTML `<select>`. | ||
|
||
_Want to understand best practices for using a `Select` component?_ Read [`Select` design guidelines](https://consensys.github.io/rimble-ui/?path=/story/components-form-select--design-guidelines) | ||
## Component | ||
<!-- STORY --> | ||
|
||
## Usage | ||
|
||
**Import component** | ||
### with options array | ||
|
||
```jsx | ||
import React, { Component } from 'react'; | ||
import { Select } from 'rimble-ui'; | ||
``` | ||
|
||
<!-- STORY --> | ||
|
||
### Component props | ||
|
||
`Select` will pass any props that are defined on its component and uses the following: | ||
const options = [ | ||
{ value: 'ETH', label: 'ETH - Ether'}, | ||
{ value: 'BTC', label: 'BTC - Bitcoin'}, | ||
{ value: 'GNO', label: 'GNO - Gnosis'}, | ||
{ value: 'GNT', label: 'GNT - Golem'}, | ||
{ value: 'REP', label: 'REP - Augur'}, | ||
]; | ||
|
||
const MyComponent = () => ( | ||
<Select options={options} /> | ||
); | ||
``` | ||
|
||
| Name | Type | Default | Description | | ||
| -------- | ---- | ------- | --------------------------------------------------------------------- | | ||
| disabled | bool | true | Sets disabled property of the radio input to prevent user interaction | | ||
| required | bool | true | Ensures that a value is selected | | ||
### or with children | ||
|
||
### Styled-system props | ||
```jsx | ||
import React, { Component } from 'react'; | ||
import { Select } from 'rimble-ui'; | ||
|
||
`Select` uses all the style props from [`Box`](https://consensys.github.io/rimble-ui/?path=/story/components-layout-box--documentation). | ||
const MyComponent = () => ( | ||
<Select name="pets"> | ||
<optgroup label="4-legged pets"> | ||
<option value="dog">Dog</option> | ||
<option value="cat">Cat</option> | ||
<option value="hamster" disabled>Hamster</option> | ||
</optgroup> | ||
<optgroup label="Flying pets"> | ||
<option value="parrot">Parrot</option> | ||
<option value="macaw">Macaw</option> | ||
<option value="albatross">Albatross</option> | ||
</optgroup> | ||
</Select> | ||
); | ||
``` | ||
## Props | ||
<!-- PROPS --> |
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 |
---|---|---|
@@ -1,100 +1,21 @@ | ||
import React from 'react'; | ||
import { storiesOf } from '@storybook/react'; | ||
import { withDocs } from 'storybook-readme'; | ||
import CodeBlock from '../../components/CodeBlock'; | ||
import ContributeBanner from '../../components/ContributeBanner'; | ||
|
||
import Documentation from './docs.md'; | ||
import Guidelines from './guide.md'; | ||
|
||
import { | ||
Select, | ||
Field, | ||
Box, | ||
Heading, | ||
Text, | ||
Flex, | ||
Card, | ||
Pill, | ||
|
||
Radio, | ||
Link, | ||
} from 'rimble-ui'; | ||
import { Select } from 'rimble-ui'; | ||
|
||
const items = [ | ||
'ETH - Ether', | ||
'BTC - Bitcoin', | ||
'GNO - Gnosis', | ||
'GNT - Golem', | ||
'REP - Augur', | ||
const options = [ | ||
{ value: 'ETH', label: 'ETH - Ether'}, | ||
{ value: 'BTC', label: 'BTC - Bitcoin'}, | ||
{ value: 'GNO', label: 'GNO - Gnosis'}, | ||
{ value: 'GNT', label: 'GNT - Golem'}, | ||
{ value: 'REP', label: 'REP - Augur'}, | ||
]; | ||
|
||
storiesOf('Components/Form/Select', module) | ||
.add( | ||
'Documentation', | ||
withDocs(Documentation, () => ( | ||
<Box mx={3}> | ||
<CodeBlock> | ||
<Field label="Choose your currency"> | ||
<Select items={items} required="false" /> | ||
</Field> | ||
</CodeBlock> | ||
</Box> | ||
)) | ||
) | ||
.add( | ||
'Design guidelines', | ||
withDocs(Guidelines, () => ( | ||
<Box mx={3}> | ||
<Box> | ||
<Heading.h3>Design</Heading.h3> | ||
<Text> | ||
Some best practices for using <code>{'Select'}</code> in your | ||
product. | ||
</Text> | ||
</Box> | ||
<Box> | ||
<Heading.h4>It's better to show your options</Heading.h4> | ||
<Text> | ||
Only use the <code>{'Select'}</code> component when you have a lot | ||
of options that would clutter your interface. If you've only got a | ||
few options to choose from it might be better to show them to the | ||
user with a <code>{'Radio'}</code> component. | ||
</Text> | ||
<br /> | ||
</Box> | ||
<Flex> | ||
<Card mx={'auto'} my={3} px={4} width="400px"> | ||
<Pill mb={3} color={'green'}> | ||
{'Do'} | ||
</Pill> | ||
<br /> | ||
<br /> | ||
<Select | ||
items={[ | ||
'ETH - Ether', | ||
'BTC - Bitcoin', | ||
'GNO - Gnosis', | ||
'GNT - Golem', | ||
'REP - Augur', | ||
]} | ||
/> | ||
<br /> | ||
<br /> | ||
<Radio label="ETH - Ether" my={2} required="false" /> | ||
<Radio label="FIAT e.g. USD" my={2} required="false" /> | ||
</Card> | ||
<Card mx={'auto'} my={3} px={4} width="400px"> | ||
<Pill mb={3} color={'red'}> | ||
{"Don't"} | ||
</Pill> | ||
<br /> | ||
<br /> | ||
<Select items={['ETH - Ether', 'FIAT e.g. USD']} /> | ||
</Card> | ||
</Flex> | ||
|
||
<ContributeBanner /> | ||
</Box> | ||
)) | ||
); | ||
storiesOf('Components/', module) | ||
.addDecorator(withDocs(Documentation)) | ||
.add('Select', () => ( | ||
<Select options={options} /> | ||
)) |
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 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
Oops, something went wrong.