From a35ee7909837d708e3b7edd6afe7fb55dd272365 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bel=C3=A9n=20Curcio?= Date: Tue, 11 Sep 2018 09:57:55 -0300 Subject: [PATCH] Adding MessageIcon --- .../client/ui/components/Message/Message.mdx | 3 +- .../client/ui/components/Message/Message.tsx | 19 +--------- .../ui/components/Message/MessageIcon.css | 5 +++ .../ui/components/Message/MessageIcon.tsx | 36 +++++++++++++++++++ 4 files changed, 44 insertions(+), 19 deletions(-) create mode 100644 src/core/client/ui/components/Message/MessageIcon.css create mode 100644 src/core/client/ui/components/Message/MessageIcon.tsx diff --git a/src/core/client/ui/components/Message/Message.mdx b/src/core/client/ui/components/Message/Message.mdx index 9a876d76c..828d18036 100644 --- a/src/core/client/ui/components/Message/Message.mdx +++ b/src/core/client/ui/components/Message/Message.mdx @@ -5,6 +5,7 @@ menu: UI Kit import { Playground } from 'docz' import Message from './Message' +import MessageIcon from './MessageIcon' import HorizontalGutter from '../HorizontalGutter' # Message @@ -20,7 +21,7 @@ import HorizontalGutter from '../HorizontalGutter' ## Usage with icon - Edit: 1 min 23 secs Remaining + alarmEdit: 1 min 23 secs Remaining diff --git a/src/core/client/ui/components/Message/Message.tsx b/src/core/client/ui/components/Message/Message.tsx index 258174288..c3f4ea2e8 100644 --- a/src/core/client/ui/components/Message/Message.tsx +++ b/src/core/client/ui/components/Message/Message.tsx @@ -24,25 +24,13 @@ export interface MessageProps { */ fullWidth?: boolean; /* - * Name of the icon, render if provided - */ - icon?: string; - /* * Name of color, "grey" stays by default - common gray one */ color?: "error" | "grey"; } const Message: StatelessComponent = props => { - const { - className, - classes, - fullWidth, - children, - icon, - color, - ...rest - } = props; + const { className, classes, fullWidth, children, color, ...rest } = props; const rootClassName = cn( classes.root, @@ -56,11 +44,6 @@ const Message: StatelessComponent = props => { return (
- {icon && ( - - {icon} - - )} {children}
); diff --git a/src/core/client/ui/components/Message/MessageIcon.css b/src/core/client/ui/components/Message/MessageIcon.css new file mode 100644 index 000000000..df730b2de --- /dev/null +++ b/src/core/client/ui/components/Message/MessageIcon.css @@ -0,0 +1,5 @@ +.root { + &:first-child { + margin-right: calc(0.5 * var(--spacing-unit)); + } +} diff --git a/src/core/client/ui/components/Message/MessageIcon.tsx b/src/core/client/ui/components/Message/MessageIcon.tsx new file mode 100644 index 000000000..cd4d0ad13 --- /dev/null +++ b/src/core/client/ui/components/Message/MessageIcon.tsx @@ -0,0 +1,36 @@ +import cn from "classnames"; +import React, { HTMLAttributes, Ref, StatelessComponent } from "react"; + +import Icon, { IconProps } from "talk-ui/components/Icon"; +import { withForwardRef, withStyles } from "talk-ui/hocs"; + +import * as styles from "./MessageIcon.css"; + +interface InnerProps extends HTMLAttributes { + /** + * This prop can be used to add custom classnames. + * It is handled by the `withStyles `HOC. + */ + classes: typeof styles & IconProps["classes"]; + + size?: IconProps["size"]; + + /** The name of the icon to render */ + children: string; + + /** Internal: Forwarded Ref */ + forwardRef?: Ref; +} + +export const MessageIcon: StatelessComponent = props => { + const { classes, className, forwardRef, ...rest } = props; + const rootClassName = cn(classes.root, className); + return ; +}; + +MessageIcon.defaultProps = { + size: "sm", +}; + +const enhanced = withForwardRef(withStyles(styles)(MessageIcon)); +export default enhanced;