-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #123 from softeerbootcamp4th/fix/103-ux-improve
[modify] 로그아웃 기능 추가, 자잘한 버그 수정, 접근성 개선
- Loading branch information
Showing
42 changed files
with
502 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { useEffect, useRef } from "react"; | ||
|
||
function getEndPointChild(element) { | ||
const focusableElements = [ | ||
...element.querySelectorAll( | ||
"a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, *[tabindex], *[contenteditable]", | ||
), | ||
].filter((elem) => elem.tabIndex >= 0); | ||
if (focusableElements.length === 0) return [null, null]; | ||
return [focusableElements[0], focusableElements[focusableElements.length - 1]]; | ||
} | ||
|
||
function useFocusTrap(active) { | ||
const prevRef = useRef(null); | ||
const ref = useRef(null); | ||
const endPointChild = useRef([null, null]); | ||
useEffect(() => { | ||
if (!active || ref.current === null) return; | ||
|
||
function renewEndPointChild() { | ||
if (ref.current === null) return; | ||
endPointChild.current = getEndPointChild(ref.current); | ||
} | ||
|
||
function handleTabKey(e) { | ||
if (e.key !== "Tab") return; | ||
|
||
const [first, last] = endPointChild.current; | ||
|
||
if (document.activeElement === prevRef.current) { | ||
if (e.shiftKey) last?.focus(); | ||
else first?.focus(); | ||
e.preventDefault(); | ||
return; | ||
} | ||
|
||
if (first === null || last === null) return; | ||
if (document.activeElement === last && !e.shiftKey) { | ||
first.focus(); | ||
e.preventDefault(); | ||
} else if (document.activeElement === first && e.shiftKey) { | ||
last.focus(); | ||
e.preventDefault(); | ||
} | ||
} | ||
|
||
renewEndPointChild(); | ||
prevRef.current = document.activeElement; | ||
document.addEventListener("keydown", handleTabKey); | ||
const config = { subtree: true, childList: true, attributeFilter: ["disabled", "tabindex"] }; | ||
const observer = new MutationObserver(renewEndPointChild); | ||
observer.observe(ref.current, config); | ||
|
||
return () => { | ||
document.removeEventListener("keydown", handleTabKey); | ||
observer.disconnect(); | ||
prevRef.current.focus(); | ||
}; | ||
}, [active]); | ||
|
||
return ref; | ||
} | ||
|
||
export default useFocusTrap; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/mainPage/features/comment/commentCarousel/CommentCarouselNoData.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
function CommentCarouselNoData() { | ||
return ( | ||
<div className="w-full h-[29rem] flex justify-center items-center px-6"> | ||
<div className="w-full max-w-[1200px] h-96 bg-neutral-50 flex flex-col justify-center items-center gap-4"> | ||
<img src="/icons/error.svg" alt="기대평 없음" width="120" height="120" /> | ||
<p className="text-body-l text-red-500 font-bold">기대평이 없어요!</p> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default CommentCarouselNoData; |
14 changes: 6 additions & 8 deletions
14
src/mainPage/features/comment/modals/CommentNegativeModal.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { useContext } from "react"; | ||
import { ModalCloseContext } from "@common/modal/modal.jsx"; | ||
import AlertModalContainer from "@main/components/AlertModalContainer.jsx"; | ||
import Button from "@common/components/Button.jsx"; | ||
import scrollTo from "@main/scroll/scrollTo.js"; | ||
import { INTERACTION_SECTION } from "@main/scroll/constants.js"; | ||
|
@@ -13,22 +14,19 @@ function CommentNoUserModal() { | |
} | ||
|
||
return ( | ||
<div className="w-[calc(100%-1rem)] max-w-[31.25rem] h-[calc(100svh-2rem)] max-h-[31.25rem] p-10 shadow bg-white relative flex flex-col justify-between items-center"> | ||
<div className="flex flex-col gap-2 items-center"> | ||
<p className="text-body-l font-bold text-neutral-700">아직 기대평을 작성할 수 없습니다.</p> | ||
<p className="w-full max-w-80 text-body-s font-medium text-neutral-400 text-center"> | ||
오늘의 추첨 이벤트에 참여하고 기대평을 작성하세요 | ||
</p> | ||
</div> | ||
<div className="absolute top-0 left-0 w-full h-full flex justify-center items-center pointer-events-none"> | ||
<AlertModalContainer | ||
title="아직 기대평을 작성할 수 없습니다." | ||
description="오늘의 추첨 이벤트에 참여하고 기대평을 작성하세요" | ||
image={ | ||
<img | ||
src="/icons/[email protected]" | ||
srcSet="/icons/[email protected] 1x, /icons/[email protected] 2x" | ||
alt="추첨 이벤트 참여 바랍니다" | ||
width="208" | ||
height="40" | ||
/> | ||
</div> | ||
} | ||
> | ||
<div className="w-full flex flex-wrap justify-center gap-5"> | ||
<Button styleType="filled" onClick={toMoveInteraction}> | ||
추첨 이벤트 참여하기 | ||
|
@@ -37,7 +35,7 @@ function CommentNoUserModal() { | |
닫기 | ||
</Button> | ||
</div> | ||
</div> | ||
</AlertModalContainer> | ||
); | ||
} | ||
|
||
|
12 changes: 7 additions & 5 deletions
12
src/mainPage/features/comment/modals/CommentSuccessModal.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,28 @@ | ||
import { useContext } from "react"; | ||
import { ModalCloseContext } from "@common/modal/modal.jsx"; | ||
import AlertModalContainer from "@main/components/AlertModalContainer.jsx"; | ||
import Button from "@common/components/Button.jsx"; | ||
|
||
function CommentSuccessModal() { | ||
const close = useContext(ModalCloseContext); | ||
|
||
return ( | ||
<div className="w-[calc(100%-1rem)] max-w-[31.25rem] h-[calc(100svh-2rem)] max-h-[31.25rem] p-10 shadow bg-white relative flex flex-col justify-between items-center"> | ||
<p className="text-body-l font-bold text-neutral-700">기대평이 등록되었습니다!</p> | ||
<div className="absolute top-0 left-0 w-full h-full flex justify-center items-center pointer-events-none"> | ||
<AlertModalContainer | ||
title="기대평이 등록되었습니다!" | ||
image={ | ||
<img | ||
src="/icons/[email protected]" | ||
srcSet="/icons/[email protected] 1x, /icons/[email protected] 2x" | ||
alt="기대평 등록 완료" | ||
width="173" | ||
height="182" | ||
/> | ||
</div> | ||
} | ||
> | ||
<Button styleType="ghost" onClick={close}> | ||
확인 | ||
</Button> | ||
</div> | ||
</AlertModalContainer> | ||
); | ||
} | ||
|
||
|
Oops, something went wrong.