-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBalloon.tsx
More file actions
55 lines (49 loc) · 1.4 KB
/
Balloon.tsx
File metadata and controls
55 lines (49 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { Icon } from '@pinback/design-system/icons';
import { cn } from '@pinback/design-system/utils';
import { ReactNode } from 'react';
type BalloonVariant = 'gray' | 'main';
interface BalloonProps {
variant?: BalloonVariant;
side?: 'top' | 'bottom' | 'left' | 'right';
onClose?: () => void;
children: ReactNode;
}
export function Balloon({
variant = 'gray',
side = 'bottom',
onClose,
children,
}: BalloonProps) {
const variantStyle = {
gray: 'bg-gray900 text-white',
main: 'bg-main500 text-white',
};
return (
<div className="relative inline-block">
<div
className={cn(
'relative flex w-full items-start whitespace-nowrap rounded-[5.5px] px-[1.2rem] py-[0.8rem]',
variantStyle[variant]
)}
>
<div className="flex-1">{children}</div>
{onClose && (
<button type="button" onClick={onClose}>
<Icon name="ic_close" size={20} />
</button>
)}
</div>
{/* 꼬리 */}
<div
className={cn(
'absolute h-[12px] w-[12px] rotate-45',
variantStyle[variant],
side === 'bottom' && '-bottom-1 left-1/2 -translate-x-1/2',
side === 'top' && '-top-1 left-1/2 -translate-x-1/2',
side === 'left' && '-left-1 top-1/2 -translate-y-1/2',
side === 'right' && '-right-1 top-1/2 -translate-y-1/2'
)}
/>
</div>
);
}