@bitrise/bitkit 13.127.0 → 13.128.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,42 +1,61 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactNode, useState } from 'react';
|
|
2
|
+
import { useMultiStyleConfig, useStyleConfig } from '@chakra-ui/react';
|
|
3
|
+
import Icon, { TypeIconName } from '../../Components/Icon/Icon';
|
|
2
4
|
import { NOTIFICATION_STATUSES, NotificationProps } from '../../Components/Notification/Notification';
|
|
3
|
-
import Card from '../../Components/Card/Card';
|
|
4
|
-
import Box from '../../Components/Box/Box';
|
|
5
|
-
import Text from '../../Components/Text/Text';
|
|
6
|
-
import Button from '../../Components/Button/Button';
|
|
5
|
+
import Card, { CardProps } from '../../Components/Card/Card';
|
|
6
|
+
import Box, { BoxProps } from '../../Components/Box/Box';
|
|
7
|
+
import Text, { TextProps } from '../../Components/Text/Text';
|
|
8
|
+
import Button, { ButtonProps } from '../../Components/Button/Button';
|
|
9
|
+
import Collapse from '../../Components/Collapse/Collapse';
|
|
10
|
+
import Link from '../../Components/Link/Link';
|
|
7
11
|
|
|
8
12
|
export type ActionProps = {
|
|
9
13
|
href?: string;
|
|
10
14
|
label: string;
|
|
11
|
-
onClick?: () => void;
|
|
12
15
|
target?: string;
|
|
13
|
-
}
|
|
16
|
+
} & Omit<ButtonProps, 'as' | 'children' | 'size'>;
|
|
14
17
|
|
|
15
18
|
export type NotificationCardProps = {
|
|
16
19
|
action?: ActionProps;
|
|
17
|
-
message:
|
|
18
|
-
|
|
20
|
+
message: ReactNode;
|
|
21
|
+
details?: ReactNode;
|
|
19
22
|
title?: string;
|
|
20
|
-
}
|
|
23
|
+
} & (
|
|
24
|
+
| {
|
|
25
|
+
status: NotificationProps['status'];
|
|
26
|
+
statusIconName?: never;
|
|
27
|
+
}
|
|
28
|
+
| {
|
|
29
|
+
status: 'error';
|
|
30
|
+
statusIconName?: Extract<TypeIconName, 'ErrorCircleFilled' | 'CrossCircle'>;
|
|
31
|
+
}
|
|
32
|
+
);
|
|
21
33
|
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
34
|
+
const NotificationCard = ({
|
|
35
|
+
action,
|
|
36
|
+
details,
|
|
37
|
+
status,
|
|
38
|
+
statusIconName,
|
|
39
|
+
message: description,
|
|
40
|
+
title,
|
|
41
|
+
}: NotificationCardProps) => {
|
|
42
|
+
const [isDetailsOpen, setIsDetailsOpen] = useState(false);
|
|
31
43
|
const { colorScheme, defaultIcon } = NOTIFICATION_STATUSES[status || 'info'];
|
|
32
44
|
|
|
45
|
+
const statusIcon = statusIconName ? <Icon name={statusIconName} /> : defaultIcon;
|
|
46
|
+
|
|
33
47
|
const style = useMultiStyleConfig('NotificationCard', { colorScheme });
|
|
34
48
|
const { borderColor, bg, color } = style.card;
|
|
35
49
|
const { borderRadius } = useStyleConfig('Card', { colorScheme });
|
|
36
50
|
|
|
37
51
|
let actionButton;
|
|
38
52
|
if (action) {
|
|
39
|
-
|
|
53
|
+
const { href, label, ...restAction } = action;
|
|
54
|
+
actionButton = (
|
|
55
|
+
<Button variant="tertiary" {...restAction} as={(href ? 'a' : 'button') as any} href={href} size="md">
|
|
56
|
+
{label}
|
|
57
|
+
</Button>
|
|
58
|
+
);
|
|
40
59
|
}
|
|
41
60
|
|
|
42
61
|
return (
|
|
@@ -56,7 +75,7 @@ const NotificationCard = ({ action, status, message: description, title }: Notif
|
|
|
56
75
|
paddingBlock="12"
|
|
57
76
|
sx={style.icon}
|
|
58
77
|
>
|
|
59
|
-
{
|
|
78
|
+
{statusIcon}
|
|
60
79
|
</Box>
|
|
61
80
|
<Box
|
|
62
81
|
flex="1"
|
|
@@ -73,9 +92,26 @@ const NotificationCard = ({ action, status, message: description, title }: Notif
|
|
|
73
92
|
{title}
|
|
74
93
|
</Text>
|
|
75
94
|
)}
|
|
76
|
-
<
|
|
77
|
-
{description}
|
|
78
|
-
|
|
95
|
+
<Box textStyle="body/md/regular" color={title ? '' : (color as TextProps['color'])}>
|
|
96
|
+
<Text>{description}</Text>
|
|
97
|
+
{details && (
|
|
98
|
+
<>
|
|
99
|
+
<Collapse in={isDetailsOpen}>
|
|
100
|
+
<Box marginTop="8">{details}</Box>
|
|
101
|
+
</Collapse>
|
|
102
|
+
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
|
|
103
|
+
<Link
|
|
104
|
+
as="button"
|
|
105
|
+
colorScheme="purple"
|
|
106
|
+
display="block"
|
|
107
|
+
marginTop="8"
|
|
108
|
+
onClick={() => setIsDetailsOpen(!isDetailsOpen)}
|
|
109
|
+
>
|
|
110
|
+
{isDetailsOpen ? 'Hide details' : 'Show details'}{' '}
|
|
111
|
+
</Link>
|
|
112
|
+
</>
|
|
113
|
+
)}
|
|
114
|
+
</Box>
|
|
79
115
|
</Box>
|
|
80
116
|
{actionButton && <Box paddingBlock="4">{actionButton}</Box>}
|
|
81
117
|
</Box>
|