-
Notifications
You must be signed in to change notification settings - Fork 2
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 #184 from KNU-HAEDAL/Fix/challenge-record-#182
챌린지 인증 수정 #182
- Loading branch information
Showing
16 changed files
with
527 additions
and
278 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,34 @@ | ||
import { forwardRef } from 'react'; | ||
|
||
import styled from '@emotion/styled'; | ||
|
||
interface EmptyStateProps { | ||
children: React.ReactNode; | ||
} | ||
|
||
// ref를 전달하기 위해 forwardRef 사용 | ||
const EmptyState = forwardRef<HTMLDivElement, EmptyStateProps>( | ||
({ children }, ref) => { | ||
return <Wrapper ref={ref}>{children}</Wrapper>; | ||
} | ||
); | ||
|
||
EmptyState.displayName = 'EmptyState'; | ||
|
||
export default EmptyState; | ||
|
||
// 스타일 정의 | ||
const Wrapper = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
flex: 1; | ||
padding: 0 16px; | ||
font-size: var(--font-size-md); | ||
.highlight { | ||
font-weight: 600; | ||
color: var(--color-green-03); | ||
} | ||
`; |
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,157 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { IoCloseOutline } from 'react-icons/io5'; | ||
|
||
import styled from '@emotion/styled'; | ||
|
||
interface TooltipProps { | ||
content: string; | ||
children: React.ReactNode; | ||
direction?: 'top' | 'right' | 'bottom' | 'left'; | ||
} | ||
|
||
const Tooltip = ({ content, children, direction = 'top' }: TooltipProps) => { | ||
const [isVisible, setIsVisible] = useState(true); | ||
|
||
// 툴팁 자동 닫기 | ||
useEffect(() => { | ||
const timer = setTimeout(() => { | ||
setIsVisible(false); | ||
}, 5000); | ||
|
||
return () => clearTimeout(timer); // 컴포넌트 언마운트 시 타이머 정리 | ||
}, []); | ||
|
||
const handleClose = () => { | ||
setIsVisible(false); | ||
}; | ||
|
||
return ( | ||
<TooltipWrapper> | ||
{children} | ||
{isVisible && ( | ||
<TooltipBox direction={direction}> | ||
{content} | ||
<CloseButton onClick={handleClose}> | ||
<IoCloseOutline size='16px' /> | ||
</CloseButton> | ||
</TooltipBox> | ||
)} | ||
</TooltipWrapper> | ||
); | ||
}; | ||
|
||
export default Tooltip; | ||
|
||
// 스타일 정의 | ||
|
||
const TOOLTIP_COLOR = `var(--color-green-03)`; | ||
|
||
const TooltipWrapper = styled.div` | ||
position: relative; | ||
display: inline-block; | ||
`; | ||
|
||
const TooltipBox = styled.div<{ direction: string }>` | ||
position: absolute; | ||
padding: 3px 6px; | ||
border-radius: 4px; | ||
background-color: ${TOOLTIP_COLOR}; | ||
color: var(--color-white); | ||
font-size: 12px; | ||
font-weight: 500; | ||
white-space: nowrap; | ||
z-index: 10; | ||
display: flex; | ||
align-items: center; | ||
${({ direction }) => | ||
direction === 'top' && | ||
` | ||
bottom: 100%; | ||
left: 50%; | ||
transform: translateX(-50%); | ||
margin-bottom: 8px; | ||
`} | ||
${({ direction }) => | ||
direction === 'right' && | ||
` | ||
top: 50%; | ||
left: 100%; | ||
transform: translateY(-50%); | ||
margin-left: 8px; | ||
`} | ||
${({ direction }) => | ||
direction === 'bottom' && | ||
` | ||
top: 100%; | ||
left: 50%; | ||
transform: translateX(-50%); | ||
margin-top: 8px; | ||
`} | ||
${({ direction }) => | ||
direction === 'left' && | ||
` | ||
top: 50%; | ||
right: 100%; | ||
transform: translateY(-50%); | ||
margin-right: 8px; | ||
`} | ||
// 꼬리 부분 | ||
::after { | ||
content: ''; | ||
position: absolute; | ||
border-style: solid; | ||
${({ direction }) => | ||
direction === 'top' && | ||
` | ||
top: 100%; | ||
left: 50%; | ||
transform: translateX(-50%); | ||
border-width: 8px 6px 0 6px; | ||
border-color: ${TOOLTIP_COLOR} transparent transparent transparent; | ||
`} | ||
${({ direction }) => | ||
direction === 'right' && | ||
` | ||
top: 50%; | ||
left: 0; | ||
transform: translateY(-50%); | ||
border-width: 8px 6px 6px 0; | ||
border-color: transparent ${TOOLTIP_COLOR} transparent transparent; | ||
`} | ||
${({ direction }) => | ||
direction === 'bottom' && | ||
` | ||
bottom: 100%; | ||
left: 50%; | ||
transform: translateX(-50%); | ||
border-width: 0 6px 8px 6px; | ||
border-color: transparent transparent ${TOOLTIP_COLOR} transparent; | ||
`} | ||
${({ direction }) => | ||
direction === 'left' && | ||
` | ||
top: 50%; | ||
right: 0; | ||
transform: translateY(-50%); | ||
border-width: 6px 0 8px 6px; | ||
border-color: transparent transparent transparent ${TOOLTIP_COLOR}; | ||
`} | ||
} | ||
`; | ||
|
||
const CloseButton = styled.button` | ||
background: transparent; | ||
border: none; | ||
color: var(--color-white); | ||
cursor: pointer; | ||
margin-left: 6px; | ||
`; |
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
Oops, something went wrong.