Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/common/input/RadioInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const RadioInput = ({
() =>
onChange?.({
target: { checked: true, value: props.value },
} as any),
} as React.ChangeEvent<HTMLInputElement>),
disabled
)
}
Expand Down
29 changes: 29 additions & 0 deletions src/components/common/label/Label.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import clsx from 'clsx'

import { Highlight } from '../text'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

절대 경로로 바꿔 주세요 !
@/components/common/text

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

변경 완료!


export interface LabelProps
extends React.LabelHTMLAttributes<HTMLLabelElement> {
required?: boolean
labelText?: string
}

export const Label = ({
required = false,
labelText,
htmlFor,
children,
className = '',
}: LabelProps): JSX.Element => {
const labelClass = clsx('flex flex-col text-body3 font-medium', className)

return (
<label htmlFor={htmlFor} className={labelClass}>
<div className='mb-4 flex items-center'>
<span className='font-medium text-gray-600'>{labelText}</span>
{required && <Highlight>*</Highlight>}
</div>
{children}
</label>
)
}
44 changes: 44 additions & 0 deletions src/stories/common/label/Label.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { Meta, StoryObj } from '@storybook/react'

import { TextInput } from '@/components/common/input/TextInput'
import { Label, LabelProps } from '@/components/common/label/Label'

const meta: Meta<typeof Label> = {
title: 'Common/Label/Label',
component: Label,
parameters: {
layout: 'centered',
},
args: {
required: false,
labelText: '라벨 제목',
},
}

export default meta

type Story = StoryObj<typeof Label>

export const Default: Story = {
args: {
labelText: '이름',
required: false,
},
render: (args: LabelProps) => (
<Label {...args}>
<TextInput placeholder='이름을 입력하세요' />
</Label>
),
}

export const RequiredLabel: Story = {
args: {
labelText: '이메일',
required: true,
},
render: (args: LabelProps) => (
<Label {...args}>
<TextInput placeholder='이메일을 입력하세요' />
</Label>
),
}