diff --git a/src/core/client/ui/components/CallOut/CallOut.css b/src/core/client/ui/components/CallOut/CallOut.css new file mode 100644 index 000000000..7a8c79b76 --- /dev/null +++ b/src/core/client/ui/components/CallOut/CallOut.css @@ -0,0 +1,35 @@ +.root { + composes: bodyCopy from "talk-ui/shared/typography.css"; + position: relative; + display: inline-flex; + justify-content: center; + align-items: center; + padding: 12px; + box-sizing: border-box; + border-width: 1px; + border-style: solid; +} + +.colorRegular { + background-color: var(--palette-grey-lightest); + border-color: var(--palette-grey-light); + color: var(--palette-text-primary); +} + +.colorPrimary { + background-color: var(--palette-primary-lightest); + border-color: var(--palette-primary-light); + color: var(--palette-text-primary); +} + +.colorError { + background-color: var(--palette-error-lightest); + border-color: var(--palette-error-light); + color: var(--palette-text-primary); +} + +.fullWidth { + display: block; + width: 100%; + box-sizing: border-box; +} diff --git a/src/core/client/ui/components/CallOut/CallOut.mdx b/src/core/client/ui/components/CallOut/CallOut.mdx new file mode 100644 index 000000000..b3977a56a --- /dev/null +++ b/src/core/client/ui/components/CallOut/CallOut.mdx @@ -0,0 +1,23 @@ +--- +name: CallOut +menu: UI Kit +--- + +import { Playground, PropsTable } from 'docz' +import CallOut from './CallOut' +import Flex from '../Flex' + +# CallOut + +## Basic Use + + + This is a component for a callout. Any text that you are wanting to draw attention to such as community guidelines, announcements, etc. can be placed in something like a callout box. The color of the callout box can be customized according your own needs. + This is a component for a callout. Any text that you are wanting to draw attention to such as community guidelines, announcements, etc. can be placed in something like a callout box. The color of the callout box can be customized according your own needs. + This is a component for a callout. Any text that you are wanting to draw attention to such as community guidelines, announcements, etc. can be placed in something like a callout box. The color of the callout box can be customized according your own needs. + The email address or password you entered is incorrect. Try again + The email address or password you entered is incorrect. Try again + + + + diff --git a/src/core/client/ui/components/CallOut/CallOut.spec.tsx b/src/core/client/ui/components/CallOut/CallOut.spec.tsx new file mode 100644 index 000000000..183e5acb5 --- /dev/null +++ b/src/core/client/ui/components/CallOut/CallOut.spec.tsx @@ -0,0 +1,16 @@ +import React from "react"; +import TestRenderer from "react-test-renderer"; + +import { PropTypesOf } from "talk-ui/types"; + +import CallOut from "./CallOut"; + +it("renders correctly", () => { + const props: PropTypesOf = { + className: "custom", + color: "error", + children: "Hello World", + }; + const renderer = TestRenderer.create(); + expect(renderer.toJSON()).toMatchSnapshot(); +}); diff --git a/src/core/client/ui/components/CallOut/CallOut.tsx b/src/core/client/ui/components/CallOut/CallOut.tsx new file mode 100644 index 000000000..df70af917 --- /dev/null +++ b/src/core/client/ui/components/CallOut/CallOut.tsx @@ -0,0 +1,57 @@ +import cn from "classnames"; +import React from "react"; +import { ReactNode, StatelessComponent } from "react"; +import { withStyles } from "talk-ui/hocs"; +import * as styles from "./CallOut.css"; + +export interface CallOutProps { + /** + * The content of the component. + */ + children: string | ReactNode; + /** + * Convenient prop to override the root styling. + */ + className?: string; + /** + * Override or extend the styles applied to the component. + */ + classes: typeof styles; + /** + * Color of the CallOut + */ + color?: "regular" | "primary" | "error"; + /* + * If set renders a full width CallOut + */ + fullWidth?: boolean; +} + +const CallOut: StatelessComponent = props => { + const { className, classes, color, fullWidth, children, ...rest } = props; + + const rootClassName = cn( + classes.root, + { + [classes.colorRegular]: color === "regular", + [classes.colorError]: color === "error", + [classes.colorPrimary]: color === "primary", + [classes.fullWidth]: fullWidth, + }, + className + ); + + return ( +
+ {children} +
+ ); +}; + +CallOut.defaultProps = { + color: "regular", + fullWidth: false, +}; + +const enhanced = withStyles(styles)(CallOut); +export default enhanced; diff --git a/src/core/client/ui/components/CallOut/__snapshots__/CallOut.spec.tsx.snap b/src/core/client/ui/components/CallOut/__snapshots__/CallOut.spec.tsx.snap new file mode 100644 index 000000000..1891d1d73 --- /dev/null +++ b/src/core/client/ui/components/CallOut/__snapshots__/CallOut.spec.tsx.snap @@ -0,0 +1,9 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`renders correctly 1`] = ` +
+ Hello World +
+`; diff --git a/src/core/client/ui/components/CallOut/index.ts b/src/core/client/ui/components/CallOut/index.ts new file mode 100644 index 000000000..189466420 --- /dev/null +++ b/src/core/client/ui/components/CallOut/index.ts @@ -0,0 +1 @@ +export { default } from "./CallOut"; diff --git a/src/core/client/ui/components/ValidationMessage/ValidationMessage.tsx b/src/core/client/ui/components/ValidationMessage/ValidationMessage.tsx index 704daee77..031735a2b 100644 --- a/src/core/client/ui/components/ValidationMessage/ValidationMessage.tsx +++ b/src/core/client/ui/components/ValidationMessage/ValidationMessage.tsx @@ -23,7 +23,7 @@ export interface ValidationMessageProps { */ color?: "regular" | "error"; /* - * If set renders a full width button + * If set renders a full width message */ fullWidth?: boolean; } diff --git a/src/core/client/ui/components/index.ts b/src/core/client/ui/components/index.ts index cd4601c52..dea7c4ec7 100644 --- a/src/core/client/ui/components/index.ts +++ b/src/core/client/ui/components/index.ts @@ -9,3 +9,4 @@ export { default as TrapFocus } from "./TrapFocus"; export { default as ValidationMessage } from "./ValidationMessage"; export { default as InputLabel } from "./InputLabel"; export { default as TextField } from "./TextField"; +export { default as CallOut } from "./CallOut";