-
Notifications
You must be signed in to change notification settings - Fork 8
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
14 changed files
with
219 additions
and
20 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
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
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
34 changes: 34 additions & 0 deletions
34
frontend/src/components/common/searchBar/SearchBar.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,34 @@ | ||
import SearchBar from "./SearchBar"; | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
const meta = { | ||
title: "Common/SearchBar", | ||
component: SearchBar, | ||
argTypes: { | ||
placeholder: { | ||
control: { | ||
type: "text", | ||
}, | ||
description: "placeholder", | ||
defaultValue: "방 제목을 검색해주세요", | ||
}, | ||
defaultValue: { | ||
control: { | ||
type: "text", | ||
}, | ||
description: "textarea의 value", | ||
}, | ||
}, | ||
} satisfies Meta<typeof SearchBar>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
value: "기본 입력창", | ||
handleValue: () => {}, | ||
handleSearch: () => {}, | ||
}, | ||
}; |
16 changes: 16 additions & 0 deletions
16
frontend/src/components/common/searchBar/SearchBar.style.ts
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,16 @@ | ||
import styled from "styled-components"; | ||
|
||
export const SearchBarContainer = styled.div` | ||
position: relative; | ||
width: 100%; | ||
height: 40px; | ||
`; | ||
|
||
export const SearchIconWrapper = styled.div` | ||
cursor: pointer; | ||
position: absolute; | ||
top: 50%; | ||
right: 3px; | ||
transform: translate(-50%, -50%); | ||
`; |
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,34 @@ | ||
import * as S from "./SearchBar.style"; | ||
import { InputHTMLAttributes } from "react"; | ||
import Icon from "@/components/common/icon/Icon"; | ||
import { Input } from "@/components/common/input/Input"; | ||
|
||
interface SearchBarProps extends InputHTMLAttributes<HTMLInputElement> { | ||
value: string; | ||
handleValue: (e: React.ChangeEvent<HTMLInputElement>) => void; | ||
handleSearch: () => void; | ||
} | ||
|
||
const SearchBar = ({ value, handleValue, handleSearch, ...props }: SearchBarProps) => { | ||
const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => { | ||
if (e.key === "Enter") { | ||
handleSearch(); | ||
} | ||
}; | ||
|
||
return ( | ||
<S.SearchBarContainer> | ||
<Input | ||
value={value} | ||
onChange={handleValue} | ||
onKeyDown={handleKeyDown} | ||
style={{ paddingRight: "3rem", height: "40px" }} | ||
/> | ||
<S.SearchIconWrapper onClick={handleSearch}> | ||
<Icon kind="search" /> | ||
</S.SearchIconWrapper> | ||
</S.SearchBarContainer> | ||
); | ||
}; | ||
|
||
export default SearchBar; |
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,7 +1,11 @@ | ||
import styled from "styled-components"; | ||
|
||
export const DropdownWrapper = styled.div` | ||
export const SearchBarWrapper = styled.div` | ||
width: 180px; | ||
`; | ||
|
||
export const FilterWrapper = styled.div` | ||
display: flex; | ||
justify-content: flex-end; | ||
justify-content: space-between; | ||
margin-bottom: 1rem; | ||
`; |
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
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