-
Notifications
You must be signed in to change notification settings - Fork 293
Expand file tree
/
Copy pathSourceActionsNotify.tsx
More file actions
43 lines (38 loc) · 1.27 KB
/
SourceActionsNotify.tsx
File metadata and controls
43 lines (38 loc) · 1.27 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
import type { ReactElement } from 'react';
import React from 'react';
import { ButtonSize, ButtonVariant } from '../../buttons/common';
import { Button } from '../../buttons/Button';
import { BellAddIcon, BellSubscribedIcon } from '../../icons';
import { Tooltip } from '../../tooltip/Tooltip';
interface SourceActionsNotifyProps {
haveNotificationsOn: boolean;
onClick: (e: React.MouseEvent) => void;
disabled?: boolean;
size?: ButtonSize;
variant?: ButtonVariant;
className?: string;
}
const SourceActionsNotify = (props: SourceActionsNotifyProps): ReactElement => {
const { haveNotificationsOn, onClick, disabled, size, variant, className } =
props;
const icon = haveNotificationsOn ? <BellSubscribedIcon /> : <BellAddIcon />;
const label = `${haveNotificationsOn ? 'Disable' : 'Enable'} notifications`;
const buttonVariant =
variant ??
(haveNotificationsOn ? ButtonVariant.Subtle : ButtonVariant.Secondary);
return (
<Tooltip content={label}>
<Button
aria-label={label}
className={className}
icon={icon}
onClick={onClick}
size={size ?? ButtonSize.Small}
title={label}
variant={buttonVariant}
disabled={disabled}
/>
</Tooltip>
);
};
export default SourceActionsNotify;