-
Notifications
You must be signed in to change notification settings - Fork 0
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
fix: 사이트 이름 클릭 시 사이트로 이동하게 수정 #293
Closed
Closed
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
654becb
feat: 링크의 상위 도메인 추출하는 함수 추가
ssolfa 7d5b24c
feat: 도메인으로 링크 여는 부분 추가
ssolfa 4ceda5f
Merge branch 'develop' into fix/#266-search-result-link-click-redirect
ssolfa f48abcb
refactor: 상위 도메인 추출함수를 utils로 분리 및 ResultList에 적용
ssolfa ef48e1b
refactor: window.open()에서 기본값인 _blank 제거
ssolfa 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
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 |
---|---|---|
|
@@ -18,26 +18,37 @@ import { | |
StyledTitle, | ||
StyledContentWrap, | ||
StyledInformationWrap, | ||
StyledDomain, | ||
} from './ResultListItem.style'; | ||
|
||
interface ResultListItemProps | ||
extends Pick<React.ComponentProps<'div'>, 'onClick'>, | ||
ResultListItemResponse {} | ||
ResultListItemResponse { | ||
domain?: string; | ||
} | ||
|
||
export const ResultListItem = forwardRef<HTMLDivElement, ResultListItemProps>( | ||
({ title, content, date, thumbnail, favicon, source, onClick }, ref) => { | ||
({ title, content, date, thumbnail, favicon, source, domain, onClick }, ref) => { | ||
const isVerticalLayout = thumbnail.length >= RESULT_LIST_ITEM_THUMBNAIL_LENGTH; | ||
const isHorizontalLayout = !isVerticalLayout && thumbnail.length > 0; | ||
const handleDomainClick = (e: React.MouseEvent) => { | ||
e.stopPropagation(); | ||
if (domain) { | ||
window.open(domain, '_blank'); | ||
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.
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. 사실 저 pr 보고 호버 썼는데... 리뷰를 안봤네요,,,,,,,,,,,,,,,,, 수정했습니다!! |
||
} | ||
}; | ||
|
||
return ( | ||
<StyledResultListItem ref={ref} onClick={onClick}> | ||
<StyledContentWrap $isHorizontalLayout={isHorizontalLayout}> | ||
<StyledInformationWrap> | ||
<StyledLinkImageWrap> | ||
<StyledLinkImage src={favicon || '/'} alt="favicon" onError={onErrorImg} /> | ||
</StyledLinkImageWrap> | ||
<Spacing direction="horizontal" size={4} /> | ||
<StyledLinkTitle>{source}</StyledLinkTitle> | ||
<StyledDomain onClick={handleDomainClick}> | ||
<StyledLinkImageWrap> | ||
<StyledLinkImage src={favicon || '/'} alt="favicon" onError={onErrorImg} /> | ||
</StyledLinkImageWrap> | ||
<Spacing direction="horizontal" size={4} /> | ||
<StyledLinkTitle>{source}</StyledLinkTitle> | ||
</StyledDomain> | ||
<Spacing direction="horizontal" size={4} /> | ||
<StyledDate>·</StyledDate> | ||
<Spacing direction="horizontal" size={4} /> | ||
|
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.
리액트에서
handle~
로 시작하는 네이밍은 이벤트 핸들러에 사용되는 것이 일반적이니handle
을 제거하고 함수가 하는 일을 명확하게 드러낼 수 있도록extractOrigin
정도로 함수 이름을 바꾸는 것이 어떨까요?또 리액트 의존성 없이 범용적으로 사용할 수 있는 함수이니 위치를
utils
폴더 아래로 옮겨도 좋을 것 같네요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.
천잰가?
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.
오... 👍👍👍👍👍 적극반영 하였습니다!!!
refactor: 상위 도메인 추출함수를 utils로 분리 및 ResultList에 적용