Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Message component #120

Merged
merged 1 commit into from
May 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions packages/pancake-uikit/src/components/Message/Message.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from "react";
import styled from "styled-components";
import { variant as systemVariant, space } from "styled-system";
import { WarningIcon, ErrorIcon } from "../Svg";
import { MessageProps } from "./types";
import variants from "./theme";

const Icons = {
warning: WarningIcon,
danger: ErrorIcon,
};

const MessageContainer = styled.div<MessageProps>`
display: flex;
background-color: gray;
padding: 16px;
border-radius: 16px;
border: solid 1px;

${space}
${systemVariant({
variants,
})}
`;

const Message: React.FC<MessageProps> = ({ children, variant, ...props }) => {
const Icon = Icons[variant];
return (
<MessageContainer variant={variant} {...props}>
<Icon color={variants[variant].borderColor} width="24px" mr="12px" />
{children}
</MessageContainer>
);
};

export default Message;
29 changes: 29 additions & 0 deletions packages/pancake-uikit/src/components/Message/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from "react";
import Message from "./Message";

export default {
title: "Components/Message",
component: Message,
argTypes: {},
};

export const Default: React.FC = () => {
return (
<>
<Message variant="warning" mb="16px">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
laborum.
</Message>
<Message variant="danger">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
laborum.
</Message>
</>
);
};
2 changes: 2 additions & 0 deletions packages/pancake-uikit/src/components/Message/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as Mesage } from "./Message";
export type { MessageProps } from "./types";
12 changes: 12 additions & 0 deletions packages/pancake-uikit/src/components/Message/theme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const variants = {
warning: {
background: "#FFB23719",
borderColor: "warning",
},
danger: {
background: "#ED4B9E19",
borderColor: "failure",
},
};

export default variants;
12 changes: 12 additions & 0 deletions packages/pancake-uikit/src/components/Message/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { SpaceProps } from "styled-system";

export const variants = {
WARNING: "warning",
DANGER: "danger",
} as const;

export type Variant = typeof variants[keyof typeof variants];

export interface MessageProps extends SpaceProps {
variant: Variant;
}
1 change: 1 addition & 0 deletions packages/pancake-uikit/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export * from "./components/Image";
export * from "./components/Input";
export * from "./components/Layouts";
export * from "./components/Link";
export * from "./components/Message";
export * from "./components/NotificationDot";
export * from "./components/PancakeToggle";
export * from "./components/Progress";
Expand Down