-
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.
- Loading branch information
Showing
4 changed files
with
68 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { ToggleBar } from "./ToggleBar"; | ||
|
||
const meta: Meta<typeof ToggleBar> = { | ||
title: "ds/ToggleBar", | ||
component: ToggleBar, | ||
tags: ["autodocs"], | ||
argTypes: { | ||
onToggle: { action: "onToggle" }, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof ToggleBar>; | ||
|
||
export const Default: Story = { | ||
render: (args) => <ToggleBar {...args} />, | ||
}; |
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,45 @@ | ||
import { useState } from "react"; | ||
import { Text, textVariants } from "./Text"; | ||
import { cn } from "./cn"; | ||
|
||
interface ToggleBarProps { | ||
onToggle: (selected: "created" | "updated") => void; | ||
} | ||
|
||
export const ToggleBar: React.FC<ToggleBarProps> = ({ onToggle }) => { | ||
const [selected, setSelected] = useState<"created" | "updated">("created"); | ||
|
||
const handleToggle = (option: "created" | "updated") => { | ||
setSelected(option); | ||
onToggle(option); | ||
}; | ||
|
||
return ( | ||
<div className={cn("flex justify-between w-full h-[36px] px-4 items-end")}> | ||
<Text as="h1" variant="title/24_sb"> | ||
독서기록 | ||
</Text> | ||
<div className="flex gap-[18px]"> | ||
<button | ||
onClick={() => handleToggle("created")} | ||
className={cn( | ||
selected === "created" ? "text-gray-500" : "text-gray-300", | ||
textVariants({ variant: "body/16_sb" }), | ||
)} | ||
> | ||
생성일 순 | ||
</button> | ||
|
||
<button | ||
onClick={() => handleToggle("updated")} | ||
className={cn( | ||
selected === "updated" ? "text-gray-500" : "text-gray-300", | ||
textVariants({ variant: "body/16_sb" }), | ||
)} | ||
> | ||
업데이트 순 | ||
</button> | ||
</div> | ||
</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