-
Notifications
You must be signed in to change notification settings - Fork 4
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
lightHouse 웹 접근성 93점을 98점으로 올렸음 #701
Changes from 5 commits
e04a064
7a03249
306e64d
a8500ce
8e5b3f2
5e96993
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { memo, useContext, useEffect } from 'react'; | ||
import { ForwardedRef, forwardRef, memo, useContext, useEffect } from 'react'; | ||
|
||
import { PostInfo } from '@type/post'; | ||
|
||
|
@@ -29,7 +29,10 @@ interface PostProps { | |
isPreview: boolean; | ||
} | ||
|
||
export default memo(function Post({ postInfo, isPreview }: PostProps) { | ||
const Post = forwardRef(function Post( | ||
{ postInfo, isPreview }: PostProps, | ||
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. forwardRef 가 이런식으로 사용하는거군요! (아래는 공식문서로 찾아본 내용)
|
||
ref: ForwardedRef<HTMLLIElement> | ||
) { | ||
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. ForwardRef 라는 타입이 따로 있군요👍 |
||
const { | ||
postId, | ||
category, | ||
|
@@ -110,7 +113,7 @@ export default memo(function Post({ postInfo, isPreview }: PostProps) { | |
const isPreviewTabIndex = isPreview ? undefined : 0; | ||
|
||
return ( | ||
<S.Container as={isPreview ? 'li' : 'div'}> | ||
<S.Container as={isPreview ? 'li' : 'div'} ref={ref} $isPreview={isPreview}> | ||
<S.DetailLink | ||
as={isPreview ? '' : 'main'} | ||
to={isPreview ? `${PATH.POST}/${postId}` : '#'} | ||
|
@@ -195,3 +198,5 @@ export default memo(function Post({ postInfo, isPreview }: PostProps) { | |
</S.Container> | ||
); | ||
}); | ||
|
||
export default memo(Post); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,23 +102,18 @@ export default function PostList() { | |
<React.Fragment key={pageIndex}> | ||
{postListInfo.postList.map((post, index) => { | ||
if (index === 7) { | ||
return ( | ||
<div key={post.postId} ref={targetRef}> | ||
<Post isPreview={true} postInfo={post} /> | ||
</div> | ||
); | ||
return <Post key={post.postId} ref={targetRef} isPreview={true} postInfo={post} />; | ||
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. 코드도 훨씬 깔끔하네요 |
||
} | ||
|
||
return <Post key={post.postId} isPreview={true} postInfo={post} />; | ||
})} | ||
<S.HiddenButton | ||
onClick={focusTopContent} | ||
aria-label="스크롤 맨 위로가기" | ||
></S.HiddenButton> | ||
<S.HiddenLink | ||
aria-label="게시글 작성 페이지로 이동" | ||
to={PATH.POST_WRITE} | ||
></S.HiddenLink> | ||
<li key={`${pageIndex}UserButton`}> | ||
<S.HiddenButton | ||
onClick={focusTopContent} | ||
aria-label="스크롤 맨 위로가기" | ||
></S.HiddenButton> | ||
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. 사소한 부분이지만 아래처럼 self-closing tag로 작성해도 좋을 것 같아요! <S.HiddenButton
onClick={focusTopContent}
aria-label="스크롤 맨 위로가기"
/ > |
||
<S.HiddenLink aria-label="게시글 작성 페이지로 이동" to={PATH.POST_WRITE} /> | ||
</li> | ||
</React.Fragment> | ||
))} | ||
{isFetchingNextPage && <Skeleton isLarge={false} />} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,16 +29,6 @@ export const PostListContainer = styled.ul` | |
gap: 30px; | ||
|
||
padding: 30px 20px; | ||
|
||
> div > li { | ||
padding-bottom: 30px; | ||
border-bottom: 1px solid rgba(0, 0, 0, 0.1); | ||
} | ||
|
||
> li { | ||
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. 사용처로 코드를 이동시키니 이해가 훨씬 잘 되네요bb |
||
padding-bottom: 30px; | ||
border-bottom: 1px solid rgba(0, 0, 0, 0.1); | ||
} | ||
`; | ||
|
||
export const SelectWrapper = styled.div` | ||
|
@@ -61,3 +51,8 @@ export const HiddenButton = styled.button` | |
export const HiddenLink = styled(Link)` | ||
position: absolute; | ||
`; | ||
|
||
export const HiddenList = styled.li` | ||
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. 오 이거 혹시 어디에 쓰이는 코드인가요?? |
||
padding-bottom: none; | ||
border-bottom: none; | ||
`; |
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.
👍