Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions src/components/Notification/Notification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,11 @@ export const Notification = React.memo(function Notification(props: Props) {
) : null;

let renderedContent;
if (typeof content === 'function') {
if (content) {
const node = typeof content === 'function' ? content({wrapperRef}) : content;
renderedContent = (
<div className={b('content-wrapper')}>
<div className={b('content')}>{content({wrapperRef})}</div>
</div>
);
} else {
renderedContent = (
<div className={b('content-wrapper')}>
<div className={b('content')}>{content}</div>
<div className={b('content')}>{node}</div>
</div>
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Notification/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export type NotificationSwipeActionsProps =

export type NotificationProps = {
id: string;
content:
content?:
| React.ReactNode
| ((props: {wrapperRef?: React.RefObject<HTMLDivElement | null>}) => React.ReactNode);

Expand Down
12 changes: 12 additions & 0 deletions src/components/Notifications/__stories__/mockData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,18 @@ export const mockNotifications: NotificationProps[] = [
formattedDate: '12 seconds ago',
swipeActions: notificationsMockSwipeActions,
},
{
id: 'only-title',
source: {
title: 'Yandex',
icon: svgYandexStoryIcon,
href: LINK,
},
theme: 'info',
title: 'You hired!',
formattedDate: '12 seconds ago',
swipeActions: notificationsMockSwipeActions,
},
{
id: 'minimum',
content: <i>Bare minimum</i>,
Expand Down
Loading