-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: document search #306
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
502305d
feat: document-search
rabyeoljji fdfb7ae
Merge branch 'develop' of github.com:picktoss/pick-toss-next into fea…
rabyeoljji 33ac86a
fix: merge
rabyeoljji 0f5ea7b
feat: use-recent-searches hook
rabyeoljji f88f931
fix: 스토리지에 저장되는 데이터 구조 간단하게 수정
rabyeoljji d541d47
Merge branch 'develop' of github.com:picktoss/pick-toss-next into fea…
rabyeoljji e9c1206
fix: localstorage
rabyeoljji f793682
Merge branch 'develop' of github.com:picktoss/pick-toss-next into fea…
rabyeoljji c3f7d20
refactor: markdown processor
rabyeoljji b1c21d9
Merge branch 'develop' of github.com:picktoss/pick-toss-next into fea…
rabyeoljji 6f99eb6
fix: api 변경 + usePreviousPath hook 수정
rabyeoljji 7cda0cd
Merge branch 'develop' of github.com:picktoss/pick-toss-next into fea…
rabyeoljji 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 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,34 +1,54 @@ | ||
'use client' | ||
|
||
import Icon from '@/shared/components/custom/icon' | ||
import { Input } from '@/shared/components/ui/input' | ||
import { useRouter } from 'next/navigation' | ||
import { RefObject, useState } from 'react' | ||
import { ChangeEventHandler, RefObject } from 'react' | ||
|
||
interface Props { | ||
searchHeaderRef: RefObject<HTMLDivElement> | ||
inputValue: string | ||
onChangeInputValue: ChangeEventHandler<HTMLInputElement> | ||
searchInputRef: RefObject<HTMLInputElement> | ||
isSearchFocused: boolean | ||
setIsSearchFocused: (value: boolean) => void | ||
onDeleteKeyword: () => void | ||
onSubmit: (e: React.FormEvent<HTMLFormElement>) => void | ||
} | ||
|
||
const HeaderInDocument = ({ searchHeaderRef, isSearchFocused, setIsSearchFocused }: Props) => { | ||
const HeaderInDocument = ({ | ||
inputValue, | ||
onChangeInputValue, | ||
searchInputRef, | ||
isSearchFocused, | ||
setIsSearchFocused, | ||
onDeleteKeyword, | ||
onSubmit, | ||
}: Props) => { | ||
const router = useRouter() | ||
const [keyword, setKeyword] = useState('') | ||
|
||
const handleCancel = () => { | ||
if (isSearchFocused) { | ||
setIsSearchFocused(false) | ||
return | ||
} else { | ||
router.push('/document') | ||
} | ||
} | ||
|
||
return ( | ||
<header | ||
ref={searchHeaderRef} | ||
className="flex-center relative right-1/2 z-20 h-[56px] w-full max-w-mobile grow translate-x-1/2 bg-background-base-01 px-[16px] text-subtitle2-medium" | ||
> | ||
<div tabIndex={-1} className="relative grow"> | ||
<header className="flex-center relative right-1/2 z-20 h-[56px] w-full max-w-mobile grow translate-x-1/2 bg-background-base-01 px-[16px] text-subtitle2-medium"> | ||
<form onSubmit={onSubmit} tabIndex={-1} className="relative grow"> | ||
<Input | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. autoFocus 속성이 들어가도 좋을 것 같아용! |
||
value={keyword} | ||
onChange={(e) => setKeyword(e.target.value)} | ||
ref={searchInputRef} | ||
onFocus={() => setIsSearchFocused(true)} | ||
value={inputValue} | ||
onChange={onChangeInputValue} | ||
placeholder="노트명, 노트, 퀴즈 검색" | ||
className="h-[40px] placeholder:text-text-placeholder-01" | ||
variant={'round'} | ||
left={<Icon name="search-bar" className="size-[20px] text-icon-secondary" />} | ||
right={ | ||
<button> | ||
<button type="button" onClick={onDeleteKeyword}> | ||
<Icon | ||
name="cancel-circle" | ||
className="size-[24px]" | ||
|
@@ -38,15 +58,9 @@ const HeaderInDocument = ({ searchHeaderRef, isSearchFocused, setIsSearchFocused | |
</button> | ||
} | ||
/> | ||
</div> | ||
<button | ||
onClick={() => { | ||
if (isSearchFocused) { | ||
setIsSearchFocused(false) | ||
} else router.back() | ||
}} | ||
className="ml-[17px] w-fit text-text-secondary" | ||
> | ||
</form> | ||
|
||
<button type="button" onClick={handleCancel} className="ml-[17px] w-fit text-text-secondary"> | ||
취소 | ||
</button> | ||
</header> | ||
|
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 | ||||
---|---|---|---|---|---|---|
|
@@ -3,17 +3,20 @@ import Tag from '@/shared/components/ui/tag' | |||||
import Text from '@/shared/components/ui/text' | ||||||
import { cn } from '@/shared/lib/utils' | ||||||
import DocumentTypeIcon from '@/features/document/components/document-type-icon' | ||||||
import Link from 'next/link' | ||||||
|
||||||
interface Props { | ||||||
documentId: number | undefined // api 수정되면 undefined 제거 | ||||||
createType: Document.ItemInList['documentType'] | ||||||
documentTitle: string | ||||||
matchingSentence: string | ||||||
documentTitle: React.ReactNode | ||||||
matchingSentence: React.ReactNode | ||||||
resultType: 'document' | 'quiz' | ||||||
relativeDirectory: string | ||||||
lastItem?: boolean | ||||||
} | ||||||
|
||||||
const SearchItem = ({ | ||||||
documentId, | ||||||
createType, | ||||||
documentTitle, | ||||||
matchingSentence, | ||||||
|
@@ -22,7 +25,8 @@ const SearchItem = ({ | |||||
lastItem, | ||||||
}: Props) => { | ||||||
return ( | ||||||
<div | ||||||
<Link | ||||||
href={documentId ? '/document/' + documentId : '#'} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
className={cn( | ||||||
'border-b border-border-divider py-[24px] flex flex-col', | ||||||
lastItem && 'border-none' | ||||||
|
@@ -37,7 +41,6 @@ const SearchItem = ({ | |||||
<Text typography="subtitle2-bold">{documentTitle}</Text> | ||||||
</div> | ||||||
|
||||||
{/* todo: 키워드와 일치하는 부분 색상 accent표시 하는 로직 필요 */} | ||||||
<Text>{matchingSentence}</Text> | ||||||
|
||||||
<div className="mt-[8px] flex items-center"> | ||||||
|
@@ -50,7 +53,7 @@ const SearchItem = ({ | |||||
<Text>{relativeDirectory}</Text> | ||||||
</div> | ||||||
</div> | ||||||
</div> | ||||||
</Link> | ||||||
) | ||||||
} | ||||||
|
||||||
|
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 @@ | ||
export const RECENT_SEARCHES = 'recentSearches' |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
router.back이 아닌 document로 보내는 이유가 있을까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
앗 안그래도 저도 통합검색 구현하면서 잘못된 부분들이 좀 있길래 수정했는데ㅎㅎ 이 부분도 정우님 말씀처럼 router.back으로 통합검색 쪽에서 수정했습니다!