@servicetitan/navigation 11.0.0-canary.237.4d902dc.0 → 11.0.0-canary.237.5f3f02d.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/dist/components/badge-tag.d.ts +1 -1
- package/dist/components/badge-tag.d.ts.map +1 -1
- package/dist/components/header-navigation/header-navigation-stacked.stories.js +1 -1
- package/dist/components/header-navigation/header-navigation-stacked.stories.js.map +1 -1
- package/dist/components/header-navigation/header-navigation.stories.js +1 -1
- package/dist/components/header-navigation/header-navigation.stories.js.map +1 -1
- package/dist/components/left-navigation/header-navigation-tiny.stories.js +2 -2
- package/dist/components/left-navigation/header-navigation-tiny.stories.js.map +1 -1
- package/dist/components/logo/logo-titan-text.d.ts +1 -1
- package/dist/components/logo/logo-titan-text.d.ts.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.d.ts +12 -7
- package/dist/components/profile-dropdown/profile-dropdown.d.ts.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.js +10 -7
- package/dist/components/profile-dropdown/profile-dropdown.js.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.module.less +20 -6
- package/dist/components/titan-layout/layout-context.js +1 -1
- package/dist/components/titan-layout/layout-context.js.map +1 -1
- package/dist/components/titan-layout/layout-header-links.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-header-links.js +1 -1
- package/dist/components/titan-layout/layout-header-links.js.map +1 -1
- package/dist/components/titan-layout/layout-header.d.ts +2 -0
- package/dist/components/titan-layout/layout-header.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-header.js +3 -4
- package/dist/components/titan-layout/layout-header.js.map +1 -1
- package/dist/components/titan-layout/layout-header.module.less +61 -21
- package/dist/components/titan-layout/layout-logo.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-logo.js +2 -1
- package/dist/components/titan-layout/layout-logo.js.map +1 -1
- package/dist/components/titan-layout/layout-profile.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-profile.js +39 -11
- package/dist/components/titan-layout/layout-profile.js.map +1 -1
- package/dist/components/titan-layout/layout-profile.stories.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-profile.stories.js +1 -1
- package/dist/components/titan-layout/layout-profile.stories.js.map +1 -1
- package/dist/components/titan-layout/layout-sidebar-links-internal.d.ts +2 -2
- package/dist/components/titan-layout/layout-sidebar-links-internal.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-sidebar-links-internal.js +4 -4
- package/dist/components/titan-layout/layout-sidebar-links-internal.js.map +1 -1
- package/dist/components/titan-layout/layout-sidebar-links.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-sidebar-links.js +12 -5
- package/dist/components/titan-layout/layout-sidebar-links.js.map +1 -1
- package/dist/components/titan-layout/layout-sidebar.d.ts +2 -1
- package/dist/components/titan-layout/layout-sidebar.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-sidebar.js +6 -4
- package/dist/components/titan-layout/layout-sidebar.js.map +1 -1
- package/dist/components/titan-layout/layout-sidebar.module.less +29 -21
- package/dist/components/titan-layout/notifications-context.d.ts +13 -0
- package/dist/components/titan-layout/notifications-context.d.ts.map +1 -0
- package/dist/components/titan-layout/notifications-context.js +23 -0
- package/dist/components/titan-layout/notifications-context.js.map +1 -0
- package/dist/components/titan-layout/titan-layout.d.ts +10 -6
- package/dist/components/titan-layout/titan-layout.d.ts.map +1 -1
- package/dist/components/titan-layout/titan-layout.js +104 -21
- package/dist/components/titan-layout/titan-layout.js.map +1 -1
- package/dist/components/titan-layout/titan-layout.module.less +74 -19
- package/dist/components/titan-layout/titan-layout.stories.d.ts +15 -11
- package/dist/components/titan-layout/titan-layout.stories.d.ts.map +1 -1
- package/dist/components/titan-layout/titan-layout.stories.js +35 -14
- package/dist/components/titan-layout/titan-layout.stories.js.map +1 -1
- package/dist/test/data.d.ts +4 -1
- package/dist/test/data.d.ts.map +1 -1
- package/dist/test/data.js +2 -3
- package/dist/test/data.js.map +1 -1
- package/dist/utils/use-breakpoint.d.ts +1 -0
- package/dist/utils/use-breakpoint.d.ts.map +1 -1
- package/dist/utils/use-breakpoint.js +3 -2
- package/dist/utils/use-breakpoint.js.map +1 -1
- package/package.json +2 -2
- package/src/components/badge-tag.tsx +1 -1
- package/src/components/header-navigation/header-navigation-stacked.stories.tsx +1 -1
- package/src/components/header-navigation/header-navigation.stories.tsx +1 -1
- package/src/components/left-navigation/header-navigation-tiny.stories.tsx +2 -2
- package/src/components/logo/logo-titan-text.tsx +1 -1
- package/src/components/profile-dropdown/profile-dropdown.module.less +20 -6
- package/src/components/profile-dropdown/profile-dropdown.module.less.d.ts +2 -0
- package/src/components/profile-dropdown/profile-dropdown.tsx +50 -15
- package/src/components/titan-layout/layout-context.tsx +1 -1
- package/src/components/titan-layout/layout-header-links.tsx +2 -1
- package/src/components/titan-layout/layout-header.module.less +61 -21
- package/src/components/titan-layout/layout-header.module.less.d.ts +2 -0
- package/src/components/titan-layout/layout-header.tsx +17 -6
- package/src/components/titan-layout/layout-logo.tsx +13 -6
- package/src/components/titan-layout/layout-profile.stories.tsx +10 -1
- package/src/components/titan-layout/layout-profile.tsx +92 -28
- package/src/components/titan-layout/layout-sidebar-links-internal.tsx +18 -5
- package/src/components/titan-layout/layout-sidebar-links.tsx +21 -5
- package/src/components/titan-layout/layout-sidebar.module.less +29 -21
- package/src/components/titan-layout/layout-sidebar.module.less.d.ts +1 -2
- package/src/components/titan-layout/layout-sidebar.tsx +15 -9
- package/src/components/titan-layout/notifications-context.tsx +44 -0
- package/src/components/titan-layout/titan-layout.module.less +74 -19
- package/src/components/titan-layout/titan-layout.module.less.d.ts +5 -0
- package/src/components/titan-layout/titan-layout.stories.tsx +171 -19
- package/src/components/titan-layout/titan-layout.tsx +244 -74
- package/src/test/data.tsx +2 -3
- package/src/utils/use-breakpoint.ts +3 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import SvgAccountActive from '@servicetitan/anvil2/assets/icons/st/gnav_account_active.svg';
|
|
2
2
|
import SvgAccountInactive from '@servicetitan/anvil2/assets/icons/st/gnav_account_inactive.svg';
|
|
3
3
|
|
|
4
|
-
import { FC, useState } from 'react';
|
|
5
|
-
import { NavigationComponentContext } from '../../utils/navigation-context';
|
|
4
|
+
import { FC, MouseEvent, useEffect, useState } from 'react';
|
|
5
|
+
import { NavLinkComponentProps, NavigationComponentContext } from '../../utils/navigation-context';
|
|
6
6
|
import {
|
|
7
7
|
ProfileDropdown as DesktopProfileDropdown,
|
|
8
8
|
ProfileDropdownLinkProps,
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
InternalSideNavigationGroupLink,
|
|
18
18
|
InternalSideNavigationGroupTrigger,
|
|
19
19
|
} from './layout-sidebar-links-internal';
|
|
20
|
+
import { useNotificationsContext, useNotificationsState } from './notifications-context';
|
|
20
21
|
|
|
21
22
|
export type {
|
|
22
23
|
ProfileDropdownProps,
|
|
@@ -24,14 +25,28 @@ export type {
|
|
|
24
25
|
ProfileDropdownLinkProps,
|
|
25
26
|
} from '../profile-dropdown/profile-dropdown';
|
|
26
27
|
|
|
28
|
+
const ExternalNavComponent: FC<NavLinkComponentProps> = ({
|
|
29
|
+
children,
|
|
30
|
+
isActive,
|
|
31
|
+
to,
|
|
32
|
+
activeClassName,
|
|
33
|
+
...props
|
|
34
|
+
}) => (
|
|
35
|
+
<a {...props} href={to}>
|
|
36
|
+
{children}
|
|
37
|
+
</a>
|
|
38
|
+
);
|
|
39
|
+
|
|
27
40
|
const ProfileDropdownContent: FC<ProfileDropdownProps> = props => {
|
|
28
|
-
const { breakpoint, NavigationComponent } = useTitanLayoutContext();
|
|
41
|
+
const { isTitanLayout, breakpoint, NavigationComponent } = useTitanLayoutContext();
|
|
29
42
|
return breakpoint.isMobile ? (
|
|
30
43
|
<MobileProfileDropdown {...props} navigationComponent={NavigationComponent} />
|
|
31
|
-
) : (
|
|
44
|
+
) : isTitanLayout ? (
|
|
32
45
|
<NavigationComponentContext.Provider value={NavigationComponent}>
|
|
33
46
|
<DesktopProfileDropdown {...props} />
|
|
34
47
|
</NavigationComponentContext.Provider>
|
|
48
|
+
) : (
|
|
49
|
+
<DesktopProfileDropdown {...props} />
|
|
35
50
|
);
|
|
36
51
|
};
|
|
37
52
|
ProfileDropdownContent.displayName = 'ProfileDropdown';
|
|
@@ -40,24 +55,37 @@ const MobileProfileDropdown: FC<ProfileDropdownProps & NavigationComponentProps>
|
|
|
40
55
|
children,
|
|
41
56
|
...props
|
|
42
57
|
}) => {
|
|
58
|
+
const id = '__profile';
|
|
43
59
|
const [expanded, setExpanded] = useState(false);
|
|
44
|
-
const
|
|
60
|
+
const { hasNotifications, NotificationsContextProvider } = useNotificationsState();
|
|
61
|
+
const { onNotificationsUpdate } = useNotificationsContext();
|
|
62
|
+
const onExpandToggle = (e: MouseEvent<never>) => {
|
|
63
|
+
e.stopPropagation();
|
|
64
|
+
setExpanded(!expanded);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
onNotificationsUpdate(id, hasNotifications);
|
|
69
|
+
}, [hasNotifications, onNotificationsUpdate]);
|
|
70
|
+
|
|
45
71
|
return (
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
72
|
+
<NotificationsContextProvider>
|
|
73
|
+
<InternalSideNavigationGroup
|
|
74
|
+
id={id}
|
|
75
|
+
to={undefined}
|
|
76
|
+
title="Profile"
|
|
77
|
+
icon={SvgAccountInactive}
|
|
78
|
+
iconActive={SvgAccountActive}
|
|
79
|
+
isActive={expanded}
|
|
80
|
+
{...props}
|
|
81
|
+
submenuExpanded={expanded}
|
|
82
|
+
onExpandToggle={onExpandToggle}
|
|
83
|
+
onClick={onExpandToggle}
|
|
84
|
+
tag={{ value: hasNotifications }}
|
|
85
|
+
>
|
|
86
|
+
{children}
|
|
87
|
+
</InternalSideNavigationGroup>
|
|
88
|
+
</NotificationsContextProvider>
|
|
61
89
|
);
|
|
62
90
|
};
|
|
63
91
|
|
|
@@ -70,6 +98,25 @@ const ProfileDropdownDivider: FC = () => {
|
|
|
70
98
|
);
|
|
71
99
|
};
|
|
72
100
|
|
|
101
|
+
const getText = (children: any, text: any): string | undefined => {
|
|
102
|
+
if (typeof children === 'string') {
|
|
103
|
+
return children;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (typeof text === 'string') {
|
|
107
|
+
return text;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return undefined;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const getTag = (
|
|
114
|
+
tag: ProfileDropdownLinkProps['tag'],
|
|
115
|
+
counter: ProfileDropdownLinkProps['counter']
|
|
116
|
+
): boolean => {
|
|
117
|
+
return !!tag?.value || !!counter;
|
|
118
|
+
};
|
|
119
|
+
|
|
73
120
|
const ProfileDropdownSection: FC<ProfileDropdownSectionProps> = props => {
|
|
74
121
|
const { breakpoint } = useTitanLayoutContext();
|
|
75
122
|
return breakpoint.isMobile ? (
|
|
@@ -78,10 +125,19 @@ const ProfileDropdownSection: FC<ProfileDropdownSectionProps> = props => {
|
|
|
78
125
|
<DesktopProfileDropdown.Section {...props} />
|
|
79
126
|
);
|
|
80
127
|
};
|
|
81
|
-
const MobileProfileDropdownSection: FC<ProfileDropdownSectionProps> =
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
128
|
+
const MobileProfileDropdownSection: FC<ProfileDropdownSectionProps> = ({
|
|
129
|
+
children,
|
|
130
|
+
text,
|
|
131
|
+
tooltip,
|
|
132
|
+
title,
|
|
133
|
+
...props
|
|
134
|
+
}) => {
|
|
135
|
+
const sectionText = getText(children, text);
|
|
136
|
+
const { onNotificationsUpdate } = useNotificationsContext();
|
|
137
|
+
onNotificationsUpdate(props.id, getTag(props.tag, props.counter));
|
|
138
|
+
|
|
139
|
+
return sectionText ? (
|
|
140
|
+
<InternalSideNavigationGroupTrigger {...props} title={sectionText} />
|
|
85
141
|
) : null;
|
|
86
142
|
};
|
|
87
143
|
|
|
@@ -94,17 +150,25 @@ const ProfileDropdownLink: FC<ProfileDropdownLinkProps> = props => {
|
|
|
94
150
|
);
|
|
95
151
|
};
|
|
96
152
|
const MobileProfileDropdownLink: FC<ProfileDropdownLinkProps & NavigationComponentProps> = ({
|
|
153
|
+
external,
|
|
97
154
|
to,
|
|
155
|
+
tooltip,
|
|
156
|
+
text,
|
|
157
|
+
children,
|
|
98
158
|
navigationComponent,
|
|
99
159
|
...props
|
|
100
160
|
}) => {
|
|
101
|
-
const
|
|
102
|
-
|
|
161
|
+
const { onNotificationsUpdate } = useNotificationsContext();
|
|
162
|
+
const linkText = getText(children, text);
|
|
163
|
+
const isExternalLink = external ?? to?.startsWith('http');
|
|
164
|
+
onNotificationsUpdate(props.id, getTag(props.tag, props.counter));
|
|
165
|
+
|
|
166
|
+
return linkText ? (
|
|
103
167
|
<InternalSideNavigationGroupLink
|
|
104
168
|
{...props}
|
|
105
169
|
to={to}
|
|
106
|
-
title={
|
|
107
|
-
navigationComponent={navigationComponent}
|
|
170
|
+
title={linkText}
|
|
171
|
+
navigationComponent={isExternalLink ? ExternalNavComponent : navigationComponent}
|
|
108
172
|
/>
|
|
109
173
|
) : null;
|
|
110
174
|
};
|
|
@@ -156,7 +156,9 @@ export const InternalSideNavigationLink: FC<InternalSideNavigationLinkProps> = (
|
|
|
156
156
|
|
|
157
157
|
/** Side Navigation menu trigger (for internal usage) */
|
|
158
158
|
export const InternalSideNavigationTrigger: FC<
|
|
159
|
-
Omit<InternalSideNavigationLinkProps, 'to' | 'navigationComponent'> & {
|
|
159
|
+
Omit<InternalSideNavigationLinkProps, 'to' | 'navigationComponent'> & {
|
|
160
|
+
onClick?: (e: MouseEvent<never>) => void;
|
|
161
|
+
}
|
|
160
162
|
> = ({ className, dataPrefix, isActive, submenuExpanded, onExpandToggle, onClick, ...props }) => {
|
|
161
163
|
return (
|
|
162
164
|
<div
|
|
@@ -180,12 +182,22 @@ export const InternalSideNavigationTrigger: FC<
|
|
|
180
182
|
|
|
181
183
|
export const InternalSideNavigationGroupLink: FC<
|
|
182
184
|
NavigationSubmenuItemData & NavigationComponentProps
|
|
183
|
-
> = ({
|
|
185
|
+
> = ({
|
|
186
|
+
id,
|
|
187
|
+
counter,
|
|
188
|
+
tag,
|
|
189
|
+
title,
|
|
190
|
+
to,
|
|
191
|
+
isActive,
|
|
192
|
+
navigationComponent: NavigationComponent,
|
|
193
|
+
...rest
|
|
194
|
+
}) => {
|
|
184
195
|
return (
|
|
185
196
|
<NavigationComponent
|
|
197
|
+
key={id}
|
|
186
198
|
data-cy={`navigation-item-${id}`}
|
|
187
199
|
data-pendo={`navigation-item-${id}`}
|
|
188
|
-
|
|
200
|
+
{...rest}
|
|
189
201
|
to={to}
|
|
190
202
|
className={classNames(Styles.submenuItem, Styles.submenuLink, {
|
|
191
203
|
[Styles.submenuLinkActive]: isActive === true,
|
|
@@ -201,12 +213,13 @@ export const InternalSideNavigationGroupLink: FC<
|
|
|
201
213
|
|
|
202
214
|
export const InternalSideNavigationGroupTrigger: FC<
|
|
203
215
|
Omit<NavigationSubmenuItemData, 'to'> & { onClick?: (e: MouseEvent<any>) => void }
|
|
204
|
-
> = ({ id, counter, onClick, tag, title, isActive }) => {
|
|
216
|
+
> = ({ id, counter, onClick, tag, title, isActive, ...rest }) => {
|
|
205
217
|
return (
|
|
206
218
|
<div
|
|
207
219
|
data-cy={`navigation-item-${id}`}
|
|
208
220
|
data-pendo={`navigation-item-${id}`}
|
|
209
221
|
key={id}
|
|
222
|
+
{...rest}
|
|
210
223
|
className={classNames(Styles.submenuItem, {
|
|
211
224
|
[Styles.submenuLink]: !!onClick,
|
|
212
225
|
[Styles.submenuLinkActive]: isActive === true,
|
|
@@ -231,7 +244,7 @@ export const InternalSideNavigationGroup: FC<
|
|
|
231
244
|
onExpandToggle?: (e: MouseEvent<never>) => void;
|
|
232
245
|
tag: BadgeTagProps | undefined;
|
|
233
246
|
to: NavigationItemData['to'] | undefined;
|
|
234
|
-
onClick?: () => void;
|
|
247
|
+
onClick?: (e: MouseEvent<never>) => void;
|
|
235
248
|
}
|
|
236
249
|
> = ({ children, submenuExpanded, to, onExpandToggle, onClick, ...props }) => {
|
|
237
250
|
return (
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
InternalSideNavigationLink,
|
|
7
7
|
InternalSideNavigationTrigger,
|
|
8
8
|
} from './layout-sidebar-links-internal';
|
|
9
|
+
import { useNotificationsContext } from './notifications-context';
|
|
9
10
|
|
|
10
11
|
const WrappedLink: FC<{
|
|
11
12
|
children: ReactElement<any>;
|
|
@@ -17,7 +18,14 @@ const WrappedLink: FC<{
|
|
|
17
18
|
|
|
18
19
|
/** Side Navigation menu link */
|
|
19
20
|
export function TitanLayoutSidebarLink({ wrapper, ...props }: TitanLayoutSidebarLinkProps) {
|
|
20
|
-
const {
|
|
21
|
+
const {
|
|
22
|
+
NavigationComponent,
|
|
23
|
+
breakpoint: { isMobile },
|
|
24
|
+
} = useTitanLayoutContext();
|
|
25
|
+
const { onNotificationsUpdate } = useNotificationsContext();
|
|
26
|
+
const tag = getCounterTag(props.counter, props.tag);
|
|
27
|
+
|
|
28
|
+
onNotificationsUpdate(props.id, !!tag);
|
|
21
29
|
|
|
22
30
|
const element = (
|
|
23
31
|
<InternalSideNavigationLink
|
|
@@ -25,11 +33,11 @@ export function TitanLayoutSidebarLink({ wrapper, ...props }: TitanLayoutSidebar
|
|
|
25
33
|
navigationComponent={NavigationComponent}
|
|
26
34
|
submenuExpanded={undefined}
|
|
27
35
|
dataPrefix="navigation-link"
|
|
28
|
-
tag={
|
|
36
|
+
tag={tag}
|
|
29
37
|
/>
|
|
30
38
|
);
|
|
31
39
|
|
|
32
|
-
return wrapper ? <WrappedLink wrapper={wrapper}>{element}</WrappedLink> : element;
|
|
40
|
+
return wrapper && !isMobile ? <WrappedLink wrapper={wrapper}>{element}</WrappedLink> : element;
|
|
33
41
|
}
|
|
34
42
|
|
|
35
43
|
/** Side Navigation menu trigger */
|
|
@@ -42,15 +50,23 @@ export function TitanLayoutSidebarTrigger({
|
|
|
42
50
|
const {
|
|
43
51
|
breakpoint: { isMobile },
|
|
44
52
|
} = useTitanLayoutContext();
|
|
53
|
+
const { onNotificationsUpdate } = useNotificationsContext();
|
|
54
|
+
const tag = getCounterTag(props.counter, props.tag);
|
|
55
|
+
|
|
56
|
+
onNotificationsUpdate(props.id, !!tag);
|
|
45
57
|
|
|
46
58
|
const element = (
|
|
47
59
|
<InternalSideNavigationTrigger
|
|
48
60
|
{...props}
|
|
49
61
|
submenuExpanded={undefined}
|
|
50
62
|
dataPrefix="navigation-trigger"
|
|
51
|
-
tag={
|
|
63
|
+
tag={tag}
|
|
52
64
|
onClick={isMobile && !!onMobileClick ? onMobileClick : onClick}
|
|
53
65
|
/>
|
|
54
66
|
);
|
|
55
|
-
return wrapper && !isMobile
|
|
67
|
+
return wrapper && (!isMobile || !onMobileClick) ? (
|
|
68
|
+
<WrappedLink wrapper={wrapper}>{element}</WrappedLink>
|
|
69
|
+
) : (
|
|
70
|
+
element
|
|
71
|
+
);
|
|
56
72
|
}
|
|
@@ -15,32 +15,22 @@
|
|
|
15
15
|
align-items: stretch;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
// desktop version positioned with flex
|
|
19
|
-
.nav-flex {
|
|
20
|
-
flex-basis: var(--nav-offset-left);
|
|
21
|
-
flex-grow: 0;
|
|
22
|
-
flex-shrink: 0;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// desktop version positioned with fixed
|
|
26
|
-
.nav-fixed {
|
|
27
|
-
position: fixed;
|
|
28
|
-
top: var(--nav-offset-top);
|
|
29
|
-
bottom: 0;
|
|
30
|
-
left: 0;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
18
|
// mobile version
|
|
34
19
|
.nav-drawer {
|
|
35
|
-
display: none;
|
|
20
|
+
// display: none;
|
|
36
21
|
position: fixed;
|
|
37
22
|
max-width: 400px;
|
|
38
23
|
width: 0;
|
|
24
|
+
height: 100vh;
|
|
39
25
|
top: 0;
|
|
40
|
-
|
|
41
|
-
left: 0;
|
|
26
|
+
left: -100vh;
|
|
42
27
|
z-index: 991;
|
|
43
28
|
|
|
29
|
+
-webkit-transition: width 200ms ease-in-out;
|
|
30
|
+
-moz-transition: width 200ms ease-in-out;
|
|
31
|
+
-o-transition: width 200ms ease-in-out;
|
|
32
|
+
transition: width 200ms ease-in-out;
|
|
33
|
+
|
|
44
34
|
.nav-main {
|
|
45
35
|
padding-left: @spacing-2;
|
|
46
36
|
padding-right: @spacing-2;
|
|
@@ -54,6 +44,7 @@
|
|
|
54
44
|
padding-top: @spacing-2;
|
|
55
45
|
padding-left: @spacing-2;
|
|
56
46
|
padding-right: @spacing-2;
|
|
47
|
+
cursor: pointer;
|
|
57
48
|
}
|
|
58
49
|
}
|
|
59
50
|
|
|
@@ -76,10 +67,21 @@
|
|
|
76
67
|
}
|
|
77
68
|
}
|
|
78
69
|
|
|
70
|
+
.nav-drawer-backdrop {
|
|
71
|
+
position: fixed;
|
|
72
|
+
height: 100vh;
|
|
73
|
+
width: 100vw;
|
|
74
|
+
top: 0;
|
|
75
|
+
left: 0;
|
|
76
|
+
z-index: 991;
|
|
77
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
78
|
+
}
|
|
79
|
+
|
|
79
80
|
// mobile version opened
|
|
80
81
|
.nav-drawer-opened {
|
|
81
82
|
display: flex;
|
|
82
83
|
width: 90vw;
|
|
84
|
+
left: 0;
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
@media only screen and (min-width: 361px) {
|
|
@@ -156,7 +158,11 @@
|
|
|
156
158
|
// desktop version expanded
|
|
157
159
|
.nav-wide {
|
|
158
160
|
width: var(--nav-offset-left);
|
|
159
|
-
|
|
161
|
+
|
|
162
|
+
.nav-item {
|
|
163
|
+
margin-left: @spacing-1;
|
|
164
|
+
margin-right: @spacing-1;
|
|
165
|
+
}
|
|
160
166
|
|
|
161
167
|
.toggle {
|
|
162
168
|
.toggle-content {
|
|
@@ -177,14 +183,16 @@
|
|
|
177
183
|
margin-top: @spacing-1;
|
|
178
184
|
margin-bottom: @spacing-1;
|
|
179
185
|
}
|
|
186
|
+
|
|
187
|
+
.nav-main {
|
|
188
|
+
padding-top: @spacing-1;
|
|
189
|
+
}
|
|
180
190
|
}
|
|
181
191
|
|
|
182
192
|
.nav-drawer,
|
|
183
193
|
.nav-wide {
|
|
184
194
|
.nav-item {
|
|
185
195
|
flex-direction: row;
|
|
186
|
-
margin-left: @spacing-1;
|
|
187
|
-
margin-right: @spacing-1;
|
|
188
196
|
|
|
189
197
|
.nav-item-icon-wrapper {
|
|
190
198
|
flex: 1;
|
|
@@ -5,9 +5,8 @@ export const navBottom: string;
|
|
|
5
5
|
export const navClose: string;
|
|
6
6
|
export const navCloseWrapper: string;
|
|
7
7
|
export const navDrawer: string;
|
|
8
|
+
export const navDrawerBackdrop: string;
|
|
8
9
|
export const navDrawerOpened: string;
|
|
9
|
-
export const navFixed: string;
|
|
10
|
-
export const navFlex: string;
|
|
11
10
|
export const navFooter: string;
|
|
12
11
|
export const navGroupItem: string;
|
|
13
12
|
export const navGroupWrapper: string;
|
|
@@ -31,45 +31,51 @@ export interface LayoutSidebarProps {
|
|
|
31
31
|
top?: ReactElement[];
|
|
32
32
|
bottom?: ReactElement;
|
|
33
33
|
mainItems?: NavigationItemData[];
|
|
34
|
-
flex: boolean;
|
|
35
34
|
barExpanded: boolean;
|
|
36
35
|
submenuExpanded: string | undefined;
|
|
36
|
+
drawerOpened: boolean;
|
|
37
37
|
mobile: boolean;
|
|
38
38
|
navigationComponent: FC<NavLinkComponentProps>;
|
|
39
39
|
onBarExpandChange(expanded: boolean): void;
|
|
40
|
+
onDrawerOpenChange(expanded: boolean): void;
|
|
40
41
|
onSubmenuExpandChange(id: string, expanded: boolean): void;
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
export const LayoutSidebar: FC<LayoutSidebarProps> = ({
|
|
44
45
|
className,
|
|
45
|
-
flex,
|
|
46
46
|
mobile,
|
|
47
47
|
barExpanded,
|
|
48
48
|
submenuExpanded,
|
|
49
|
+
drawerOpened,
|
|
49
50
|
onBarExpandChange,
|
|
50
51
|
onSubmenuExpandChange,
|
|
52
|
+
onDrawerOpenChange,
|
|
51
53
|
mainItems,
|
|
52
54
|
top,
|
|
53
55
|
bottom,
|
|
54
56
|
navigationComponent,
|
|
55
57
|
}) => {
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
+
const closeDrawer = () => {
|
|
59
|
+
if (mobile) {
|
|
60
|
+
onDrawerOpenChange?.(false);
|
|
61
|
+
}
|
|
58
62
|
};
|
|
59
63
|
|
|
60
64
|
return (
|
|
61
65
|
<LayoutPlacementContext.Provider value="side">
|
|
66
|
+
{mobile && drawerOpened && (
|
|
67
|
+
<div className={Styles.navDrawerBackdrop} onClick={closeDrawer} />
|
|
68
|
+
)}
|
|
62
69
|
<div
|
|
63
70
|
className={classNames(
|
|
64
71
|
Styles.nav,
|
|
65
72
|
mobile && Styles.navDrawer,
|
|
66
|
-
mobile &&
|
|
73
|
+
mobile && drawerOpened && Styles.navDrawerOpened,
|
|
67
74
|
!mobile && (barExpanded ? Styles.navWide : Styles.navSlim),
|
|
68
|
-
!mobile && (flex ? Styles.navFlex : Styles.navFixed),
|
|
69
75
|
className
|
|
70
76
|
)}
|
|
71
77
|
data-cy="side-navigation"
|
|
72
|
-
onClick={
|
|
78
|
+
onClick={closeDrawer}
|
|
73
79
|
>
|
|
74
80
|
<ThemeProvider mode="dark" className={Styles.navMain}>
|
|
75
81
|
{mobile && (
|
|
@@ -82,14 +88,14 @@ export const LayoutSidebar: FC<LayoutSidebarProps> = ({
|
|
|
82
88
|
</div>
|
|
83
89
|
</div>
|
|
84
90
|
)}
|
|
85
|
-
{top?.length && <SidebarTop>{top}</SidebarTop>}
|
|
91
|
+
{!!top?.length && <SidebarTop>{top}</SidebarTop>}
|
|
86
92
|
|
|
87
93
|
<div data-cy="navigation-items">
|
|
88
94
|
{mainItems?.map(item =>
|
|
89
95
|
item.submenu ? (
|
|
90
96
|
<SideNavigationGroupItem
|
|
91
97
|
key={item.id}
|
|
92
|
-
barExpanded={barExpanded}
|
|
98
|
+
barExpanded={mobile ? drawerOpened : barExpanded}
|
|
93
99
|
submenuExpanded={!!item.id && submenuExpanded === item.id}
|
|
94
100
|
onSubmenuExpand={onSubmenuExpandChange}
|
|
95
101
|
navigationComponent={navigationComponent}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FC,
|
|
3
|
+
PropsWithChildren,
|
|
4
|
+
createContext,
|
|
5
|
+
useCallback,
|
|
6
|
+
useContext,
|
|
7
|
+
useRef,
|
|
8
|
+
useState,
|
|
9
|
+
} from 'react';
|
|
10
|
+
|
|
11
|
+
interface NotificationsContextType {
|
|
12
|
+
onNotificationsUpdate: (id: string, hasNotifications: boolean) => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const NotificationsContext = createContext<NotificationsContextType>({
|
|
16
|
+
onNotificationsUpdate: () => {},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export const useNotificationsContext = () => useContext(NotificationsContext);
|
|
20
|
+
|
|
21
|
+
export const useNotificationsState = () => {
|
|
22
|
+
const [hasNotifications, setHasNotifications] = useState(false);
|
|
23
|
+
const items = useRef(new Set<string>());
|
|
24
|
+
const onNotificationsUpdate = useCallback((id: string, hasNotifications: boolean) => {
|
|
25
|
+
if (hasNotifications && !items.current.has(id)) {
|
|
26
|
+
items.current.add(id);
|
|
27
|
+
setHasNotifications(!!items.current.size);
|
|
28
|
+
} else if (!hasNotifications && items.current.has(id)) {
|
|
29
|
+
items.current.delete(id);
|
|
30
|
+
setHasNotifications(!!items.current.size);
|
|
31
|
+
}
|
|
32
|
+
}, []);
|
|
33
|
+
|
|
34
|
+
const NotificationsContextProvider: FC<PropsWithChildren> = useCallback(
|
|
35
|
+
({ children }) => (
|
|
36
|
+
<NotificationsContext.Provider value={{ onNotificationsUpdate }}>
|
|
37
|
+
{children}
|
|
38
|
+
</NotificationsContext.Provider>
|
|
39
|
+
),
|
|
40
|
+
[onNotificationsUpdate]
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
return { NotificationsContextProvider, hasNotifications };
|
|
44
|
+
};
|
|
@@ -8,16 +8,47 @@
|
|
|
8
8
|
@bg-color-hover: rgba(255, 255, 255, 0.08);
|
|
9
9
|
@bg-color-active: rgba(120, 187, 250, 0.2);
|
|
10
10
|
|
|
11
|
-
.layout-legacy {
|
|
12
|
-
padding-left: var(--nav-offset-left);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
11
|
.layout-anvil1 {
|
|
16
|
-
|
|
12
|
+
height: calc(100vh - var(--nav-offset-top));
|
|
13
|
+
margin-top: var(--nav-offset-top);
|
|
14
|
+
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
|
|
18
|
+
.side {
|
|
19
|
+
flex-basis: var(--nav-offset-left);
|
|
20
|
+
flex-grow: 0;
|
|
21
|
+
flex-shrink: 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.content {
|
|
25
|
+
flex-grow: 1;
|
|
26
|
+
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
overflow: hidden;
|
|
30
|
+
}
|
|
17
31
|
}
|
|
18
32
|
|
|
19
33
|
.layout-anvil2 {
|
|
20
|
-
|
|
34
|
+
.content-header {
|
|
35
|
+
position: sticky;
|
|
36
|
+
top: var(--nav-offset-top);
|
|
37
|
+
z-index: 989;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.layout-desktop {
|
|
42
|
+
padding-left: var(--nav-offset-left);
|
|
43
|
+
|
|
44
|
+
.side {
|
|
45
|
+
position: fixed;
|
|
46
|
+
top: var(--nav-offset-top);
|
|
47
|
+
bottom: 0;
|
|
48
|
+
left: 0;
|
|
49
|
+
right: 0;
|
|
50
|
+
z-index: @z-index-global-nav;
|
|
51
|
+
}
|
|
21
52
|
}
|
|
22
53
|
|
|
23
54
|
.layout-legacy,
|
|
@@ -25,29 +56,53 @@
|
|
|
25
56
|
.top-placeholder {
|
|
26
57
|
height: var(--nav-offset-top);
|
|
27
58
|
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.layout {
|
|
62
|
+
--nav-offset-top: 0px;
|
|
63
|
+
--nav-offset-left: 0px;
|
|
64
|
+
--content-offset-top: var(--nav-offset-top);
|
|
65
|
+
--offset: var(--content-offset-top);
|
|
66
|
+
|
|
67
|
+
&.layout-desktop.layout-top {
|
|
68
|
+
--nav-offset-top: 48px;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
&.layout-mobile.layout-top {
|
|
72
|
+
--nav-offset-top: 72px;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
&.layout-desktop.layout-nav-slim {
|
|
76
|
+
--nav-offset-left: 64px;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
&.layout-desktop.layout-nav-wide {
|
|
80
|
+
--nav-offset-left: 212px;
|
|
81
|
+
}
|
|
28
82
|
|
|
29
83
|
.top {
|
|
30
84
|
position: fixed;
|
|
85
|
+
width: 100vw;
|
|
31
86
|
top: 0;
|
|
32
87
|
left: 0;
|
|
33
|
-
right: 0;
|
|
34
88
|
z-index: 991;
|
|
35
89
|
}
|
|
36
|
-
}
|
|
37
90
|
|
|
38
|
-
.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
--nav-offset-top: 61px;
|
|
43
|
-
--nav-offset-left: 0;
|
|
91
|
+
.content-header {
|
|
92
|
+
position: sticky;
|
|
93
|
+
left: 0;
|
|
94
|
+
right: 0;
|
|
44
95
|
}
|
|
96
|
+
}
|
|
45
97
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
98
|
+
@media print {
|
|
99
|
+
.layout {
|
|
100
|
+
--nav-offset-left: 0px !important;
|
|
101
|
+
--nav-offset-right: 0px !important;
|
|
49
102
|
|
|
50
|
-
|
|
51
|
-
|
|
103
|
+
.side,
|
|
104
|
+
.top {
|
|
105
|
+
display: none !important;
|
|
106
|
+
}
|
|
52
107
|
}
|
|
53
108
|
}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
export const __esModule: true;
|
|
2
|
+
export const content: string;
|
|
3
|
+
export const contentHeader: string;
|
|
2
4
|
export const layout: string;
|
|
3
5
|
export const layoutAnvil1: string;
|
|
4
6
|
export const layoutAnvil2: string;
|
|
7
|
+
export const layoutDesktop: string;
|
|
5
8
|
export const layoutLegacy: string;
|
|
6
9
|
export const layoutMobile: string;
|
|
7
10
|
export const layoutNavSlim: string;
|
|
8
11
|
export const layoutNavWide: string;
|
|
12
|
+
export const layoutTop: string;
|
|
13
|
+
export const side: string;
|
|
9
14
|
export const top: string;
|
|
10
15
|
export const topPlaceholder: string;
|
|
11
16
|
|