-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBaseNotification.tsx
More file actions
45 lines (39 loc) · 1.43 KB
/
BaseNotification.tsx
File metadata and controls
45 lines (39 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import React from 'react';
import { CheckCircleFilled, ExclamationCircleFilled, InfoCircleFilled, WarningFilled } from '@ant-design/icons';
import * as S from './BaseNotification.styles';
import { BaseSpace } from '../BaseSpace/BaseSpace';
interface Icons {
info: React.ReactNode;
success: React.ReactNode;
warning: React.ReactNode;
error: React.ReactNode;
mention: React.ReactNode;
moderation: React.ReactNode;
}
export type NotificationType = 'info' | 'mention' | 'success' | 'warning' | 'error' | 'moderation';
interface BaseNotificationProps {
type: NotificationType;
title: React.ReactNode;
description?: React.ReactNode;
mentionIconSrc?: React.ReactNode;
}
export const BaseNotification: React.FC<BaseNotificationProps> = ({ type, mentionIconSrc, title, description }) => {
const icons: Icons = {
info: <InfoCircleFilled />,
success: <CheckCircleFilled />,
warning: <ExclamationCircleFilled />,
error: <WarningFilled />,
mention: mentionIconSrc,
moderation: <WarningFilled />, // Using the same icon as error for moderation
};
const icon = icons[type] || icons.warning;
return (
<S.SpaceWrapper type={type} align="start" size="middle">
{mentionIconSrc ? <S.NotificationIcon src={icon} alt="User icon" /> : icon}
<BaseSpace direction="vertical">
<S.Title>{title}</S.Title>
<S.Description>{description}</S.Description>
</BaseSpace>
</S.SpaceWrapper>
);
};