-
Notifications
You must be signed in to change notification settings - Fork 6
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-fe: 범용 Tooltip 컴포넌트 구현, 대시보드 사이드바 버그 수정 및 리팩토링 #986
Conversation
1737547023.635199 |
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.
넘 깔끔하게 코로케이션 해주시고, 역할에 따라 컴포넌트 구성해주셔서 너무 보기 편했씁니다 ㅎㅎ 너무 깔끔합니다!
스토리북도 너무 자세하게 적어주셔서 놀랍네요 ㅋㅋㅋㅋ 너무 고생하셨습니다!
툴팁이 적용된 건 아니고 컴포넌트 수정만 이루어진 것으로 보이네요!
'버그 수정'이라고 되어있어서 적용까지 고려하셨는지 여쭤봅니다!
useEffect(() => { | ||
const tooltipObj = ref as RefObject<HTMLDivElement>; | ||
if (!tooltipObj.current) return; | ||
|
||
tooltipObj.current.style.left = `${positionX}px`; | ||
tooltipObj.current.style.top = `${positionY}px`; | ||
|
||
if (maxWidth) { | ||
tooltipObj.current.style.maxWidth = `${maxWidth}px`; | ||
} | ||
}, [maxWidth, positionX, positionY, ref]); | ||
|
||
return ( | ||
<S.ContentContainer | ||
ref={ref} | ||
placement={placement} | ||
zIndex={zIndex} | ||
data-visible={isVisible} | ||
> | ||
{content} | ||
</S.ContentContainer> | ||
); | ||
}, |
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.
useEffect를 사용하신 이유가 따로 있으실까요? S.ContentContainer 내부에 style을 바로 적용해도 될 것 같단 생각이 들었습니다!
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.
리사이징이나 스크롤 상황에서의 위치 변화에 대응하려면 DOM 요소에 스타일을 직접 주입하는 것이 퍼포먼스 측면에서 더 나을 거라 생각해서 이렇게 구현했었어요. 그런데 실제로 실험해보니, style prop으로 위치를 내려주는 것과 useEffect를 사용하는 것 사이의 유의미한 차이가 없었네요 😅
따라서 스타일의 선언적 관리, 그리고 코드의 가독성을 고려하여 러기 의견대로 스타일 적용 구조를 바꾸었습니다. 피드백 감사해요 👍
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.
안녕하세요, 아르! 드디어 마지막 작업이었네요.
사이드바 리팩토링, Tooltip 컴포넌트 생성 확인했습니다. 제 환경에서는 버그도 없었어요.
아키텍처가 탄탄하고 변수명도 직관적이어서 술술 읽히는 코드였습니다.
이것이 아르 코어?
마지막 작업 고생 많으셨습니다. 출국하시기 전에 한번 뵙죠!
가족분들과 함께 따뜻하고 즐거운 설 연휴 보내시길 바랍니다. 새해 복 많이 받으세용.
const style: React.CSSProperties = { | ||
left: `${positionX}px`, | ||
top: `${positionY}px`, | ||
maxWidth: maxWidth ? `${maxWidth}px` : undefined, | ||
}; |
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.
선언적으로 사용하셨군요 👍
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Seongjin Hong <[email protected]>
Original issue description
목적
작업 세부사항
참고 사항
COMM_TOOLTIP_01
크루루 팀의 일원으로서 올려드리는 마지막 PR입니다.
본래는 아래의 3개로 분리되었어야 할 작업이나, 과업 진행 여건을 고려하여 PR 리뷰의 편의를 돕고자 하나로 합쳤습니다.
마지막까지 잘 부탁드립니다.
목적
작업 세부사항
범용 Tooltip 컴포넌트 구현
Tooltip 컴포넌트 구현
createPortal
을 이용한 DOM 삽입 방법을 이용했습니다. (TooltipPortal.tsx
참고)Element.getBoundingClientRect
와window.scrollX/Y
,document.documentElement.scrollLeft/Top
를 활용해 실시간 계산하여 Ref로 삽입하는 구조를 가집니다.8방향 Tooltip 배치 유형 구현
top
,topRight
,right
,bottomRight
,bottom
,bottomLeft
,left
,topLeft
의 8방향을placement
prop으로 받습니다.top
입니다.기타 Tooltip 배치에 필요한 커스터마이징 요소 구현
zIndex
: zIndex값을 부여합니다. 기본값은9999
입니다.distanceFromTarget
: 툴팁을 표시할 타겟 요소와의 거리를 정합니다. 기본값은8
(px)입니다.maxWidth
: 툴팁의 최대 너비를 정합니다. 정해질 경우 내부 텍스트는 줄바꿈이 이루어집니다.Tooltip UI 테스트용 스토리보드 구현
대시보드 사이드바 화면에서 스크롤 동작 시 Tooltip 요소가 어긋나는 문제 수정
Tooltip 배치 시 브라우저 뷰포트 영역 대응
placement
값대로 배치한 Tooltip이 브라우저의 뷰포트 바깥 영역으로 나갈 경우, Tooltip은placement
설정값의 반대 방향으로 자동 배치됩니다. (예:right
의 경우left
방향으로 전환 배치)화면 스크롤, 리사이징 상태에 모두 대응
대시보드 사이드바 영역의 컴포넌트 구조 전면 리팩토링
구현 화면
사이드바 툴팁 적용 화면
Jan-22-2025.20-49-39.mp4
배치 방향별 툴팁 표시 화면
Jan-22-2025.20-50-60.mp4
스크롤 시 동작 테스트 화면
Jan-22-2025.20-52-37.mp4
참고사항
Molecule
로 구분하여 두었습니다. Content, Portal 등 여러 요소를 결합하여 구성하였기에 이 분류가 적절하다고 판단했습니다. 혹시 다른 의견이 있으시다면 편히 말씀 주세요.관련 이슈