-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aa8f5c6
commit 2c8ffec
Showing
7 changed files
with
118 additions
and
100 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
import { InputHTMLAttributes } from 'react'; | ||
import { InputHTMLAttributes, forwardRef } from 'react'; | ||
import cx from 'clsx'; | ||
import styles from './radio.module.css'; | ||
|
||
interface Props extends InputHTMLAttributes<HTMLInputElement> { | ||
type Props = InputHTMLAttributes<HTMLInputElement> & { | ||
label: string; | ||
} | ||
}; | ||
|
||
function Radio({ label, className, ...attrs }: Props) { | ||
const Radio = forwardRef<HTMLInputElement, Props>(({ label, className, ...attrs }, ref) => { | ||
const { disabled } = attrs; | ||
|
||
return ( | ||
<label className={cx(styles.label, className, disabled && styles.disabled)}> | ||
<input type="radio" className={styles.input} {...attrs} /> | ||
<input type="radio" className={styles.input} ref={ref} {...attrs} /> | ||
|
||
{label} | ||
</label> | ||
); | ||
} | ||
}); | ||
|
||
export { Radio }; | ||
export type { Props as RadioProps }; |
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