Skip to content

Commit f681659

Browse files
authored
Merge branch 'main' into fix-gallery-video-url
2 parents d5f4f03 + 6b94407 commit f681659

File tree

6 files changed

+102
-9
lines changed

6 files changed

+102
-9
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## [4.3.0](https://github.com/gravity-ui/components/compare/v4.2.2...v4.3.0) (2025-05-16)
4+
5+
6+
### Features
7+
8+
* **Notifications:** add the renderCustomHeader prop ([b7ddd4b](https://github.com/gravity-ui/components/commit/b7ddd4b1c031d086a73b0752007bf719ce65480c))
9+
310
## [4.2.2](https://github.com/gravity-ui/components/compare/v4.2.1...v4.2.2) (2025-05-06)
411

512

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@gravity-ui/components",
3-
"version": "4.2.2",
3+
"version": "4.3.0",
44
"description": "",
55
"license": "MIT",
66
"type": "commonjs",

src/components/Notifications/Notifications.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,18 @@ export const Notifications = React.memo(function Notifications(props: Notificati
5353
);
5454
}
5555

56+
const title = <div className={b('head-title')}>{props.title || i18n('title')}</div>;
57+
5658
return (
5759
<div className={b()} data-qa={props.qa}>
58-
<div className={b('head')}>
59-
<div className={b('head-title')}>{props.title || i18n('title')}</div>
60-
{<div className={b('actions')}>{props.actions}</div>}
61-
</div>
60+
{props.renderCustomHeader ? (
61+
props.renderCustomHeader({title})
62+
) : (
63+
<div className={b('head')}>
64+
{title}
65+
<div className={b('actions')}>{props.actions}</div>
66+
</div>
67+
)}
6268
<div className={b('body')}>{content}</div>
6369
</div>
6470
);

src/components/Notifications/__stories__/Notifications.stories.tsx

Lines changed: 80 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
import * as React from 'react';
22

3-
import {Bell} from '@gravity-ui/icons';
4-
import {Button, Checkbox, Flex, Icon, Popup, SegmentedRadioGroup, Text} from '@gravity-ui/uikit';
3+
import {Bell, Funnel, Gear} from '@gravity-ui/icons';
4+
import {
5+
Button,
6+
Checkbox,
7+
Flex,
8+
Icon,
9+
Popup,
10+
SegmentedRadioGroup,
11+
Tab,
12+
TabList,
13+
Text,
14+
} from '@gravity-ui/uikit';
515
import {Meta, StoryFn} from '@storybook/react';
616

717
import {delay} from '../../InfiniteScroll/__stories__/utils';
18+
import {NotificationAction} from '../../Notification/NotificationAction';
819
import {NotificationProps, NotificationSourcePlacement} from '../../Notification/definitions';
920
import {Notifications} from '../Notifications';
1021
import {NotificationsPopupWrapper} from '../NotificationsPopupWrapper';
@@ -161,6 +172,73 @@ export const Empty: StoryFn = () => {
161172
);
162173
};
163174

175+
export const CustomHeader: StoryFn = () => {
176+
return (
177+
<Wrapper>
178+
<NotificationsWithCustomHeader />
179+
</Wrapper>
180+
);
181+
};
182+
183+
function NotificationsWithCustomHeader() {
184+
const [activeTab, setActiveTab] = React.useState('first');
185+
186+
return (
187+
<Notifications
188+
renderCustomHeader={({title}) => (
189+
<CustomHeaderComponent
190+
title={title}
191+
activeTab={activeTab}
192+
onTabUpdate={setActiveTab}
193+
/>
194+
)}
195+
notifications={activeTab === 'first' ? mockNotifications : []}
196+
/>
197+
);
198+
}
199+
200+
interface CustomHeaderComponentProps {
201+
title: React.ReactNode;
202+
activeTab: string;
203+
onTabUpdate?: (tab: string) => void;
204+
}
205+
206+
function CustomHeaderComponent({title, activeTab, onTabUpdate}: CustomHeaderComponentProps) {
207+
return (
208+
<div>
209+
<div
210+
style={{
211+
padding: '16px 16px 0 16px',
212+
}}
213+
>
214+
{title}
215+
</div>
216+
<div style={{position: 'relative'}}>
217+
<TabList value={activeTab} onUpdate={onTabUpdate}>
218+
<Tab style={{marginLeft: '16px'}} value="first">
219+
First tab
220+
</Tab>
221+
<Tab value="second">Second tab</Tab>
222+
</TabList>
223+
<Flex
224+
style={{
225+
position: 'absolute',
226+
right: '16px',
227+
top: '50%',
228+
transform: 'translateY(-50%)',
229+
}}
230+
gap={1}
231+
>
232+
<NotificationAction action={{icon: Funnel, text: 'Filter'}} />
233+
{activeTab === 'second' && (
234+
<NotificationAction action={{icon: Gear, text: 'Settings'}} />
235+
)}
236+
</Flex>
237+
</div>
238+
</div>
239+
);
240+
}
241+
164242
function useNotificationsVariationsControl() {
165243
const [showNotificationsActions, setShowNotificationsActions] = React.useState(true);
166244
const [showNotificationActions, setShowNotificationActions] = React.useState(true);

src/components/Notifications/definitions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ export type NotificationsProps = {
88
title?: React.ReactNode;
99
actions?: React.ReactNode;
1010

11+
renderCustomHeader?: (params: {title: React.ReactNode}) => JSX.Element;
12+
1113
notifications: NotificationProps[];
1214
areAllNotificationsLoaded?: boolean;
1315
onLoadMoreNotifications?: () => Promise<void>;

0 commit comments

Comments
 (0)