Skip to content

Commit

Permalink
fix: adjust name of the toggle button
Browse files Browse the repository at this point in the history
  • Loading branch information
jv-farias committed Jul 17, 2024
1 parent 4456e53 commit 02f2e01
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 74 deletions.
30 changes: 30 additions & 0 deletions src/components/ToggleButton/ToggleButton.stories.tsx
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"),
},
};
8 changes: 8 additions & 0 deletions src/components/ToggleButton/ToggleButton.test.tsx
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();
});
14 changes: 14 additions & 0 deletions src/components/ToggleButton/ToggleButton.tsx
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>
);
};
3 changes: 3 additions & 0 deletions src/components/ToggleButton/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { ToggleButton } from "./ToggleButton"

export { ToggleButton }
4 changes: 4 additions & 0 deletions src/components/ToggleButton/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export type ToggleButtonProps = {
isSaved: boolean;
onToggle: (isSaved: boolean) => void;
};
30 changes: 0 additions & 30 deletions src/components/Togglebutton/Togglebutton.stories.tsx

This file was deleted.

8 changes: 0 additions & 8 deletions src/components/Togglebutton/Togglebutton.test.tsx

This file was deleted.

33 changes: 0 additions & 33 deletions src/components/Togglebutton/Togglebutton.tsx

This file was deleted.

3 changes: 0 additions & 3 deletions src/components/Togglebutton/index.ts

This file was deleted.

0 comments on commit 02f2e01

Please sign in to comment.