Skip to content

Commit

Permalink
test: Modal storybook 제작 #41
Browse files Browse the repository at this point in the history
  • Loading branch information
bottlewook committed Jan 6, 2024
1 parent 7336f0a commit 0aa0fb3
Show file tree
Hide file tree
Showing 4 changed files with 232 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"jsdom": "^23.0.1",
"sass": "^1.69.6",
"storybook": "^7.6.6",
"storybook-react-context": "^0.6.0",
"stylelint": "^16.1.0",
"stylelint-config-property-sort-order-smacss": "^10.0.0",
"stylelint-config-standard-scss": "^12.0.0",
Expand Down
47 changes: 47 additions & 0 deletions src/components/shared/Modal/Modal.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import type { Meta, StoryObj } from '@storybook/react';

// eslint-disable-next-line import/no-extraneous-dependencies
import { withReactContext } from 'storybook-react-context';

import { ModalContext } from '@contexts/ModalContext';

import Modal from './Modal';

const meta = {
title: 'Shared/Modal',
decorators: [
withReactContext({
Context: ModalContext,
initialState: {
open: true,
title: '탈퇴하시겠습니까?',
description: '회원을 탈퇴하면 차량용품 추천 서비스를 제공받을 수 없습니다. 정말로 탈퇴하시겠습니까?',
topButtonLabel: '예',
bottomButtonLabel: '아니오',
onTopButtonClick: () => { },
onBottomButtonClick: () => { },
},
}),
],
component: Modal,
parameters: {
},
tags: ['autodocs'],
argTypes: {
},
} satisfies Meta<typeof Modal>;

export default meta;
type Story = StoryObj<typeof meta>;

export const normal: Story = {
args: {
open: true,
title: '탈퇴하시겠습니까?',
description: '회원을 탈퇴하면 차량용품 추천 서비스를 제공받을 수 없습니다. 정말로 탈퇴하시겠습니까?',
topButtonLabel: '예',
bottomButtonLabel: '아니오',
onTopButtonClick: () => { },
onBottomButtonClick: () => { },
},
};
2 changes: 1 addition & 1 deletion src/contexts/ModalContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const defaultValues: ModalProps = {
onBottomButtonClick: () => { },
};

const ModalContext = createContext<ModalContextValue | undefined>(undefined);
export const ModalContext = createContext<ModalContextValue | undefined>(undefined);

export function ModalContextProvider({ children }: { children: React.ReactNode }) {
const [modalState, setModalState] = useState(defaultValues);
Expand Down
Loading

0 comments on commit 0aa0fb3

Please sign in to comment.