|
| 1 | +import React, { FunctionComponent } from "react"; |
| 2 | +import styled, { css } from "styled-components"; |
| 3 | +import theme from "../../theme"; |
| 4 | +import { Icon } from "../icon"; |
| 5 | + |
| 6 | +type MessageProps = { |
| 7 | + image?: string; |
| 8 | + status?: "success" | "notification" | "danger"; |
| 9 | + children?: React.ReactNode; |
| 10 | +}; |
| 11 | + |
| 12 | +export const MessageWrapper = styled.div<MessageProps>` |
| 13 | + display:flex; |
| 14 | + align-items:center; |
| 15 | + border-radius: ${theme.radiusDefault}; |
| 16 | + color: ${theme.colors.white}; |
| 17 | + font-size: ${theme.fontSizes.regular}; |
| 18 | + padding: ${theme.spacing.spacing03}; |
| 19 | + line-height:1.5rem; |
| 20 | + |
| 21 | + ${({ status }) => |
| 22 | + status === "success" && |
| 23 | + css` |
| 24 | + background: ${theme.colors.success}; |
| 25 | + `} |
| 26 | + ${({ status }) => |
| 27 | + status === "danger" && |
| 28 | + css` |
| 29 | + background: ${theme.colors.danger}; |
| 30 | + `} |
| 31 | + ${({ status }) => |
| 32 | + status === "notification" && |
| 33 | + css` |
| 34 | + background: ${theme.colors.notification}; |
| 35 | + `} |
| 36 | +`; |
| 37 | + |
| 38 | +export const IconBox = styled.div<MessageProps>` |
| 39 | + display:flex; |
| 40 | + align-items:center; |
| 41 | + border-radius: ${theme.radiusDefault}; |
| 42 | + padding: ${theme.spacing.spacing02}; |
| 43 | + margin-right: ${theme.spacing.spacing03}; |
| 44 | +
|
| 45 | + ${({ status }) => |
| 46 | + status === "success" && |
| 47 | + css` |
| 48 | + background: rgba(30, 132, 73, 0.5); |
| 49 | + `} |
| 50 | + ${({ status }) => |
| 51 | + status === "danger" && |
| 52 | + css` |
| 53 | + background: rgba(176, 58, 46, 0.5); |
| 54 | + `} |
| 55 | + ${({ status }) => |
| 56 | + status === "notification" && |
| 57 | + css` |
| 58 | + background: rgba(40, 116, 166, 0.5); |
| 59 | + `} |
| 60 | +`; |
| 61 | + |
| 62 | +export const Align = styled.div` |
| 63 | + margin-bottom:auto; |
| 64 | +`; |
| 65 | + |
| 66 | +export const Message: FunctionComponent<MessageProps> = ({ |
| 67 | + children, |
| 68 | + image, |
| 69 | + status |
| 70 | +}) => |
| 71 | + <MessageWrapper status={status}> |
| 72 | + <Align> |
| 73 | + <IconBox status={status}> |
| 74 | + <Icon image={image} width="1.5rem" height="1.5rem"/> |
| 75 | + </IconBox> |
| 76 | + </Align> |
| 77 | + {children} |
| 78 | + </MessageWrapper>; |
0 commit comments