-
Notifications
You must be signed in to change notification settings - Fork 41
/
MessageBox.tsx
39 lines (35 loc) · 1.21 KB
/
MessageBox.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
import { AlertProps, Box, Text } from '@chakra-ui/react'
import ExclaimationTriangle from '@/icons/misc/ExclaimationTriangle'
import { colors } from '@/theme/cssVariables'
export interface MessageBoxProps extends AlertProps {
title?: string
status?: 'warning' | 'error' | 'info'
icon?: React.ReactNode
children?: React.ReactNode
}
export default function MessageBox({ title, status = 'info', icon, children, ...rest }: MessageBoxProps) {
const customColor =
status === 'error'
? {
mainColor: colors.semanticError,
bg: 'rgba(255, 78, 163, 0.1)'
}
: status === 'warning'
? {
mainColor: colors.semanticWarning,
bg: 'rgba(254, 211, 58, 0.1)'
}
: {
mainColor: colors.semanticNeutral,
bg: 'rgba(171, 196, 255, 0.07)'
}
return (
<Box display="flex" bg={customColor.bg} px="18px" py={3} borderRadius="8px" color={customColor.mainColor} {...rest}>
<Box mr={3}>{icon ?? <ExclaimationTriangle />}</Box>
<Box display="flex" flexDirection="column" justifyContent="start">
{title && <Text>{title}</Text>}
{children && <Box mt={title ? 3 : 0}>{children}</Box>}
</Box>
</Box>
)
}