-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: adjust name of the toggle button
- Loading branch information
Showing
9 changed files
with
59 additions
and
74 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { ToggleButton } from "./ToggleButton"; | ||
import { action } from "@storybook/addon-actions"; | ||
|
||
export type Story = StoryObj<typeof ToggleButton>; | ||
|
||
const meta: Meta<typeof ToggleButton> = { | ||
title: "Components/ToggleButton", | ||
component: ToggleButton, | ||
argTypes: { | ||
isSaved: { control: "boolean" }, | ||
onToggle: { action: "mode changed" }, | ||
}, | ||
} satisfies Meta<typeof ToggleButton>; | ||
|
||
export default meta; | ||
|
||
export const PlusButton: Story = { | ||
args: { | ||
isSaved: true, | ||
onToggle: action("mode changed"), | ||
}, | ||
}; | ||
|
||
export const MinusButton: Story = { | ||
args: { | ||
isSaved: false, | ||
onToggle: action("mode changed"), | ||
}, | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { render } from '@testing-library/react'; | ||
import { ToggleButton } from './ToggleButton'; | ||
|
||
test('renders Togglebutton', () => { | ||
const { getByTestId } = render(<ToggleButton isSaved={true} onToggle={() => (true)} />); | ||
const element = getByTestId("toggleButton"); | ||
expect(element).toBeInTheDocument(); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { CircleMinus, CirclePlus } from "lucide-react"; | ||
|
||
type ToggleButtonProps = { | ||
isSaved: boolean; | ||
onToggle: (isSaved: boolean) => void; | ||
}; | ||
|
||
export const ToggleButton = ({ isSaved, onToggle }: ToggleButtonProps) => { | ||
return ( | ||
<div data-testid="toggleButton" onClick={() => onToggle(!isSaved)}> | ||
{isSaved ? ( <CircleMinus color="#ffffff" /> ) : ( <CirclePlus color="#ffffff" /> )} | ||
</div> | ||
); | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { ToggleButton } from "./ToggleButton" | ||
|
||
export { ToggleButton } |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export type ToggleButtonProps = { | ||
isSaved: boolean; | ||
onToggle: (isSaved: boolean) => void; | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.