@true-engineering/true-react-common-ui-kit 4.0.0-alpha67 → 4.0.0-alpha68
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/dist/components/Notification/Notification.d.ts +3 -3
- package/dist/true-react-common-ui-kit.js +4 -6
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/package.json +1 -1
- package/src/components/Notification/Notification.stories.tsx +3 -1
- package/src/components/Notification/Notification.tsx +9 -17
package/package.json
CHANGED
|
@@ -39,7 +39,9 @@ const meta: Meta<typeof Story> = {
|
|
|
39
39
|
shouldUseChildrenInstead: false,
|
|
40
40
|
},
|
|
41
41
|
argTypes: {
|
|
42
|
-
icon: { options: [undefined, ...Object.keys(iconsMap)], control: 'select' },
|
|
42
|
+
icon: { options: [undefined, null, ...Object.keys(iconsMap)], control: 'select' },
|
|
43
|
+
size: { options: ['s', 'm', 'l'], control: 'inline-radio' },
|
|
44
|
+
type: { options: ['info', 'error', 'warning', 'ok', 'not-ok', 'custom'], control: 'select' },
|
|
43
45
|
},
|
|
44
46
|
parameters: {
|
|
45
47
|
controls: {
|
|
@@ -3,11 +3,11 @@ import clsx from 'clsx';
|
|
|
3
3
|
import {
|
|
4
4
|
addDataAttributes,
|
|
5
5
|
addDataTestId,
|
|
6
|
+
isNotEmpty,
|
|
6
7
|
isReactNodeNotEmpty,
|
|
7
|
-
isStringNotEmpty,
|
|
8
8
|
} from '@true-engineering/true-react-platform-helpers';
|
|
9
9
|
import { ICommonProps } from '../../types';
|
|
10
|
-
import {
|
|
10
|
+
import { IIcon, renderIcon } from '../Icon';
|
|
11
11
|
import { INotificationType } from './types';
|
|
12
12
|
import { useStyles, INotificationStyles } from './Notification.styles';
|
|
13
13
|
|
|
@@ -15,11 +15,11 @@ export interface INotificationProps extends ICommonProps<INotificationStyles> {
|
|
|
15
15
|
type: INotificationType;
|
|
16
16
|
/** @default true */
|
|
17
17
|
isFullWidth?: boolean;
|
|
18
|
-
text?:
|
|
19
|
-
title?:
|
|
18
|
+
text?: ReactNode;
|
|
19
|
+
title?: ReactNode;
|
|
20
20
|
/** @default 's' */
|
|
21
21
|
size?: 's' | 'm' | 'l';
|
|
22
|
-
icon?: IIcon;
|
|
22
|
+
icon?: IIcon | null;
|
|
23
23
|
children?: ReactNode;
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -32,15 +32,13 @@ export const Notification: FC<INotificationProps> = ({
|
|
|
32
32
|
testId,
|
|
33
33
|
size = 's',
|
|
34
34
|
data,
|
|
35
|
-
icon,
|
|
35
|
+
icon = type !== 'custom' ? `status-${type}` : undefined,
|
|
36
36
|
tweakStyles,
|
|
37
37
|
}) => {
|
|
38
38
|
const classes = useStyles({ theme: tweakStyles });
|
|
39
39
|
|
|
40
|
-
const hasText =
|
|
41
|
-
const hasTitle =
|
|
42
|
-
const isDefaultType = type !== 'custom';
|
|
43
|
-
const hasIcon = isReactNodeNotEmpty(icon) || isDefaultType;
|
|
40
|
+
const hasText = isReactNodeNotEmpty(text);
|
|
41
|
+
const hasTitle = isReactNodeNotEmpty(title);
|
|
44
42
|
|
|
45
43
|
return (
|
|
46
44
|
<div
|
|
@@ -51,13 +49,7 @@ export const Notification: FC<INotificationProps> = ({
|
|
|
51
49
|
})}
|
|
52
50
|
{...addDataAttributes(data, testId)}
|
|
53
51
|
>
|
|
54
|
-
{
|
|
55
|
-
<div className={classes.icon}>
|
|
56
|
-
{isReactNodeNotEmpty(icon)
|
|
57
|
-
? renderIcon(icon)
|
|
58
|
-
: isDefaultType && <Icon type={`status-${type}`} />}
|
|
59
|
-
</div>
|
|
60
|
-
)}
|
|
52
|
+
{isNotEmpty(icon) && <div className={classes.icon}>{renderIcon(icon)}</div>}
|
|
61
53
|
<div className={classes.body}>
|
|
62
54
|
{hasTitle && (
|
|
63
55
|
<span className={classes.title} {...addDataTestId(testId, 'title')}>
|