diff --git a/src/components/common/index.tsx b/src/components/common/index.tsx index ce1c9c47..ca16f489 100644 --- a/src/components/common/index.tsx +++ b/src/components/common/index.tsx @@ -1,4 +1,5 @@ // eslint-disable-next-line react-refresh/only-export-components export * from './selectweek/SelectWeek' +export * from './listRow/ListRow' export * from './label/Label' export * from './icon/Icon' diff --git a/src/components/common/listRow/ListRow.stories.tsx b/src/components/common/listRow/ListRow.stories.tsx new file mode 100644 index 00000000..4855a0d9 --- /dev/null +++ b/src/components/common/listRow/ListRow.stories.tsx @@ -0,0 +1,53 @@ +import type { Meta, StoryObj } from '@storybook/react' +import ListRow from '@/components/common/listRow/ListRow' + +const meta: Meta = { + component: ListRow, + tags: ['autodocs'], + title: 'components/ListRow', + argTypes: { + hasBorder: { + control: 'boolean' + }, + rightElement: { + control: 'text' + }, + leftElement: { + control: 'text', + required: true + }, + paddingSize: { + control: 'select', + options: ['small', 'medium', 'large'] + } + }, + render: ({ ...args }) => ( + {args.rightElement}} + leftElement={
{args.leftElement}
} + paddingSize={args.paddingSize} + hasBorder={args.hasBorder} + /> + ) +} + +export default meta +type Story = StoryObj + +export const Default: Story = { + args: { + rightElement:
{'학원명'}
, + leftElement:
{'샤론음악학원'}
, + paddingSize: 'medium', + hasBorder: false + } +} + +export const ListRowBorder: Story = { + args: { + rightElement:
{'학원명'}
, + leftElement:
{'샤론음악학원'}
, + paddingSize: 'medium', + hasBorder: true + } +} diff --git a/src/components/common/listRow/ListRow.tsx b/src/components/common/listRow/ListRow.tsx new file mode 100644 index 00000000..f139e7d9 --- /dev/null +++ b/src/components/common/listRow/ListRow.tsx @@ -0,0 +1,31 @@ +/* eslint-disable prettier/prettier */ +import { ComponentProps, ReactNode } from 'react' +import { PaddingSizeType, PaddingVariant } from './ListRowType' + +/** + * @param leftElement 왼쪽 요소 (필수) ReactNode로 작성해야 함. + * @param rightElement 오른쪽 요소 ReactNode로 작성해야 함 + * @param paddingSize 'small [10px] | medium [20px] | large [30px] 가로 사이즈만 조절됨' + * @param hasBorder 'bottom-border 의 존재 여부 설정' + * */ + +interface ListRowProps extends ComponentProps<'div'> { + rightElement: ReactNode + leftElement?: ReactNode + paddingSize?: PaddingSizeType + hasBorder?: boolean +} + +const ListRow = ({ leftElement, rightElement, hasBorder = true, paddingSize = 'medium' }: ListRowProps) => { + return ( +
+ {leftElement} + {rightElement} +
+ ) +} + +export default ListRow diff --git a/src/components/common/listRow/ListRowType.ts b/src/components/common/listRow/ListRowType.ts new file mode 100644 index 00000000..2693f79a --- /dev/null +++ b/src/components/common/listRow/ListRowType.ts @@ -0,0 +1,6 @@ +export type PaddingSizeType = 'small' | 'medium' | 'large' +export const PaddingVariant = { + small: 'px-[10px]', + medium: 'px-[20px]', + large: 'px-[30px]' +}