diff --git a/package.json b/package.json index 6437ffa8f..c072ea843 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "toast-component", "version": "0.1.0", "private": true, - "author": "Josh Comeau ", + "author": "Josh Comeau , Samuel Alvarez", "dependencies": { "eslint": "^8.49.0", "eslint-config-react-app": "^7.0.1", diff --git a/src/components/Toast/Toast.js b/src/components/Toast/Toast.js index 96af6012c..2cadb32c0 100644 --- a/src/components/Toast/Toast.js +++ b/src/components/Toast/Toast.js @@ -18,16 +18,16 @@ const ICONS_BY_VARIANT = { error: AlertOctagon, }; -function Toast() { +function Toast({ variant, handleDismiss, children }) { + const Tag = ICONS_BY_VARIANT[variant]; + return ( -
+
- +
-

- 16 photos have been uploaded -

- diff --git a/src/components/ToastPlayground/ToastPlayground.js b/src/components/ToastPlayground/ToastPlayground.js index e1c6c6eb2..293c68827 100644 --- a/src/components/ToastPlayground/ToastPlayground.js +++ b/src/components/ToastPlayground/ToastPlayground.js @@ -3,10 +3,19 @@ import React from 'react'; import Button from '../Button'; import styles from './ToastPlayground.module.css'; +import Toast from '../Toast/Toast'; const VARIANT_OPTIONS = ['notice', 'warning', 'success', 'error']; function ToastPlayground() { + const [value, setValue] = React.useState(''); + const [variant, setVariant] = React.useState(VARIANT_OPTIONS[0]); + const [isShowing, setIsShowing] = React.useState(false); + + const handleDismiss = () => { + setIsShowing(false); + }; + return (
@@ -14,7 +23,20 @@ function ToastPlayground() {

Toast Playground

-
+ {isShowing && ( + + {value} + + )} + +
{ + e.preventDefault(); + setValue(''); + setIsShowing(true); + }} + >