You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
894 B
34 lines
894 B
import React, { FC, MouseEventHandler } from 'react'
|
|
import classNames from 'classnames'
|
|
|
|
import { notificationTypeToClassName } from 'src/utils'
|
|
import { NotificationType } from 'src/types'
|
|
|
|
interface Props {
|
|
id: string
|
|
type: NotificationType
|
|
auto: boolean
|
|
setAuto: (id: string) => void
|
|
dismiss: (id: string) => void
|
|
}
|
|
|
|
const Notification: FC<Props> = ({ id, type, auto, setAuto, dismiss, children }) => {
|
|
const classnames = classNames({
|
|
notification: true,
|
|
[notificationTypeToClassName(type)]: true,
|
|
})
|
|
|
|
const handleDismiss: MouseEventHandler = e => {
|
|
e.stopPropagation()
|
|
dismiss(id)
|
|
}
|
|
|
|
return (
|
|
<div className={classnames} onClick={() => setAuto(id)}>
|
|
{!auto && <button className="delete" onClick={handleDismiss}></button>}
|
|
{children}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default Notification
|