-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feat] 나의 과제 페이지 Tooltip, Popover 컴포넌트 구현 (#49)
- Loading branch information
Showing
16 changed files
with
327 additions
and
62 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
69 changes: 69 additions & 0 deletions
69
...tudy/my-assignment/_components/AssignmentContent/AssignmentOverviewBox/FailurePopover.tsx
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,69 @@ | ||
import { Flex } from "@styled-system/jsx"; | ||
import { Text } from "@wow-class/ui"; | ||
import Popover from "components/Popover"; | ||
import type { SubmissionFailureType } from "types/entities/common/assignment"; | ||
import { Help as HelpIcon } from "wowds-icons"; | ||
|
||
interface FailurePopoverProps { | ||
submissionFailureType: SubmissionFailureType; | ||
} | ||
export const FailurePopover = ({ | ||
submissionFailureType, | ||
}: FailurePopoverProps) => { | ||
if ( | ||
submissionFailureType === "NONE" || | ||
submissionFailureType === "NOT_SUBMITTED" | ||
) | ||
return null; | ||
return ( | ||
<Popover | ||
triggerContent={<HelpIcon fill="sub" stroke="sub" style={iconStyle} />} | ||
> | ||
<Flex direction="column" gap="xs"> | ||
<Text color="textWhite" typo="body3"> | ||
{submissionFailureType === "WORD_COUNT_INSUFFICIENT" && | ||
"Q. 글자수가 부족하다고 나와요."} | ||
{submissionFailureType === "LOCATION_UNIDENTIFIABLE" && | ||
'Q. "위치 확인 불가" 라고 나와요.'} | ||
</Text> | ||
<Text as="div" color="outline" typo="body3"> | ||
{submissionFailureType === "LOCATION_UNIDENTIFIABLE" && ( | ||
<> | ||
아래 조건에 맞게 WIL.md 파일을 제출했는지 확인해주세요. <br /> | ||
<br /> | ||
<ul style={ulStyle}> | ||
<li>본인의 레포지터리가 맞는지</li> | ||
<li>제출한 브랜치 이름이 main인지</li> | ||
<li>파일 위치가 `WeekN/WIL.md` 가 맞는지</li> | ||
<li>파일 위치가 `WeekN/WIL.md` 가 맞는지</li> | ||
</ul> | ||
<br /> | ||
<br /> | ||
커밋 후 원격 저장소에 push까지 완료했는지 제대로 제출한 후에도 | ||
계속 "경로 확인 불가"라고 나온다면,GDSC Hongik 카카오톡 채널로 | ||
문의해주세요. | ||
</> | ||
)} | ||
{submissionFailureType === "WORD_COUNT_INSUFFICIENT" && ( | ||
<p> | ||
WIL.md 파일에 배운 내용을 최소 300자 이상 작성해야 해요. <br /> | ||
<br /> | ||
제대로 제출한 후에도 계속 글자수가 부족하다고 나온다면, | ||
<br /> | ||
GDSC Hongik 카카오톡 채널로 문의해주세요. | ||
</p> | ||
)} | ||
</Text> | ||
</Flex> | ||
</Popover> | ||
); | ||
}; | ||
|
||
const iconStyle = { | ||
cursor: "pointer", | ||
}; | ||
|
||
const ulStyle = { | ||
listStyleType: "disc", | ||
paddingLeft: "15px", | ||
}; |
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 |
---|---|---|
|
@@ -51,5 +51,6 @@ const textButtonstyle = { | |
|
||
const boxStyle = { | ||
minWidth: "484px", | ||
width: "484px", | ||
height: "fit-content", | ||
}; |
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
38 changes: 38 additions & 0 deletions
38
apps/client/app/(afterLogin)/my-study/my-assignment/_components/AssignmentDescription.tsx
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,38 @@ | ||
import { css } from "@styled-system/css"; | ||
import { studyDetailApi } from "apis/studyDetailApi"; | ||
import Tooltip from "components/Tooltip"; | ||
import { studyDashBoardData } from "constants/assignmentMockData"; | ||
import Link from "next/link"; | ||
|
||
export const AssignmentDescription = async () => { | ||
//const studyDashboard = await studyDetailApi.getStudyDetailDashboard(1); | ||
|
||
const studyDashboard = studyDashBoardData; | ||
return ( | ||
<p> | ||
제출 완료하기 버튼을 누르면 등록한{" "} | ||
{studyDashboard.isLinkEditable ? ( | ||
<span className={githubTextStyle}>GitHub 레포지토리</span> | ||
) : ( | ||
<Tooltip | ||
content={ | ||
<Link href="https://github.com/123456789012345678" target="_blank"> | ||
https://github.com/123456789012345678 | ||
</Link> | ||
} | ||
> | ||
<span className={githubTextStyle}>GitHub 레포지토리</span> | ||
</Tooltip> | ||
)} | ||
의 main 브랜치에서 가장 최신 상태의 WIL.md 파일이 제출돼요. <br /> | ||
과제는 기한 내에 여러 번 제출할 수 있으나, 가장 마지막 제출만 최종 제출로 | ||
인정해요. | ||
</p> | ||
); | ||
}; | ||
|
||
const githubTextStyle = css({ | ||
color: "blueHover", | ||
cursor: "pointer", | ||
textDecoration: "underline", | ||
}); |
18 changes: 18 additions & 0 deletions
18
apps/client/app/(afterLogin)/my-study/my-assignment/_components/AssignmentHeader.tsx
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,18 @@ | ||
import { Flex, styled } from "@styled-system/jsx"; | ||
import Image from "next/image"; | ||
|
||
export const AssignmentHeader = () => { | ||
//TODO: 스터디 정보 연결, 내가 수강 중인 스터디 api 호출 | ||
//const studyId = await myStudyApi.getMyOngoingStudyInfo() | ||
//const { title } = await myStudyApi.getBasicStudyInfo(studyId) | ||
|
||
return ( | ||
<header> | ||
<Flex gap="sm" textStyle="h1"> | ||
<styled.h1 color="textBlack">나의 과제</styled.h1> | ||
<Image alt="dot" height={6} src="/images/dot.svg" width={6} /> | ||
<styled.h1 color="primary">기초 웹 스터디</styled.h1> | ||
</Flex> | ||
</header> | ||
); | ||
}; |
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
29 changes: 6 additions & 23 deletions
29
apps/client/app/(afterLogin)/my-study/my-assignment/page.tsx
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,75 @@ | ||
"use client"; | ||
|
||
import { css } from "@styled-system/css"; | ||
import { useClickOutside, useOpenState } from "@wow-class/ui/hooks"; | ||
import type { PropsWithChildren, ReactNode } from "react"; | ||
import { Close as CloseIcon } from "wowds-icons"; | ||
|
||
interface PopoverProps extends PropsWithChildren { | ||
triggerContent: ReactNode; | ||
} | ||
|
||
const Popover = ({ triggerContent, children }: PopoverProps) => { | ||
const { open, setOpen, onClose } = useOpenState(); | ||
|
||
const popoverRef = useClickOutside<HTMLDivElement>(onClose); | ||
|
||
const handleClickTrigger = () => { | ||
setOpen((prev) => !prev); | ||
}; | ||
const handleClickCloseButton = () => { | ||
onClose(); | ||
}; | ||
return ( | ||
<div className={popoverContainerStyle}> | ||
<button className={triggerStyle} onClick={handleClickTrigger}> | ||
{triggerContent} | ||
</button> | ||
{open && ( | ||
<div className={popoverStyle} id="popover" ref={popoverRef}> | ||
<CloseIcon | ||
className={closeButtonStyle} | ||
height={14} | ||
stroke="white" | ||
width={14} | ||
onClick={handleClickCloseButton} | ||
/> | ||
|
||
{children} | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default Popover; | ||
|
||
const popoverContainerStyle = css({ | ||
position: "relative", | ||
display: "inline-block", | ||
}); | ||
|
||
const popoverStyle = css({ | ||
position: "absolute", | ||
width: "344px", | ||
top: "100%", | ||
left: 0, | ||
transform: "translateY(8px)", | ||
borderRadius: "md", | ||
backgroundColor: "rgba(0,0,0,0.6)", | ||
zIndex: 10000, | ||
paddingX: "md", | ||
paddingY: "sm", | ||
boxShadow: "mono", | ||
backdropFilter: "blur(15px)", | ||
}); | ||
|
||
const triggerStyle = css({ | ||
display: "flex", | ||
}); | ||
const closeButtonStyle = css({ | ||
position: "absolute", | ||
top: "sm", | ||
right: "md", | ||
cursor: "pointer", | ||
}); |
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,53 @@ | ||
"use client"; | ||
|
||
import { css } from "@styled-system/css"; | ||
import { useOpenState } from "@wow-class/ui/hooks"; | ||
import type { PropsWithChildren, ReactNode } from "react"; | ||
|
||
interface TooltipProps extends PropsWithChildren { | ||
content: ReactNode; | ||
} | ||
|
||
const Tooltip = ({ content, children }: TooltipProps) => { | ||
const { open, onOpen, onClose } = useOpenState(); | ||
|
||
const handleMouseEnter = () => { | ||
onOpen(); | ||
}; | ||
|
||
const handleMouseLeave = () => { | ||
onClose(); | ||
}; | ||
|
||
return ( | ||
<span | ||
className={tooltipContainerStyle} | ||
onMouseEnter={handleMouseEnter} | ||
onMouseLeave={handleMouseLeave} | ||
> | ||
{children} | ||
{open && <span className={tooltipStyle}>{content}</span>} | ||
</span> | ||
); | ||
}; | ||
|
||
export default Tooltip; | ||
|
||
const tooltipContainerStyle = css({ | ||
position: "relative", | ||
display: "inline-block", | ||
}); | ||
|
||
const tooltipStyle = css({ | ||
position: "absolute", | ||
top: "100%", | ||
left: 0, | ||
borderRadius: "md", | ||
backgroundColor: "rgba(0,0,0,0.6)", | ||
zIndex: 10000, | ||
paddingX: "md", | ||
paddingY: "sm", | ||
boxShadow: "mono", | ||
backdropFilter: "blur(15px)", | ||
color: "textWhite", | ||
}); |
Oops, something went wrong.