-
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
[Refactor] 아카이빙 페이지 리팩토링 #208
[Refactor] 아카이빙 페이지 리팩토링 #208
Conversation
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.
리팩토링 고생하셨습니다 ! LGTM ~
overflowX: 'hidden', | ||
overflowY: 'hidden', |
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.
overflow: hidden
?
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.
넵 !!
currentMonth={selectedMonth} | ||
onMonthClick={(month) => setSelectedMonth(month)} | ||
currentMonth={selectedMonthType} | ||
onMonthClick={(month) => setSelectedMonthType(month)} |
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.
onMonthClick={setSelectedMonthType}
을 의도하신 걸까요 ?
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.
움 넵 그렇습니다 수정할게요!
|
||
const [selectedBlock, setSelectedBlock] = useState<Block>(); | ||
const timeBlocks: Block[] = data?.timeBlocks || []; | ||
const blockFloors = alignBlocks(timeBlocks, endDay, selectedMonth, currentYear); | ||
const blockFloors = alignBlocks(timeBlocks, endDay, selectedMonthType, currentYear); |
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.
alignBlocks
에 대한 결과값을 useMemo
로 처리해주는 것도 좋을 것 같아요. 실제로 비교적 높은 비용의 연산이기도 하니 메모이제이션을 적용해준다면 성능에 좋을 것 같습니다.
또한 Daysection
과 같은 컴포넌트들은 실제로 prop이 바뀔 일이 흔하지 않은데, 부모 요소의 리렌더링으로서 같이 모두다 리렌더링되니까, memo
과 같은 함수를 통해 메모이제이션 해줄 수도 있을 것 같아요
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.
추가적으로 selectedMonthType
이 "12월" 과 같은 문자열을 리턴하는 것으로 보여지는데, MonthType
보다 더 적절한 네이밍은 없을까용 ?
보통 Date가 아닌 문자열 형식으로 포맷된 Date 문자열을 dateString 이라고 하니까 MonthString
...?
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.
useMemo로 블록 쌓기 로직 처리해주는 것과 DaySection도 memo를 통해 렌더링 최소화 하는 것 모두 동의합니다 반영했어요 !
그리고 selectedMonthType의 경우 저도 네이밍을 많이 고민해봤는데 .. selectedMonthString도 나쁘지 않은데 문자열이라는 타입에 초점을 두기 보다는 달 헤더의 각 이름을 의미하는 바로 selectedMonthLabel
은 어떠신가요 ?
<div css={blockStyle(blockWidth, startPosition, floor, color, isSelected)} onClick={onBlockClick} {...props}> | ||
{BLOCK_TYPE.find((icon) => icon.name === blockType)?.icon} | ||
<p css={spanStyle}>{children}</p> | ||
<span css={blockNameStyle}>{children}</span> | ||
</div> | ||
); | ||
}; |
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.
제가 생각하기에는 타임블록은 clickable
하고 focusable
해야된다고 생각해요. 왜냐하면 그래야 스크린리더도 해당 타임블록들이 클릭 가능하며, 유저와의 인터랙션을 통해 부가적인 기능들을 제공한다는 것을 인식할 수 있을 것 같아요.
따라서 적절한 role
을 부여하여 keyboard
이벤트와 click
이벤트 모두다 적용해주면 어떨까요 ? tab
을 통해서도 접근 가능하다면 사용자 입장에서나 접근성 측면에서나 더 좋을 것 같다고 생각해요
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.
깔끔하게 리펙토링 잘하셨네요~~ 최적화까지 신경쓰신게 아주 대단합니다 저도 메모이제이션을 고려해보면서 코드를 한번 다시 슥 봐야겠어요!
@@ -35,7 +41,10 @@ const ArchivingPage = () => { | |||
setSelectedId(id); | |||
}; | |||
|
|||
const handleBlockClick = (e: React.MouseEvent<HTMLDivElement>, block: Block) => { | |||
const handleBlockClick = ( | |||
e: React.MouseEvent<HTMLDivElement> | React.KeyboardEvent<HTMLDivElement>, |
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.
keyboardEvent 까지 신경쓴거 아주 굳이네요 굳
paddingLeft: '6rem', | ||
}} | ||
css={{ overflowY: 'hidden', overflowX: 'hidden' }}> | ||
<Flex css={pageStyle}> |
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.
css와 styles를 둘 다 썼길래 css하나로 통일해줬습니다리
const blockFloors = useMemo( | ||
() => alignBlocks(timeBlocks, endDay, selectedMonthString, currentYear), | ||
[currentYear, endDay, selectedMonthString, timeBlocks] | ||
); |
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.
오 usememo로 최적화까지! 역시 리액트 스장님이십니다
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.
아카이빙 페이지 전체 리팩토링하느라 수고하셨습니다 ❤️
보고싶네용 😉
return ( | ||
<Flex css={dayStyle(isEven, isToday)}> | ||
<Flex css={dayHeaderStyle(isToday)}>{day + 1}</Flex> | ||
<Flex css={bodyStyle} /> |
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.
소소하게 궁금한게, 여기 Flex 태그는 내용이 없는데도 css가 적용이 되나용 ❓
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.
그러게용 순수 css prop 만을 사용할거라면 가시적일수 있도록 일반 html tag를 사용해도 좋을 것 같네요.
Flex
태그는 디폴트로 div
태그의 속성들을 상속하기 때문에, 일반적인 prop들 다 적용 가능해요 !
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.
그러게용 순수 css prop 만을 사용할거라면 가시적일수 있도록 일반 html tag를 사용해도 좋을 것 같네요.
저는 flex 속성을 사용할 때 가능하면 Flex 공컴을 써보려고 했는데 고런 부분도 함 생각해봐야겠네요 고맙습니다 ~
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.
고생하셨습니다!! 최고!!
useDate(); | ||
|
||
const selectedMonthNumber = parseInt(selectedMonth.split('월')[0]); | ||
const selectedMonth = parseInt(selectedMonthString.split('월')[0]); |
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.
오오 string으로 구분해주니, string 과 number을 바로 구분하여 사용할 수 있겠네요!!
const blockFloors = useMemo( | ||
() => alignBlocks(timeBlocks, endDay, selectedMonthString, currentYear), | ||
[currentYear, endDay, selectedMonthString, timeBlocks] | ||
); |
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.
역시 스장님!!
@@ -28,7 +28,7 @@ export const blockStyle = (width: number, startPosition: number, floor: number, | |||
cursor: 'pointer', | |||
}); | |||
|
|||
export const spanStyle = { | |||
export const blockNameStyle = { | |||
margin: 'auto 0.7rem', | |||
|
|||
lineHeight: '120%', |
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.
span태그가 기본적으로 inline 요소이고 줄바꿈이 되지 않으니, lineHeight: '120%',는 없애도 되지 않을까요..??!
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.
동의합니다 수정했어요 :)
해당 이슈 번호
closed #189
체크리스트
📌 내가 알게 된 부분
ArchivingPage.tsx
)안에 각 컴포넌트에 대한 코드가 너무 드러난 것 같아서 가독성에 좋지 못하다고 판단했습니다. 그래서 최대한 이를 분리하는 것에 신경써봤어요. (각 컴포넌트 코드 안에 그 컴포넌트에 해당하는 로직 코드가 존재하도록 !)📌 질문할 부분
📌스크린샷 (선택)