diff --git a/src/components/index.js b/src/components/index.js index fe2ec843..9a911a52 100644 --- a/src/components/index.js +++ b/src/components/index.js @@ -14,6 +14,7 @@ export { default as PageTitle } from './ui/PageTitle'; export { default as Paragraph } from './ui/Paragraph'; export { default as Select } from './ui/Select'; export { default as SkipLink } from './ui/SkipLink'; +export { default as Snackbar } from './ui/Snackbar'; export { default as Tabs } from './ui/Tabs'; export { default as Tags } from './ui/Tags'; export { default as TextField } from './ui/TextField'; diff --git a/src/components/ui/Snackbar/README.md b/src/components/ui/Snackbar/README.md new file mode 100644 index 00000000..36baf2d2 --- /dev/null +++ b/src/components/ui/Snackbar/README.md @@ -0,0 +1,19 @@ +A snackbar is a non-disruptive message that appears to provide feedback to the user. + +```jsx +import { Button } from '@octopusthink/nautilus'; +
+
+ This just in: Scotland is rainy +
+
+ This just in: Scotland is rainy +
+
+ This just in: Scotland is rainy and sometimes it has some real long text strings too +
+
+ This just in: Scotland is rainy and sometimes it has some real long text strings too +
+
+``` diff --git a/src/components/ui/Snackbar/index.js b/src/components/ui/Snackbar/index.js new file mode 100644 index 00000000..4aaae08a --- /dev/null +++ b/src/components/ui/Snackbar/index.js @@ -0,0 +1,144 @@ +import { css } from '@emotion/react'; +import PropTypes from 'prop-types'; +import React from 'react'; +import { bodyStyles, toUnits } from '../../../styles'; +import { useTheme } from '../../../themes'; +import Button from '../Button'; +import Paragraph from '../Paragraph'; + +const Snackbar = (props) => { + const theme = useTheme(); + const { action, actionLabel, children, inverse, onDismiss, unstyled, ...otherProps } = props; + + return ( +
+ + {children} + + + {action && ( + + )} +
+ ); +}; + +Snackbar.defaultProps = { + action: undefined, + actionLabel: undefined, + children: undefined, + inverse: false, + onDismiss: undefined, + unstyled: false, +}; + +Snackbar.propTypes = { + /** Callback action to run when the action button is clicked. */ + action: PropTypes.func, + /** Label for the (optional) action button. */ + actionLabel: PropTypes.string, + /** @ignore */ + children: PropTypes.node, + /** Inverse container and text colour. Used for dark backgrounds. */ + inverse: PropTypes.bool, + /** Callback action to run when the Snackbar is dismissed */ + onDismiss: PropTypes.func, + /* @ignore Don't output any CSS styles. */ + unstyled: PropTypes.bool, +}; + +export default Snackbar; diff --git a/src/themes/nautilus/index.js b/src/themes/nautilus/index.js index e4c5feda..62530b4a 100644 --- a/src/themes/nautilus/index.js +++ b/src/themes/nautilus/index.js @@ -220,14 +220,23 @@ export const theme = { strokeWidth: 1.125, }, }, + }, - // TODO: implement these! - Tag: { - capitalization: 'uppercase', // uppercase, lowercase, sentence, title - colorPosition: 'background', // background or border - borderRadius: 0, - padding: 'toUnits(theme.spacing.padding.xSmall) toUnits(theme.spacing.padding.small)', - }, + // TODO: implement these! + Tag: { + capitalization: 'uppercase', // uppercase, lowercase, sentence, title + colorPosition: 'background', // background or border + borderRadius: 0, + padding: 'toUnits(theme.spacing.padding.xSmall) toUnits(theme.spacing.padding.small)', + }, + + Snackbar: { + backgroundColor: colors.black, + textColor: colors.grey100, + actionLinkColor: colors.pink100, + backgroundColorInverse: colors.grey100, + textColorInverse: colors.black, + actionLinkColorInverse: colors.grey900, }, },