Skip to content

Commit 6e1d792

Browse files
committed
refactor: toast
1 parent b7f8105 commit 6e1d792

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

packages/toast/src/Toast.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Toast as ToastPropType } from './types'
2-
import { CheckCircleFilledIcon, ClearCircleFilledIcon } from '@standardnotes/icons'
2+
import { CheckCircleFilledIcon, ClearCircleFilledIcon, InfoIcon } from '@standardnotes/icons'
33
import { dismissToast } from './toastStore'
44
import { ToastType } from './enums'
55
import { ForwardedRef, forwardRef, RefObject, useEffect } from 'react'
@@ -30,7 +30,7 @@ const iconForToastType = (type: ToastType) => {
3030
case ToastType.Loading:
3131
return <div className="border-info h-4 w-4 animate-spin rounded-full border border-solid border-r-transparent" />
3232
default:
33-
return null
33+
return <InfoIcon className="fill-text h-5 w-5" />
3434
}
3535
}
3636

@@ -90,15 +90,12 @@ export const Toast = forwardRef(({ toast, index }: Props, ref: ForwardedRef<HTML
9090
}}
9191
ref={ref}
9292
>
93-
<div
94-
className={`flex w-full flex-wrap items-center gap-2 ${
95-
hasActions ? 'p-2 pl-3' : hasProgress ? 'px-3 py-2.5' : 'p-3'
96-
}`}
97-
>
93+
<div className="grid gap-x-2.5 gap-y-1 overflow-hidden grid-cols-[1fr,auto] pl-3 pr-3.5 py-2.5">
9894
{icon ? <div className="sn-icon flex flex-shrink-0 items-center justify-center">{icon}</div> : null}
99-
<div className="text-text text-sm [word-wrap:anywhere]">{toast.message}</div>
95+
{toast.title && <div className="text-text text-sm font-semibold col-start-2">{toast.title}</div>}
96+
<div className="text-text text-sm [word-wrap:anywhere] col-start-2">{toast.message}</div>
10097
{hasActions && (
101-
<>
98+
<div className="col-start-2 -mx-1.5 -mb-0.5">
10299
{toast.actions?.map((action, index) => (
103100
<button
104101
className={`hover:bg-passive-3 cursor-pointer rounded border-0 px-[0.45rem] py-1 text-sm font-semibold md:bg-transparent ${colorForToastType(
@@ -114,7 +111,7 @@ export const Toast = forwardRef(({ toast, index }: Props, ref: ForwardedRef<HTML
114111
{action.label}
115112
</button>
116113
))}
117-
</>
114+
</div>
118115
)}
119116
</div>
120117
{hasProgress && (

packages/toast/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export type ToastAction = {
77

88
type CommonToastProperties = {
99
type: ToastType
10+
title?: string
1011
message: string
1112
actions?: ToastAction[]
1213
progress?: number

0 commit comments

Comments
 (0)