-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
/
TooltipMessage.tsx
62 lines (53 loc) · 1.28 KB
/
TooltipMessage.tsx
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
56
57
58
59
60
61
62
import type { ReactNode } from 'react';
import React from 'react';
import { styled } from '@storybook/theming';
import { Link } from '../typography/link/link';
const Title = styled.div(({ theme }) => ({
fontWeight: theme.typography.weight.bold,
}));
const Desc = styled.span();
const Links = styled.div(({ theme }) => ({
marginTop: 8,
textAlign: 'center',
'> *': {
margin: '0 8px',
fontWeight: theme.typography.weight.bold,
},
}));
const Message = styled.div(({ theme }) => ({
color: theme.color.defaultText,
lineHeight: '18px',
}));
const MessageWrapper = styled.div({
padding: 15,
width: 280,
boxSizing: 'border-box',
});
export interface TooltipMessageProps {
title?: ReactNode;
desc?: ReactNode;
links?: {
title: string;
href?: string;
onClick?: () => void;
}[];
}
export const TooltipMessage = ({ title, desc, links }: TooltipMessageProps) => {
return (
<MessageWrapper>
<Message>
{title && <Title>{title}</Title>}
{desc && <Desc>{desc}</Desc>}
</Message>
{links && (
<Links>
{links.map(({ title: linkTitle, ...other }) => (
<Link {...other} key={linkTitle}>
{linkTitle}
</Link>
))}
</Links>
)}
</MessageWrapper>
);
};