-
Notifications
You must be signed in to change notification settings - Fork 241
/
Copy pathSuspensionBox.tsx
93 lines (83 loc) · 1.82 KB
/
SuspensionBox.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import styled from "styled-components";
import { ReactComponent as close } from "icons/v1/icon-flokclose.svg";
import { ScrollBar } from "../components/ScrollBar";
const Container = styled.div<{ $width: number }>`
width: ${(props) => props.$width}px;
background: #ffffff;
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
border-radius: 8px;
box-sizing: border-box;
padding-bottom: 16px;
`;
const ChildDiv = styled.div`
display: flex;
flex-direction: column;
padding: 0 16px;
gap: 8px;
`;
const CloseIcon = styled(close)`
height: 16px;
width: 16px;
padding: 1px;
color: #8b8fa3;
&:hover {
cursor: pointer;
}
&:hover g {
stroke: #222222;
}
`;
const TitleDiv = styled.div`
height: 48px;
display: flex;
align-items: center;
padding: 0 16px;
justify-content: space-between;
`;
const TitleText = styled.span`
display: inline-block;
font-weight: 500;
font-size: 16px;
color: #222222;
line-height: 16px;
user-select: none;
`;
const FooterDiv = styled.div`
padding: 0 16px;
`;
interface Iprops {
title: string;
onClose?: () => void;
content: any;
width?: number;
contentMaxHeight?: string | number;
footer?: React.ReactNode;
scrollable?: boolean;
}
export const SuspensionBox = (props: Iprops) => {
const {
title,
onClose,
content,
footer,
width = 312,
contentMaxHeight = "calc(100vh - 100px)",
scrollable,
} = props;
return (
<Container $width={width}>
<TitleDiv>
<TitleText>{title}</TitleText>
{onClose && <CloseIcon onClick={onClose} />}
</TitleDiv>
{scrollable ? (
<ScrollBar style={{ maxHeight: contentMaxHeight }}>
<ChildDiv>{content}</ChildDiv>
</ScrollBar>
) : (
<ChildDiv>{content}</ChildDiv>
)}
<FooterDiv>{footer}</FooterDiv>
</Container>
);
};