-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Radio): label 입력이 정상적으로 되지 않던 문제 수정 (#116)
* fix: Radio 컴포넌트 label이 정상적으로 작동하지 않던 문제 수정 * changeset
- Loading branch information
Showing
2 changed files
with
18 additions
and
18 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,5 @@ | ||
--- | ||
"@sopt-makers/ui": patch | ||
--- | ||
|
||
Radio label 이 정상적으로 작동하지 않던 문제 수정 |
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,34 +1,29 @@ | ||
import type { InputHTMLAttributes } from "react"; | ||
import { forwardRef } from "react"; | ||
import theme from "../theme.css"; | ||
import { controlLabel, controlWrapper, radio } from "./style.css"; | ||
import type { InputHTMLAttributes } from 'react'; | ||
import { forwardRef } from 'react'; | ||
import theme from '../theme.css'; | ||
import { controlLabel, controlWrapper, radio } from './style.css'; | ||
|
||
export interface RadioProps | ||
extends Omit<InputHTMLAttributes<HTMLInputElement>, "size"> { | ||
export interface RadioProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size'> { | ||
label?: string; | ||
size?: "sm" | "lg"; | ||
size?: 'sm' | 'lg'; | ||
checked?: boolean; | ||
color?: string; | ||
} | ||
|
||
const Radio = forwardRef<HTMLInputElement, RadioProps>( | ||
({ checked = false, label, size = "sm", color = theme.colors.gray10, ...props }, ref) => { | ||
({ checked = false, label, size = 'sm', color = theme.colors.gray10, ...props }, ref) => { | ||
return ( | ||
<label className={controlWrapper}> | ||
<input | ||
checked={checked} | ||
className={radio[size]} | ||
ref={ref} | ||
type="radio" | ||
{...props} | ||
/> | ||
<input checked={checked} className={radio[size]} ref={ref} type='radio' {...props} /> | ||
{label ? ( | ||
<p className={controlLabel[size]} style={{ color }}>label</p> | ||
<p className={controlLabel[size]} style={{ color }}> | ||
{label} | ||
</p> | ||
) : null} | ||
</label> | ||
); | ||
} | ||
}, | ||
); | ||
Radio.displayName = "Radio"; | ||
Radio.displayName = 'Radio'; | ||
|
||
export default Radio; |