-
Notifications
You must be signed in to change notification settings - Fork 1
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] 나의 과제 페이지 Tooltip, Popover 컴포넌트 구현 #49
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
ghdtjgus76 marked this conversation as resolved.
Show resolved
Hide resolved
|
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
p4;
해당 페이지 코드 보다가 든 생각인데, section 태그는 컴포넌트 내부에 숨기고 가장 외부 태그로 사용하면 더 좋을 거 같아요
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.
생각해보니 Header 부분에서도 스터디 기본 정보 api를 호출해서 title 을 얻어와야 해서 Header 컴포넌트로 분리해씁니다!
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.
이거 반영해주셨는데 페이지 부분에 section 태그가 남아있어서 그 부분만 반영 부탁드려요!