Skip to content

Commit

Permalink
refactor: 스토리북에서 DepositToggle을 클릭시 focus가 변경되도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
soi-ha committed Sep 19, 2024
1 parent 3c9a90e commit 70d1d94
Showing 1 changed file with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/** @jsxImportSource @emotion/react */
import type {Meta, StoryObj} from '@storybook/react';

import {useEffect, useState} from 'react';

import {DepositToggle} from './DepositToggle';

const meta = {
Expand All @@ -20,14 +23,29 @@ const meta = {
options: [undefined, () => alert('change toggle')],
},
},
args: {
isDeposit: false,
onToggle: () => alert('change toggle'),
},
} satisfies Meta<typeof DepositToggle>;

export default meta;

type Story = StoryObj<typeof meta>;

export const Playground: Story = {};
export const Playground: Story = {
args: {
isDeposit: false,
onToggle: () => {},
},
render: ({isDeposit, onToggle, ...args}) => {
const [isDepositState, setIsDepositState] = useState(isDeposit);

useEffect(() => {
setIsDepositState(isDeposit);
}, [isDeposit]);

const handleToggle = () => {
setIsDepositState(!isDepositState);
onToggle();
};

return <DepositToggle {...args} isDeposit={isDepositState} onToggle={handleToggle} />;
},
};

0 comments on commit 70d1d94

Please sign in to comment.