-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add attendanceModal to storybook
- Loading branch information
Showing
2 changed files
with
80 additions
and
101 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
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,33 +1,26 @@ | ||
import { Meta, StoryObj } from "@storybook/react"; | ||
import { useState } from "react"; | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import AttendanceModal from "../../design/attendance/AttendanceModal"; | ||
|
||
// Meta 타입에 typeof를 사용하여 컴포넌트 타입을 정확히 지정합니다. | ||
const meta: Meta<typeof AttendanceModal> = { | ||
const meta = { | ||
title: "DESIGNS/AttendanceModal", | ||
component: AttendanceModal, | ||
parameters: {}, | ||
tags: ["autodocs"], | ||
}; | ||
argTypes: {}, | ||
args: {}, | ||
} satisfies Meta<typeof AttendanceModal>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
// StoryObj를 사용할 때는 컴포넌트의 Props 타입을 정확하게 매핑합니다. | ||
type AttendanceModalProps = { | ||
isExist?: boolean; | ||
setIsModal: (exist: boolean) => void; | ||
}; | ||
|
||
export const Primary: StoryObj<typeof AttendanceModal> = { | ||
render: (args) => { | ||
const [isExist, setIsExist] = useState(args.isExist ?? false); // args.isExist가 undefined일 경우 false를 기본값으로 사용 | ||
|
||
// isExist 상태를 토글하는 함수 | ||
const setIsModal = () => setIsExist(!isExist); | ||
|
||
return <div />; | ||
export const Primary: Story = { | ||
args: { | ||
type: 1, | ||
}, | ||
}; | ||
export const Secondary: Story = { | ||
args: { | ||
isExist: false, | ||
type: 2, | ||
}, | ||
}; |