-
Notifications
You must be signed in to change notification settings - Fork 71
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 #56 from edx/radio-button
Implement Radio Button Group
- Loading branch information
Showing
6 changed files
with
550 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* eslint-disable import/no-extraneous-dependencies, no-console */ | ||
import React from 'react'; | ||
import { storiesOf } from '@storybook/react'; | ||
import { action } from '@storybook/addon-actions'; | ||
import { setConsoleOptions } from '@storybook/addon-console'; | ||
|
||
import RadioButtonGroup, { RadioButton } from './index'; | ||
|
||
setConsoleOptions({ | ||
panelExclude: ['warn', 'error'], | ||
}); | ||
|
||
const onChange = (event) => { | ||
console.log(`onChange fired for ${event.target.value}`); | ||
|
||
const selectedIndex = parseInt(event.target.getAttribute('data-index'), 10); | ||
console.log(`Selected index should be ${selectedIndex}`); | ||
|
||
action('Radio Button Change'); | ||
}; | ||
|
||
const onClick = (event) => { | ||
console.log(`onClick fired for ${event.target.value}`); | ||
|
||
action('Radio Button Click'); | ||
}; | ||
|
||
const onFocus = (event) => { | ||
console.log(`onFocus fired for ${event.target.value}`); | ||
|
||
action('Radio Button Focus'); | ||
}; | ||
|
||
const onKeyDown = (event) => { | ||
console.log(`onKeyDown fired for ${event.target.value} with key value: ${event.key}`); | ||
|
||
action('Radio Button Key Press'); | ||
}; | ||
|
||
storiesOf('RadioButtonGroup', module) | ||
.add('unselected minimal usage', () => ( | ||
<RadioButtonGroup | ||
name={'rbg'} | ||
label={'Radio Button Group'} | ||
onBlur={action('Radio Button Blur')} | ||
onChange={onChange} | ||
onClick={onClick} | ||
onFocus={onFocus} | ||
onKeyDown={onKeyDown} | ||
> | ||
<RadioButton value={'jaebaebae'}>First Value</RadioButton> | ||
<RadioButton value={'value2'}>Second Value</RadioButton> | ||
<RadioButton value={'value3'}>Third Value</RadioButton> | ||
</RadioButtonGroup> | ||
)) | ||
.add('selected minimal usage', () => ( | ||
<RadioButtonGroup | ||
name={'rbg'} | ||
label={'Radio Button Group'} | ||
onBlur={action('Radio Button Blur')} | ||
onChange={onChange} | ||
onClick={onClick} | ||
onFocus={onFocus} | ||
onKeyDown={onKeyDown} | ||
selectedIndex={1} | ||
> | ||
<RadioButton value={'jaebaebae'}>First Value</RadioButton> | ||
<RadioButton value={'value2'}>Second Value</RadioButton> | ||
<RadioButton value={'value3'}>Third Value</RadioButton> | ||
</RadioButtonGroup> | ||
)); |
Oops, something went wrong.