-
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
1 parent
b3e4aab
commit 599e521
Showing
5 changed files
with
105 additions
and
10 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/components/Common/KeywordToggleButton/KeywordToggleButton.stories.tsx
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,26 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { KeywordToggleButton } from './KeywordToggleButton'; | ||
|
||
const meta: Meta<typeof KeywordToggleButton> = { | ||
component: KeywordToggleButton, | ||
title: 'atoms/KeywordToggleButton', | ||
tags: ['autodocs'], | ||
argTypes: {} | ||
}; | ||
export default meta; | ||
|
||
type Story = StoryObj<typeof KeywordToggleButton>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
keyword: '키워드' | ||
} | ||
}; | ||
|
||
export const Active: Story = { | ||
args: { | ||
keyword: '키워드', | ||
isActive: true | ||
} | ||
}; |
20 changes: 20 additions & 0 deletions
20
src/components/Common/KeywordToggleButton/KeywordToggleButton.tsx
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,20 @@ | ||
type KeywordToggleButtonProps = { | ||
keyword: string; | ||
isActive?: boolean; | ||
onClick: () => void; | ||
}; | ||
|
||
export const KeywordToggleButton = ({ | ||
keyword, | ||
isActive = false, | ||
onClick | ||
}: KeywordToggleButtonProps) => { | ||
return ( | ||
<button | ||
onClick={onClick} | ||
className={`border border-gray-600 border-solid rounded-full px-3 py-1 ${isActive ? 'bg-slate-500' : 'bg-white'} ${isActive ? 'text-white' : 'text-black'}`} | ||
> | ||
{keyword} | ||
</button> | ||
); | ||
}; |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import { useUserStore } from './useUserStore'; | ||
import { useHomeSheetStore } from './useHomeSheetStore'; | ||
import { useSelectedKeywordStore } from './useSelectedKeywordStore'; | ||
|
||
export { useUserStore, useHomeSheetStore }; | ||
export { useUserStore, useHomeSheetStore, useSelectedKeywordStore }; |
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,11 @@ | ||
import { create } from 'zustand'; | ||
|
||
interface selectedKeywordState { | ||
selectedKeywords: string[]; | ||
setSelectedKeywords: (selectedKeywords: string[]) => void; | ||
} | ||
|
||
export const useSelectedKeywordStore = create<selectedKeywordState>((set) => ({ | ||
selectedKeywords: [], | ||
setSelectedKeywords: (selectedKeywords) => set({ selectedKeywords }) | ||
})); |