11import { observer } from 'mobx-react-lite'
22import type { FC } from 'react'
33import { useRef } from 'react'
4+ import { toast } from 'react-toastify'
45
56import { Avatar } from '@mx-space/kami-design/components/Avatar'
67
8+ import { HumbleiconsTimes } from '~/../packages/kami-design/components/Icons'
79import { ImpressionView } from '~/components/biz/ImpressionView'
810import { RelativeTime } from '~/components/universal/RelativeTime'
911import { useInitialData } from '~/hooks/use-initial-data'
@@ -15,6 +17,8 @@ export const ToastCard: FC<{
1517 description ?: string
1618 text ?: string
1719 avatar ?: string
20+ onClick ?: ( e : MouseEvent ) => void
21+ getToastId ?: ( ) => string
1822} > = observer ( ( props ) => {
1923 const { userStore, appStore } = store
2024 const isPadOrMobile = appStore . isPadOrMobile
@@ -26,6 +30,7 @@ export const ToastCard: FC<{
2630 trackerMessage = { `Toast 曝光 - ${ title } · ${ description } · ${ text } ` }
2731 >
2832 < div
33+ onClick = { ( e ) => props . onClick ?.( e . nativeEvent ) }
2934 className = "relative flex space-x-4 items-center p-4 w-full text-[12px] bg-bg-opacity overflow-hidden
3035 text-inherit border border-shallow border-opacity-50
3136 rounded-xl backdrop-filter backdrop-brightness-150 backdrop-brightness-110 backdrop-saturate-150 backdrop-blur-md
@@ -34,6 +39,17 @@ export const ToastCard: FC<{
3439 width : isPadOrMobile ? 'calc(100% - 16px - 16px)' : '350px' ,
3540 } }
3641 >
42+ < div
43+ role = { 'button' }
44+ tabIndex = { 0 }
45+ className = "flex items-center justify-center absolute z-10 top-2 left-2 h-4 w-4 rounded-full overflow-hidden bg-gray-6 bg-opacity-80 dark:bg-dark-100 text-dark-50 dark:text-white"
46+ onClick = { ( e ) => {
47+ e . stopPropagation ( )
48+ props . getToastId && toast . dismiss ( props . getToastId ( ) )
49+ } }
50+ >
51+ < HumbleiconsTimes />
52+ </ div >
3753 < div className = "flex-shrink-0" >
3854 < Avatar
3955 useRandomColor = { false }
0 commit comments