Skip to content

Commit 17daed1

Browse files
authored
Feat(client): tooltip component 구현 (#262)
* refactor: Tooltip 컴포넌트를 TooltipCard로 변경 * feat: Tooltip component 추가 * feat: Balloon 컴포넌트 추가 및 TooltipContent에 variant prop 추가 * feat: Tooltip 컴포넌트 삭제 * chore: 안쓰는 의존성 정리 * fix: ReactNode 타입 임포트 수정 * feat: 버튼에 type 속성 추가
1 parent 5225fbb commit 17daed1

File tree

8 files changed

+96
-6
lines changed

8 files changed

+96
-6
lines changed
Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
1+
import { Icon } from '@pinback/design-system/icons';
2+
import { Balloon } from '@shared/components/balloon/Balloon';
3+
14
const JobPins = () => {
2-
return <div>관심 직무 핀 페이지</div>;
5+
return (
6+
<div>
7+
{' '}
8+
<Balloon variant="main" side="bottom">
9+
<div className="text-lg font-semibold">치삐가 방금</div>
10+
11+
<div className="text-sm opacity-90">도토리 1개를 모았어요!</div>
12+
</Balloon>
13+
<Balloon variant="gray" side="left" onClose={() => alert('닫힘')}>
14+
<div className="text-lg font-semibold">치삐가 방금</div>
15+
16+
<div className="text-sm opacity-90">도토리 1개를 모았어요!</div>
17+
</Balloon>
18+
<Balloon variant="gray" side="left">
19+
<Icon name="ic_info" size={16} />
20+
<div className="text-sm opacity-90">도토리 1개를 모았어요!</div>
21+
</Balloon>
22+
<Balloon variant="main" side="bottom">
23+
<div className="flex items-center gap-3">
24+
{/* 캐릭터 이미지 */}
25+
<Icon name="chippi_profile" size={40} />
26+
27+
{/* 텍스트 영역 */}
28+
<div className="flex flex-col">
29+
<div className="text-[18px] font-semibold">치삐가 방금</div>
30+
<div className="text-[16px]">도토리 1개를 모았어요!</div>
31+
</div>
32+
</div>
33+
</Balloon>
34+
</div>
35+
);
336
};
437

538
export default JobPins;

apps/client/src/pages/login/Login.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const Login = () => {
3535
</p>
3636

3737
<button
38+
type="button"
3839
onClick={handleGoogleLogin}
3940
className="sub2-sb flex h-[5.2rem] w-[29.8rem] items-center justify-between gap-3 rounded-full border border-gray-100 bg-white px-[2rem]"
4041
>

apps/client/src/pages/myBookmark/MyBookmark.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
useDeleteRemindArticle,
1414
usePutArticleReadStatus,
1515
} from '@shared/apis/queries';
16-
import Tooltip from '@shared/components/tooltip/Tooltip';
16+
import TooltipCard from '@shared/components/tooltipCard/TooltipCard';
1717
import ArticlesLoadingBoundary from '@shared/components/articlesLoadingBoundary/ArticlesLoadingBoundary';
1818
import ArticlesErrorBoundary from '@shared/components/articlesErrorBoundary/ArticlesErrorBoundary';
1919
import { ErrorBoundary } from 'react-error-boundary';
@@ -87,7 +87,7 @@ const MyBookmark = () => {
8787
<p className="head3 text-main500">{category || ''}</p>
8888
</div>
8989

90-
<Tooltip />
90+
<TooltipCard />
9191

9292
<Suspense fallback={<ArticlesLoadingBoundary />}>
9393
<ErrorBoundary FallbackComponent={ArticlesErrorBoundary}>

apps/client/src/pages/onBoarding/components/funnel/step/SocialLoginStep.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const SocialLoginStep = () => {
3030
</p>
3131

3232
<button
33+
type="button"
3334
onClick={handleGoogleLogin}
3435
className="sub2-sb flex h-[5.2rem] w-[22.7rem] items-center justify-between gap-3 rounded-full border border-gray-100 bg-white px-[2rem]"
3536
>

apps/client/src/pages/remind/Remind.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { useQueryClient } from '@tanstack/react-query';
2222
import NoRemindArticles from './components/noRemindArticles/NoRemindArticles';
2323
import FetchCard from './components/fetchCard/FetchCard';
2424
import { useInfiniteScroll } from '@shared/hooks/useInfiniteScroll';
25-
import Tooltip from '@shared/components/tooltip/Tooltip';
25+
import TooltipCard from '@shared/components/tooltipCard/TooltipCard';
2626
import Footer from './components/footer/Footer';
2727

2828
const Remind = () => {
@@ -138,7 +138,7 @@ const Remind = () => {
138138
isActive={activeBadge === 'read'}
139139
/>
140140
</div>
141-
<Tooltip />
141+
<TooltipCard />
142142

143143
{articlesToDisplay.length > 0 ? (
144144
<div
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { Icon } from '@pinback/design-system/icons';
2+
import { cn } from '@pinback/design-system/utils';
3+
import { ReactNode } from 'react';
4+
5+
type BalloonVariant = 'gray' | 'main';
6+
7+
interface BalloonProps {
8+
variant?: BalloonVariant;
9+
side?: 'top' | 'bottom' | 'left' | 'right';
10+
onClose?: () => void;
11+
children: ReactNode;
12+
}
13+
14+
export function Balloon({
15+
variant = 'gray',
16+
side = 'bottom',
17+
onClose,
18+
children,
19+
}: BalloonProps) {
20+
const variantStyle = {
21+
gray: 'bg-gray900 text-white',
22+
main: 'bg-main500 text-white',
23+
};
24+
25+
return (
26+
<div className="relative inline-block">
27+
<div
28+
className={cn(
29+
'relative flex items-start gap-3 rounded-[4px] p-[1.2rem]',
30+
variantStyle[variant]
31+
)}
32+
>
33+
<div className="flex-1">{children}</div>
34+
35+
{onClose && (
36+
<button type="button" onClick={onClose}>
37+
<Icon name="ic_close" size={16} />
38+
</button>
39+
)}
40+
</div>
41+
42+
{/* 꼬리 */}
43+
<div
44+
className={cn(
45+
'absolute h-[12px] w-[12px] rotate-45',
46+
variantStyle[variant],
47+
side === 'bottom' && '-bottom-1 left-1/2 -translate-x-1/2',
48+
side === 'top' && '-top-1 left-1/2 -translate-x-1/2',
49+
side === 'left' && '-left-1 top-1/2 -translate-y-1/2',
50+
side === 'right' && '-right-1 top-1/2 -translate-y-1/2'
51+
)}
52+
/>
53+
</div>
54+
);
55+
}

apps/client/src/shared/components/tooltip/InfoCard.tsx renamed to apps/client/src/shared/components/tooltipCard/InfoCard.tsx

File renamed without changes.

apps/client/src/shared/components/tooltip/Tooltip.tsx renamed to apps/client/src/shared/components/tooltipCard/TooltipCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Icon } from '@pinback/design-system/icons';
22
import InfoCard from './InfoCard';
33

4-
export default function Tooltip() {
4+
export default function TooltipCard() {
55
return (
66
<div className="mt-[0.8rem] flex items-center">
77
<p className="body3-r text-font-gray-3">

0 commit comments

Comments
 (0)