This repository has been archived by the owner on Nov 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(toggle-group): split into composable components (#388)
BREAKING CHANGE: Renames ToggleGroup to FieldSet to match intended usage.
- Loading branch information
1 parent
eb104f5
commit e4beb91
Showing
12 changed files
with
139 additions
and
239 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from 'react' | ||
import propTypes from 'prop-types' | ||
|
||
const FieldSet = ({ className, children }) => ( | ||
<fieldset className={className}> | ||
{children} | ||
<style jsx>{` | ||
fieldset { | ||
border: none; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
`}</style> | ||
</fieldset> | ||
) | ||
|
||
FieldSet.propTypes = { | ||
className: propTypes.string, | ||
children: propTypes.node.isRequired, | ||
} | ||
|
||
export { FieldSet } |
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,29 @@ | ||
import React from 'react' | ||
import propTypes from 'prop-types' | ||
import cx from 'classnames' | ||
import { theme, spacers } from '../theme.js' | ||
|
||
const Legend = ({ className, children, required }) => ( | ||
<legend className={cx(className, { required })}> | ||
{children} | ||
<style jsx>{` | ||
legend { | ||
font-size: 16px; | ||
color: ${theme.default}; | ||
margin: ${spacers.dp12} 0 ${spacers.dp12}; | ||
} | ||
legend.required::after { | ||
padding-left: ${spacers.dp4}; | ||
content: '*'; | ||
} | ||
`}</style> | ||
</legend> | ||
) | ||
|
||
Legend.propTypes = { | ||
className: propTypes.string, | ||
children: propTypes.node.isRequired, | ||
required: propTypes.bool, | ||
} | ||
|
||
export { Legend } |
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
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,57 @@ | ||
import React from 'react' | ||
import { storiesOf } from '@storybook/react' | ||
import { FieldSet, FormControl, Radio, Help, Legend } from '../src' | ||
|
||
import markdown from './info/atoms/fieldSet.md' | ||
|
||
const onChange = () => { | ||
console.log('Radio was clicked, nothing else will happen') | ||
} | ||
|
||
storiesOf('FieldSet', module) | ||
.addParameters({ | ||
notes: { | ||
markdown, | ||
}, | ||
}) | ||
.add('Default', () => ( | ||
<FieldSet> | ||
It renders something in a fieldset element without the browser | ||
styles | ||
</FieldSet> | ||
)) | ||
.add('Usage example - a radio button group with error status', () => ( | ||
<FieldSet> | ||
<Legend required>Choose an option</Legend> | ||
<FormControl> | ||
<Radio | ||
onChange={onChange} | ||
name="radio" | ||
value="first" | ||
label="First" | ||
error | ||
/> | ||
</FormControl> | ||
<FormControl> | ||
<Radio | ||
onChange={onChange} | ||
name="radio" | ||
value="second" | ||
label="Second" | ||
error | ||
/> | ||
</FormControl> | ||
<FormControl> | ||
<Radio | ||
onChange={onChange} | ||
name="radio" | ||
value="third" | ||
label="Third" | ||
error | ||
/> | ||
</FormControl> | ||
<Help error indent={false}> | ||
You really have to choose something! | ||
</Help> | ||
</FieldSet> | ||
)) |
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,20 @@ | ||
import React from 'react' | ||
import { storiesOf } from '@storybook/react' | ||
import { Legend } from '../src' | ||
|
||
import markdown from './info/atoms/legend.md' | ||
|
||
storiesOf('Legend', module) | ||
.addParameters({ | ||
notes: { | ||
markdown, | ||
}, | ||
}) | ||
.add('Default', () => ( | ||
<Legend>I am wrapped in a legend which has some styling</Legend> | ||
)) | ||
.add('Required', () => ( | ||
<Legend required> | ||
I am wrapped in a legend which has some styling | ||
</Legend> | ||
)) |
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
Oops, something went wrong.