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

issue #144 design: move notification button to Header #145

Merged
merged 3 commits into from
Nov 25, 2023

Conversation

2Junsu
Copy link
Contributor

@2Junsu 2Junsu commented Oct 26, 2023

설명

테스트

Demo

2023-10-26.3.14.32.mov

@2Junsu 2Junsu added the enhancement New feature or request label Oct 26, 2023
@2Junsu 2Junsu requested review from kimyoungyin and sikkzz October 26, 2023 06:16
@2Junsu 2Junsu self-assigned this Oct 26, 2023
@2Junsu 2Junsu linked an issue Oct 26, 2023 that may be closed by this pull request
@sikkzz
Copy link
Contributor

sikkzz commented Nov 3, 2023

const handleDropdown = (e) => {
  const { target } = e;

  if (isProfileDropdownOpen && !profileRef.current.contains(target)) {
    setIsProfileDropdownOpen(false);
  }
};

const handleNotification = (e) => {
  const { target } = e;

  if (isNotiDropdownOpen && !notiRef.current.contains(target)) {
    setIsNotiDropdownOpen(false);
  }
};

useEffect(() => {
  window.addEventListener("click", handleDropdown);

  return () => {
    window.removeEventListener("click", handleDropdown);
  };
});

useEffect(() => {
  window.addEventListener("click", handleNotification);

  return () => {
    window.removeEventListener("click", handleNotification);
  };
});

<NotificationDiv>
  <NotificationButton
    ref={notiRef}
    onClick={() => {
      setIsNotiDropdownOpen(!isNotiDropdownOpen);
    }}
  >
    <NotificationIcon />
  </NotificationButton>
  {isNotiDropdownOpen && <NotificationDropdown />}
</NotificationDiv>

<ProfileDiv>
  <ProfileImg
    ref={profileRef}
    src="https://yt3.ggpht.com/ytc/AOPolaSlb8-cH_rN_lZDD1phXr7aHFpoOqMVoepaGuTm=s48-c-k-c0x00ffffff-no-rj"
    alt="user-profile"
    onClick={() => {
      setIsProfileDropdownOpen(!isProfileDropdownOpen);
    }}
  />
  {isProfileDropdownOpen && <ProfileDropdown />}
</ProfileDiv>

여기도 이렇게 작성하면 fowardRef랑 불필요 ref 제거하고 사용할 수 있을 거 같아요

kimyoungyin
kimyoungyin previously approved these changes Nov 16, 2023
sikkzz
sikkzz previously approved these changes Nov 17, 2023
@sikkzz sikkzz dismissed stale reviews from kimyoungyin and themself via 5104a00 November 25, 2023 11:23
@sikkzz sikkzz force-pushed the 144-front-task-알림탭-위치-변경 branch from 583cc32 to 5104a00 Compare November 25, 2023 11:23
@sikkzz sikkzz merged commit 3da8fad into develop Nov 25, 2023
1 check passed
@sikkzz sikkzz deleted the 144-front-task-알림탭-위치-변경 branch November 25, 2023 11:23
@sikkzz sikkzz restored the 144-front-task-알림탭-위치-변경 branch November 25, 2023 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FRONT-TASK] 알림탭 위치 변경
3 participants