-
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.
feat(SelectButtonsGroup): new components
- Loading branch information
Eszter Hofmann
committed
Jan 3, 2020
1 parent
979c682
commit ff4910f
Showing
8 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
src/components/SelectButtonGroup/SelectButton/SelectButton.tsx
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,41 @@ | ||
import * as React from 'react'; | ||
|
||
interface Props { | ||
/** the label to be displayed on this button */ | ||
children: string; | ||
/** the value associated with this button */ | ||
value: string; | ||
/** | ||
* A function to be called if a button is pressed. | ||
* This prop, if defined on the parent SelectButtonGroup will overwrite this one | ||
*/ | ||
onSelect?: (value: string) => void; | ||
/** if this button should be in a selected state */ | ||
isSelected?: boolean; | ||
/** the color context to be applied in the selected state */ | ||
selectedContext?: 'neutral' | 'brand'; | ||
/** | ||
* is this button part of a multiselect group | ||
* when yes will render as checkbox otherwise as radioButton | ||
* This prop will be overwritten by the parent <SelectButtonGroup> | ||
*/ | ||
isMultiselect?: boolean; | ||
/** | ||
* is this button has same width as its siblings | ||
* This prop will be overwritten by the parent <SelectButtonGroup> | ||
*/ | ||
isEqualWidth?: boolean; | ||
} | ||
|
||
const SelectButton: React.FC<Props> = props => <div></div>; | ||
|
||
SelectButton.displayName = 'SelectButton'; | ||
|
||
SelectButton.defaultProps = { | ||
isSelected: false, | ||
selectedContext: 'brand', | ||
isMultiselect: false, | ||
isEqualWidth: false, | ||
}; | ||
|
||
export default SelectButton; |
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 @@ | ||
export { default } from './SelectButton'; |
28 changes: 28 additions & 0 deletions
28
src/components/SelectButtonGroup/SelectButtonGroup/SelectButtonGroup.tsx
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,28 @@ | ||
import * as React from 'react'; | ||
|
||
interface Props { | ||
/** SelectButton components */ | ||
children: NotEmptyReactNode; | ||
/** | ||
* A function to be called if a button is pressed. | ||
* This prop, if defined will overwrite the onSelect on children | ||
*/ | ||
onSelect?: (value: string) => void; | ||
/** is this button part of a multiselect group - when yes will render as checkbox otherwise as radioButton */ | ||
isMultiselect?: boolean; | ||
/** should the component take up all the width available */ | ||
isBlock?: boolean; | ||
/** should children have equal width */ | ||
isEqualWidth?: boolean; | ||
} | ||
|
||
const SelectButtonGroup: React.FC<Props> = props => <div></div>; | ||
|
||
SelectButtonGroup.displayName = 'SelectButtonGroup'; | ||
|
||
SelectButtonGroup.defaultProps = { | ||
isMultiselect: false, | ||
isBlock: false, | ||
}; | ||
|
||
export default SelectButtonGroup; |
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 @@ | ||
export { default } from './SelectButtonGroup'; |
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,2 @@ | ||
export { default as SelectButton } from './SelectButton'; | ||
export { default as SelectButtonGroup } from './SelectButtonGroup'; |
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,41 @@ | ||
import * as React from 'react'; | ||
import { storiesOf } from '@storybook/react'; | ||
import { text, boolean, select, withKnobs } from '@storybook/addon-knobs'; | ||
import { SelectButtonGroup, SelectButton } from '@textkernel/oneui'; | ||
|
||
storiesOf('Atoms|SelectButtonGroup', module) | ||
.addDecorator(withKnobs) | ||
.add('SelectButtonGroup', () => ( | ||
<SelectButtonGroup | ||
isMultiselect={boolean('Multiselect group', false)} | ||
isBlock={boolean('Display as block', false)} | ||
isEqualWidth={boolean('Make all buttons the same width', false)} | ||
onSelect={value => { | ||
const msg = `onSelect was called with value ${value}`; | ||
console.log(msg); | ||
}} | ||
> | ||
<SelectButton | ||
value="button 1" | ||
isSelected={boolean('Button 1 is selected', true)} | ||
selectedContext={select( | ||
'Selected color context for button 1', | ||
['brand', 'neutral'], | ||
'brand' | ||
)} | ||
> | ||
{text('Option label 1', 'Option 1')} | ||
</SelectButton> | ||
<SelectButton | ||
value="button 2" | ||
isSelected={boolean('Button 2 is selected', false)} | ||
selectedContext={select( | ||
'Selected color context for button 2', | ||
['brand', 'neutral'], | ||
'brand' | ||
)} | ||
> | ||
{text('Option label 2', 'Option 2')} | ||
</SelectButton> | ||
</SelectButtonGroup> | ||
)); |
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