Skip to content

Commit

Permalink
fix(Radio): label 입력이 정상적으로 되지 않던 문제 수정 (#116)
Browse files Browse the repository at this point in the history
* fix: Radio 컴포넌트 label이 정상적으로 작동하지 않던 문제 수정

* changeset
  • Loading branch information
Brokyeom authored Aug 20, 2024
1 parent 6c948aa commit cb84727
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .changeset/smart-mugs-invent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@sopt-makers/ui": patch
---

Radio label 이 정상적으로 작동하지 않던 문제 수정
31 changes: 13 additions & 18 deletions packages/ui/Control/Radio.tsx
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;

0 comments on commit cb84727

Please sign in to comment.