-
Notifications
You must be signed in to change notification settings - Fork 2
✨ 검색창 컴포넌트 제작 #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
The head ref may contain hidden characters: "feature/#31_\uAC80\uC0C9\uCC3D-\uCEF4\uD3EC\uB10C\uD2B8"
Merged
✨ 검색창 컴포넌트 제작 #33
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
76c4c03
✨ 검색창 컴포넌트 제작
crazyupinc-design 7ace855
🔧내부 상태 관리 제거,아이콘 정렬 수정
crazyupinc-design 8cc14d8
SearchInput.tsx 업데이트했습니다
crazyupinc-design 91ac8fd
이미지 태그 수정
crazyupinc-design 906afbd
Merge branch 'develop' into feature/#31_검색창-컴포넌트
crazyupinc-design 5657c38
Merge branch 'develop' into feature/#31_검색창-컴포넌트
crazyupinc-design cb7b123
🚨Resolve lint and prettier issues
crazyupinc-design File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,84 @@ | ||
| import React, { useState } from 'react'; | ||
|
|
||
| interface SearchInputProps { | ||
| size: 'large' | 'medium'; | ||
| value?: string; | ||
| onSubmit?: (value: string) => void; | ||
| placeholder?: string; | ||
| } | ||
|
|
||
| function SearchInput({ | ||
| size = 'large', | ||
| value = '', | ||
| onSubmit = () => {}, | ||
| placeholder, | ||
| }: SearchInputProps) { | ||
| const [inputValue, setInputValue] = useState(value); | ||
| const [isFocused, setIsFocused] = useState(false); | ||
|
|
||
| const defaultPlaceholder = | ||
| size === 'large' ? '이름으로 위키 검색' : '제목을 검색해 주세요.'; | ||
junghwaYang marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| // 크기별 스타일 | ||
| const sizeStyles = { | ||
| large: { | ||
| container: 'w-[860px] h-[45px] ', | ||
| padding: 'p-[8px] pl-[56px] pr-[128px]', | ||
| }, | ||
| medium: { | ||
| container: 'w-[800px] h-[40px] ', | ||
| padding: 'p-[8px] pl-[56px] pr-[128px]', | ||
| }, | ||
| }; | ||
|
|
||
| const currentSize = sizeStyles[size]; | ||
|
|
||
| const inputStyles = [ | ||
| currentSize.container, | ||
| currentSize.padding, | ||
| 'rounded-lg', | ||
| 'border-none', | ||
| 'bg-gray-100', | ||
| 'text-gray-500', | ||
| 'text-16', | ||
| 'placeholder:text-gray-400', | ||
| isFocused | ||
| ? 'outline outline-2 outline-green-100' | ||
| : 'focus:outline-green-100', | ||
| ].join(' '); | ||
|
|
||
| function handleInputChange(e: React.ChangeEvent<HTMLInputElement>) { | ||
| setInputValue(e.target.value); | ||
| } | ||
|
|
||
| function handleSubmit(e: React.FormEvent) { | ||
| e.preventDefault(); | ||
| onSubmit(inputValue); | ||
| } | ||
|
|
||
| return ( | ||
| <form onSubmit={handleSubmit}> | ||
| <div className="relative"> | ||
| <div className="absolute left-4 top-1/2 -translate-y-1/2 transform"> | ||
| <img | ||
| src="/icon/icon-search.svg" | ||
| alt="검색 아이콘" | ||
| className="h-[22px] w-[22px]" | ||
| /> | ||
| </div> | ||
junghwaYang marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| <input | ||
| className={inputStyles} | ||
| type="text" | ||
| value={inputValue} | ||
| onChange={handleInputChange} | ||
| placeholder={placeholder || defaultPlaceholder} | ||
| onFocus={() => setIsFocused(true)} | ||
| onBlur={() => setIsFocused(false)} | ||
| /> | ||
| </div> | ||
| </form> | ||
| ); | ||
| } | ||
|
|
||
| export default SearchInput; | ||
This file contains hidden or 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.