-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #536 from woowacourse-teams/feat/489-search
검색 기능 구현
- Loading branch information
Showing
10 changed files
with
350 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import type { ComponentPropsWithoutRef } from 'react'; | ||
import styled, { css } from 'styled-components'; | ||
|
||
type SearchInputVariant = 'small' | 'large'; | ||
|
||
type SearchInputProps = ComponentPropsWithoutRef<'input'> & { | ||
variant?: SearchInputVariant; | ||
}; | ||
|
||
const SearchInput = (props: SearchInputProps) => { | ||
const { variant = 'small', ...restProps } = props; | ||
|
||
return <Input $variant={variant} {...restProps} />; | ||
}; | ||
|
||
export default SearchInput; | ||
|
||
const Variants = { | ||
large: css` | ||
padding: ${({ theme }) => theme.space[3]}; | ||
font-size: ${({ theme }) => theme.fontSize.lg}; | ||
`, | ||
small: css` | ||
padding: ${({ theme }) => theme.space[2]}; | ||
font-size: ${({ theme }) => theme.fontSize.base}; | ||
`, | ||
}; | ||
|
||
const Input = styled.input<{ $variant: SearchInputVariant }>` | ||
width: 100%; | ||
border: 1px solid #d0d0d0; | ||
border-radius: 4px; | ||
outline: none; | ||
${({ $variant }) => Variants[$variant || 'small']} | ||
`; |
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,21 @@ | ||
import client from '../client'; | ||
import type { SearchedCafe } from '../types'; | ||
import useSuspenseQuery from './useSuspenseQuery'; | ||
|
||
type SearchCafesQuery = { | ||
searchName: string; | ||
searchMenu?: string | undefined; | ||
searchAddress?: string | undefined; | ||
}; | ||
|
||
const useSearchCafes = (query: SearchCafesQuery) => { | ||
const { searchName, searchMenu, searchAddress } = query; | ||
|
||
return useSuspenseQuery<SearchedCafe[]>({ | ||
queryKey: ['searchCafes', query], | ||
retry: false, | ||
queryFn: () => client.searchCafes({ name: searchName, menu: searchMenu, address: searchAddress }), | ||
}); | ||
}; | ||
|
||
export default useSearchCafes; |
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
Oops, something went wrong.