From 6e1d7926c3e46a99a9976446bcef286f23c5c578 Mon Sep 17 00:00:00 2001 From: Aman Harwara Date: Mon, 8 Jan 2024 14:29:15 +0530 Subject: [PATCH] refactor: toast --- packages/toast/src/Toast.tsx | 17 +++++++---------- packages/toast/src/types.ts | 1 + 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/packages/toast/src/Toast.tsx b/packages/toast/src/Toast.tsx index 8a7e8b0e4..7852b4435 100644 --- a/packages/toast/src/Toast.tsx +++ b/packages/toast/src/Toast.tsx @@ -1,5 +1,5 @@ import type { Toast as ToastPropType } from './types' -import { CheckCircleFilledIcon, ClearCircleFilledIcon } from '@standardnotes/icons' +import { CheckCircleFilledIcon, ClearCircleFilledIcon, InfoIcon } from '@standardnotes/icons' import { dismissToast } from './toastStore' import { ToastType } from './enums' import { ForwardedRef, forwardRef, RefObject, useEffect } from 'react' @@ -30,7 +30,7 @@ const iconForToastType = (type: ToastType) => { case ToastType.Loading: return
default: - return null + return } } @@ -90,15 +90,12 @@ export const Toast = forwardRef(({ toast, index }: Props, ref: ForwardedRef -
+
{icon ?
{icon}
: null} -
{toast.message}
+ {toast.title &&
{toast.title}
} +
{toast.message}
{hasActions && ( - <> +
{toast.actions?.map((action, index) => (
)}
{hasProgress && ( diff --git a/packages/toast/src/types.ts b/packages/toast/src/types.ts index 4eab143c3..da159f7be 100644 --- a/packages/toast/src/types.ts +++ b/packages/toast/src/types.ts @@ -7,6 +7,7 @@ export type ToastAction = { type CommonToastProperties = { type: ToastType + title?: string message: string actions?: ToastAction[] progress?: number