From f659f4f0ff08da0526eacc35cce54596410bb62f Mon Sep 17 00:00:00 2001 From: tokiyskiygruz Date: Mon, 20 Nov 2023 09:31:52 +0200 Subject: [PATCH 1/6] Ex 1 && 2 --- src/components/Toast/Toast.js | 22 +++---- .../ToastPlayground/ToastPlayground.js | 63 ++++++++++++------- 2 files changed, 51 insertions(+), 34 deletions(-) diff --git a/src/components/Toast/Toast.js b/src/components/Toast/Toast.js index 96af6012..f2e0011e 100644 --- a/src/components/Toast/Toast.js +++ b/src/components/Toast/Toast.js @@ -1,15 +1,15 @@ -import React from 'react'; +import React from "react"; import { AlertOctagon, AlertTriangle, CheckCircle, Info, X, -} from 'react-feather'; +} from "react-feather"; -import VisuallyHidden from '../VisuallyHidden'; +import VisuallyHidden from "../VisuallyHidden"; -import styles from './Toast.module.css'; +import styles from "./Toast.module.css"; const ICONS_BY_VARIANT = { notice: Info, @@ -18,16 +18,16 @@ const ICONS_BY_VARIANT = { error: AlertOctagon, }; -function Toast() { +function Toast({ content, variant, handleDismiss }) { + const IconTag = 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 e1c6c6eb..229a2190 100644 --- a/src/components/ToastPlayground/ToastPlayground.js +++ b/src/components/ToastPlayground/ToastPlayground.js @@ -1,12 +1,17 @@ -import React from 'react'; +import React from "react"; -import Button from '../Button'; +import Button from "../Button"; +import Toast from "../Toast"; -import styles from './ToastPlayground.module.css'; +import styles from "./ToastPlayground.module.css"; -const VARIANT_OPTIONS = ['notice', 'warning', 'success', 'error']; +const VARIANT_OPTIONS = ["notice", "warning", "success", "error"]; function ToastPlayground() { + const [message, setMessage] = React.useState(""); + const [variant, setVariant] = React.useState("notice"); + const [isToastOpen, toogleIsToastOpen] = React.useState(false); + return (
@@ -14,45 +19,57 @@ function ToastPlayground() {

Toast Playground

+ {isToastOpen && ( + toogleIsToastOpen(false)} + variant={variant} + > + )} +
-