diff --git a/apps/docs/src/stories/Callout.stories.tsx b/apps/docs/src/stories/Callout.stories.tsx index ebf6546f..8573765f 100644 --- a/apps/docs/src/stories/Callout.stories.tsx +++ b/apps/docs/src/stories/Callout.stories.tsx @@ -1,73 +1,146 @@ -import { Callout } from "@sopt-makers/ui"; -import { Meta, StoryObj } from "@storybook/react"; +import { Callout } from '@sopt-makers/ui'; +import { Meta, StoryObj } from '@storybook/react'; +import type React from 'react'; -interface CalloutProps { - children: React.ReactNode; - type: "danger" | "information" | "warning"; - hasIcon?: boolean; - buttonLabel?: string; - isButtonDisabled?: boolean; - onClick?: () => void; -} +type CalloutProps = React.ComponentProps; export default { - title: "Components/Callout", + title: 'Components/Callout', component: Callout, - tags: ["autodocs"], + tags: ['autodocs'], argTypes: { - type: { control: 'radio', options: ['danger', 'information', 'warning'] }, - } + children: { + description: '콜아웃의 내용을 작성합니다.', + control: 'text', + table: { + type: { summary: 'ReactNode' }, + }, + }, + type: { + description: '콜아웃의 타입을 지정합니다. 타입에 따라 색상과 아이콘이 변경됩니다.', + control: 'radio', + options: ['danger', 'information', 'warning'], + table: { + type: { summary: 'danger | information | warning' }, + }, + }, + hasIcon: { + description: '아이콘 표시 여부를 지정합니다. buttonLabel이 있으면 이 옵션과 무관하게 아이콘이 항상 표시됩니다.', + control: 'boolean', + table: { + type: { summary: 'boolean' }, + defaultValue: { summary: 'true' }, + }, + }, + buttonLabel: { + description: '버튼의 텍스트를 지정합니다. 지정하면 버튼이 표시됩니다.', + control: 'text', + table: { + type: { summary: 'string' }, + }, + }, + isButtonDisabled: { + description: '버튼의 비활성화 상태를 지정합니다.', + control: 'boolean', + table: { + type: { summary: 'boolean' }, + defaultValue: { summary: 'false' }, + }, + }, + onClick: { + description: '버튼 클릭 시 실행할 함수를 지정합니다.', + action: 'clicked', + table: { + type: { summary: '() => void' }, + }, + }, + }, } as Meta; +const content = ( + <> + hasIcon 옵션으로 통해 아이콘을 표시할 수 있으며
+ buttonLabel과 onClick 옵션을 통해 버튼의 text와 클릭 핸들러를 설정할 수 있어요 + +); // danger 콜아웃 스토리 export const Danger: StoryObj = { args: { - children: "hasIcon 옵션으로 통해 아이콘을 표시할 수 있어요", - type: "danger", + children: content, + type: 'danger', hasIcon: false, }, }; // information 콜아웃 스토리 export const Information: StoryObj = { args: { - children: "hasIcon 옵션으로 통해 아이콘을 표시할 수 있어요", - type: "information", + children: 'hasIcon 옵션으로 통해 아이콘을 표시할 수 있으며 ', + type: 'information', hasIcon: false, }, }; // warning 콜아웃 스토리 export const Warning: StoryObj = { args: { - children: "hasIcon 옵션으로 통해 아이콘을 표시할 수 있어요", - type: "warning", + children: 'buttonLabel과 onClick 옵션을 통해 버튼의 text와 클릭 핸들러를 설정할 수 있어요', + type: 'warning', hasIcon: false, }, }; +// danger+icon 콜아웃 스토리 +export const MultipleIconCallouts: StoryObj = { + render: () => ( +
+ + + +
+ ), +}; -// warning+icon+button 콜아웃 스토리 -export const CalloutWithBtn: StoryObj = { +export const MultipleButtonCallouts: StoryObj = { + render: () => ( +
+ + <> + 버튼이 있는 경우 hasIcon과 무관하게 아이콘이 항상 표시돼요.
+ isButtonDisabled 옵션으로 disabled state를 확인해보세요. + +
+ + <> + 버튼이 있는 경우 hasIcon과 무관하게 아이콘이 항상 표시돼요.
+ isButtonDisabled 옵션으로 disabled state를 확인해보세요. + +
+ + <> + 버튼이 있는 경우 hasIcon과 무관하게 아이콘이 항상 표시돼요.
+ isButtonDisabled 옵션으로 disabled state를 확인해보세요. + +
+
+ ), +}; + +// 여러줄 텍스트 콜아웃 스토리 +export const CalloutWithLongText: StoryObj = { args: { - children: ( - <> - 버튼이 있는 경우 hasIcon과 무관하게 아이콘이 항상 표시돼요.
- isButtonDisabled 옵션으로 disabled state를 확인해보세요. - - ), - type: "warning", + children: + 'Facebook 정책이 변경되어, 앞으로 Facebook 로그인이 불가해요. 다른 계정으로 재설정 부탁드려요. Facebook 정책이 변경되어, 앞으로 Facebook 로그인이 불가해요. 다른 계정으로 재설정 부탁드려요.', + type: 'information', hasIcon: true, - buttonLabel: "hover, press 해보세요!", + buttonLabel: '소셜 계정 재설정하기', isButtonDisabled: false, }, }; -// 여러줄 텍스트 콜아웃 스토리 -export const CalloutWithLongText: StoryObj = { +export const CalloutWithShortText: StoryObj = { args: { - children: - "Facebook 정책이 변경되어, 앞으로 Facebook 로그인이 불가해요. 다른 계정으로 재설정 부탁드려요. Facebook 정책이 변경되어, 앞으로 Facebook 로그인이 불가해요. 다른 계정으로 재설정 부탁드려요.", - type: "information", + children: '짧은 텍스트 ', + type: 'information', hasIcon: true, - buttonLabel: "소셜 계정 재설정하기", + buttonLabel: '짧은 라벨', isButtonDisabled: false, }, }; diff --git a/packages/ui/Callout/Callout.tsx b/packages/ui/Callout/Callout.tsx index fc75d7de..febda00b 100644 --- a/packages/ui/Callout/Callout.tsx +++ b/packages/ui/Callout/Callout.tsx @@ -1,18 +1,7 @@ -import { - IconAlertCircle, - IconChevronRight, - IconInfoCircle, -} from "@sopt-makers/icons"; -import type { ReactNode } from "react"; -import { - buttonIcon, - button, - calloutVariant, - container, - iconVariant, - text, -} from "./style.css"; -import type { CalloutType } from "./types"; +import { IconAlertCircle, IconChevronRight, IconInfoCircle } from '@sopt-makers/icons'; +import type { ReactNode } from 'react'; +import { buttonIcon, button, calloutVariant, container, iconVariant, text } from './style.css'; +import type { CalloutType } from './types'; const icons = { danger: IconAlertCircle, @@ -29,24 +18,18 @@ interface CalloutProps { } function Callout(props: CalloutProps) { - const { children, type, hasIcon, buttonLabel, isButtonDisabled, onClick } = - props; + const { children, type, hasIcon = true, buttonLabel, isButtonDisabled, onClick } = props; const Icon = icons[type]; return (