Skip to content
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

Merged
merged 17 commits into from
Jan 31, 2025

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Jan 12, 2025

Original issue description

목적

  • 현재 툴팁 요소는 공고 대시보드 사이드바 영역이 접혀있는 경우에 한해 각 아이콘 버튼에만 적용되어 있는 상태입니다.
  • 이 툴팁은 최종 데모데이를 하루 앞두고 HTML+CSS 만으로 급조되었습니다. 독립된 컴포넌트로 구현되지 못했을 뿐만 아니라 재사용성 또한 거의 없는 상태입니다.
  • 아울러 한 번 렌더링 완료된 상태의 부모 요소 위치에 종속된 position을 가지고 있어, 스크롤 또는 화면 resizing 등의 변화에 대응하지 못하는 문제도 가지고 있습니다.
  • 이에 독립된 형태의, 재사용성 높은 범용 Tooltip 컴포넌트를 구현하여 위의 문제들을 해결하고자 합니다.

작업 세부사항

  • 범용 Tooltip 컴포넌트 구현
    • 선호 위치, 원 요소와의 거리, maxWidth, zIndex 등 커스텀 가능한 요소 적용
    • 화면 리사이징 혹은 스크롤에 대응
    • 툴팁 위치가 화면 viewport를 벗어날 경우 처음 선호 위치의 반대 방향으로 표시되도록 구현

참고 사항

아래의 별표줄 밑에 요구사항 ID만 작성해주세요. Prefix 금지!


COMM_TOOLTIP_01

크루루 팀의 일원으로서 올려드리는 마지막 PR입니다.
본래는 아래의 3개로 분리되었어야 할 작업이나, 과업 진행 여건을 고려하여 PR 리뷰의 편의를 돕고자 하나로 합쳤습니다.

  1. 범용 Tooltip 컴포넌트 구현
  2. 대시보드 사이드바 화면에서 스크롤 동작 시 Tooltip 요소가 어긋나는 문제 수정
  3. 대시보드 사이드바 영역의 컴포넌트 구조 전면 리팩토링

마지막까지 잘 부탁드립니다.

목적

  • 서비스 화면 어디에서나 Wrapper 형태로 가져다 쓸 수 있는 범용 Tooltip 컴포넌트를 새롭게 구현합니다.
  • 새로 구현한 Tooltip 컴포넌트를 대시보드 사이드바에 적용합니다.
  • 대시보드 사이드바 코드 구조를 전면 리팩토링합니다.

작업 세부사항

범용 Tooltip 컴포넌트 구현

  • Tooltip 컴포넌트 구현

  • 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 방향으로 전환 배치)
    • 만약 양쪽 중 어느 방향에 Tooltip을 배치하더라도 뷰포트에서 벗어나는 경우, Tooltip은 원래 설정값대로 배치됩니다. (물론 이럴 경우는 거의 없을 것으로 생각됩니다)
  • 화면 스크롤, 리사이징 상태에 모두 대응

대시보드 사이드바 영역의 컴포넌트 구조 전면 리팩토링

  • 사이드바 구조 리팩토링
    • 아래 이미지와 같은 구조로 재구성했습니다.
      image

구현 화면

사이드바 툴팁 적용 화면

Jan-22-2025.20-49-39.mp4

배치 방향별 툴팁 표시 화면

Jan-22-2025.20-50-60.mp4

스크롤 시 동작 테스트 화면

Jan-22-2025.20-52-37.mp4

참고사항

  • Tooltip 컴포넌트는 Molecule로 구분하여 두었습니다. Content, Portal 등 여러 요소를 결합하여 구성하였기에 이 분류가 적절하다고 판단했습니다. 혹시 다른 의견이 있으시다면 편히 말씀 주세요.

관련 이슈

@github-actions github-actions bot added feature 새로운 기능 frontend 프론트엔드 labels Jan 12, 2025
@github-actions github-actions bot added this to the 스프린트 7.0 milestone Jan 12, 2025
@seongjinme seongjinme changed the title feat-fe: 범용 Tooltip 컴포넌트 구현 feat-fe: 범용 Tooltip 컴포넌트 구현, 대시보드 사이드바 버그 수정 및 리팩토링 Jan 22, 2025
@seongjinme seongjinme marked this pull request as ready for review January 22, 2025 11:56
Copy link
Contributor Author

1737547023.635199

Copy link
Contributor

@lurgi lurgi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넘 깔끔하게 코로케이션 해주시고, 역할에 따라 컴포넌트 구성해주셔서 너무 보기 편했씁니다 ㅎㅎ 너무 깔끔합니다!
스토리북도 너무 자세하게 적어주셔서 놀랍네요 ㅋㅋㅋㅋ 너무 고생하셨습니다!

툴팁이 적용된 건 아니고 컴포넌트 수정만 이루어진 것으로 보이네요!
'버그 수정'이라고 되어있어서 적용까지 고려하셨는지 여쭤봅니다!

Comment on lines 18 to 40
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>
);
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useEffect를 사용하신 이유가 따로 있으실까요? S.ContentContainer 내부에 style을 바로 적용해도 될 것 같단 생각이 들었습니다!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리사이징이나 스크롤 상황에서의 위치 변화에 대응하려면 DOM 요소에 스타일을 직접 주입하는 것이 퍼포먼스 측면에서 더 나을 거라 생각해서 이렇게 구현했었어요. 그런데 실제로 실험해보니, style prop으로 위치를 내려주는 것과 useEffect를 사용하는 것 사이의 유의미한 차이가 없었네요 😅

따라서 스타일의 선언적 관리, 그리고 코드의 가독성을 고려하여 러기 의견대로 스타일 적용 구조를 바꾸었습니다. 피드백 감사해요 👍

Copy link
Contributor

@seongjinme seongjinme Jan 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 그리고 툴팁은 사이드바 영역에 전부 새로 적용되어 있습니다. 버그도 모두 고쳐진 상태입니다 :)

Copy link
Contributor

@llqqssttyy llqqssttyy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

안녕하세요, 아르! 드디어 마지막 작업이었네요.
사이드바 리팩토링, Tooltip 컴포넌트 생성 확인했습니다. 제 환경에서는 버그도 없었어요.
아키텍처가 탄탄하고 변수명도 직관적이어서 술술 읽히는 코드였습니다.
이것이 아르 코어?

마지막 작업 고생 많으셨습니다. 출국하시기 전에 한번 뵙죠!
가족분들과 함께 따뜻하고 즐거운 설 연휴 보내시길 바랍니다. 새해 복 많이 받으세용.

@seongjinme seongjinme requested a review from lurgi January 28, 2025 10:46
Comment on lines +18 to +22
const style: React.CSSProperties = {
left: `${positionX}px`,
top: `${positionY}px`,
maxWidth: maxWidth ? `${maxWidth}px` : undefined,
};
Copy link
Contributor

@lurgi lurgi Jan 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

선언적으로 사용하셨군요 👍

@seongjinme seongjinme merged commit 8259f61 into fe/develop Jan 31, 2025
35 of 36 checks passed
@seongjinme seongjinme deleted the 985-fe-COMM_TOOLTIP_01 branch January 31, 2025 00:48
lurgi pushed a commit that referenced this pull request Feb 10, 2025
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Seongjin Hong <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 새로운 기능 frontend 프론트엔드
Projects
Status: 완료
Development

Successfully merging this pull request may close these issues.

3 participants