-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Selection button props split between container and input elements (
#207)
- Loading branch information
Showing
3 changed files
with
160 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,66 @@ | ||
import PropTypes from 'prop-types'; | ||
import React, { forwardRef } from 'react'; | ||
|
||
import { Box } from '../Box'; | ||
import { Label } from '../Label'; | ||
|
||
export const RadioButton = forwardRef(function RadioButton({ | ||
className, | ||
hidden, | ||
invisible, | ||
style, | ||
autoComplete, | ||
checked, | ||
defaultChecked, | ||
disabled, | ||
form, | ||
id, | ||
name, | ||
required, | ||
tabIndex, | ||
value, | ||
qa, | ||
'data-qa': dataQa, | ||
onChange, | ||
onInput, | ||
onInvalid, | ||
...props | ||
}, ref) { | ||
return <Box is={Label} componentClassName='rcx-radio-button' className={className} hidden={hidden} invisible={invisible} style={style}> | ||
<Box is='input' componentClassName='rcx-radio-button__input' ref={ref} type='radio' {...props} /> | ||
return <Box is={Label} componentClassName='rcx-radio-button' {...props}> | ||
<Box | ||
is='input' | ||
componentClassName='rcx-radio-button__input' | ||
autoComplete={autoComplete} | ||
checked={checked} | ||
defaultChecked={defaultChecked} | ||
disabled={disabled} | ||
form={form} | ||
id={id} | ||
name={name} | ||
required={required} | ||
tabIndex={tabIndex} | ||
type='radio' | ||
value={value} | ||
data-qa={dataQa || qa} | ||
ref={ref} | ||
onChange={onChange} | ||
onInput={onInput} | ||
onInvalid={onInvalid} | ||
/> | ||
<Box is='i' componentClassName='rcx-radio-button__fake' aria-hidden='true' /> | ||
</Box>; | ||
}); | ||
|
||
RadioButton.propTypes = { | ||
autoComplete: PropTypes.string, | ||
checked: PropTypes.bool, | ||
defaultChecked: PropTypes.bool, | ||
disabled: PropTypes.bool, | ||
form: PropTypes.string, | ||
id: PropTypes.string, | ||
name: PropTypes.string, | ||
required: PropTypes.bool, | ||
tabIndex: PropTypes.number, | ||
value: PropTypes.string, | ||
qa: PropTypes.string, | ||
'data-qa': PropTypes.string, | ||
onChange: PropTypes.func, | ||
onInput: PropTypes.func, | ||
onInvalid: PropTypes.func, | ||
}; |
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,18 +1,66 @@ | ||
import PropTypes from 'prop-types'; | ||
import React, { forwardRef } from 'react'; | ||
|
||
import { Label } from '../Label'; | ||
import { Box } from '../Box'; | ||
|
||
export const ToggleSwitch = forwardRef(function ToggleSwitch({ | ||
className, | ||
hidden, | ||
invisible, | ||
style, | ||
onClick, | ||
autoComplete, | ||
checked, | ||
defaultChecked, | ||
disabled, | ||
form, | ||
id, | ||
name, | ||
required, | ||
tabIndex, | ||
value, | ||
qa, | ||
'data-qa': dataQa, | ||
onChange, | ||
onInput, | ||
onInvalid, | ||
...props | ||
}, ref) { | ||
return <Box is={Label} componentClassName='rcx-toggle-switch' className={className} hidden={hidden} invisible={invisible} style={style} onClick={onClick}> | ||
<Box is='input' componentClassName='rcx-toggle-switch__input' ref={ref} type='checkbox' {...props} /> | ||
return <Box is={Label} componentClassName='rcx-toggle-switch' {...props}> | ||
<Box | ||
is='input' | ||
componentClassName='rcx-toggle-switch__input' | ||
autoComplete={autoComplete} | ||
checked={checked} | ||
defaultChecked={defaultChecked} | ||
disabled={disabled} | ||
form={form} | ||
id={id} | ||
name={name} | ||
required={required} | ||
tabIndex={tabIndex} | ||
type='checkbox' | ||
value={value} | ||
data-qa={dataQa || qa} | ||
ref={ref} | ||
onChange={onChange} | ||
onInput={onInput} | ||
onInvalid={onInvalid} | ||
/> | ||
<Box is='i' componentClassName='rcx-toggle-switch__fake' aria-hidden='true' /> | ||
</Box>; | ||
}); | ||
|
||
ToggleSwitch.propTypes = { | ||
autoComplete: PropTypes.string, | ||
checked: PropTypes.bool, | ||
defaultChecked: PropTypes.bool, | ||
disabled: PropTypes.bool, | ||
form: PropTypes.string, | ||
id: PropTypes.string, | ||
name: PropTypes.string, | ||
required: PropTypes.bool, | ||
tabIndex: PropTypes.number, | ||
value: PropTypes.string, | ||
qa: PropTypes.string, | ||
'data-qa': PropTypes.string, | ||
onChange: PropTypes.func, | ||
onInput: PropTypes.func, | ||
onInvalid: PropTypes.func, | ||
}; |