@servicetitan/navigation 11.0.0-canary.237.6ce8e81.0 → 11.0.0-canary.237.7e21f65.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/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 +1 -0
- package/dist/components/profile-dropdown/profile-dropdown.d.ts.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.js +2 -2
- package/dist/components/profile-dropdown/profile-dropdown.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 +26 -2
- 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 +20 -5
- package/dist/components/titan-layout/layout-profile.js.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 +9 -2
- package/dist/components/titan-layout/layout-sidebar-links.js.map +1 -1
- package/dist/components/titan-layout/layout-sidebar.d.ts +2 -0
- 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 +16 -3
- 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 +6 -3
- package/dist/components/titan-layout/titan-layout.d.ts.map +1 -1
- package/dist/components/titan-layout/titan-layout.js +42 -18
- package/dist/components/titan-layout/titan-layout.js.map +1 -1
- package/dist/components/titan-layout/titan-layout.module.less +30 -7
- package/dist/components/titan-layout/titan-layout.stories.d.ts +2 -0
- package/dist/components/titan-layout/titan-layout.stories.d.ts.map +1 -1
- package/dist/components/titan-layout/titan-layout.stories.js +8 -5
- 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/package.json +2 -2
- package/src/components/badge-tag.tsx +1 -1
- package/src/components/logo/logo-titan-text.tsx +1 -1
- package/src/components/profile-dropdown/profile-dropdown.tsx +5 -1
- package/src/components/titan-layout/layout-header.module.less +26 -2
- package/src/components/titan-layout/layout-header.tsx +7 -4
- package/src/components/titan-layout/layout-logo.tsx +13 -6
- package/src/components/titan-layout/layout-profile.stories.tsx +1 -1
- package/src/components/titan-layout/layout-profile.tsx +42 -19
- package/src/components/titan-layout/layout-sidebar-links-internal.tsx +18 -5
- package/src/components/titan-layout/layout-sidebar-links.tsx +11 -2
- package/src/components/titan-layout/layout-sidebar.module.less +16 -3
- package/src/components/titan-layout/layout-sidebar.module.less.d.ts +1 -0
- package/src/components/titan-layout/layout-sidebar.tsx +14 -5
- package/src/components/titan-layout/notifications-context.tsx +44 -0
- package/src/components/titan-layout/titan-layout.module.less +30 -7
- package/src/components/titan-layout/titan-layout.module.less.d.ts +2 -1
- package/src/components/titan-layout/titan-layout.stories.tsx +13 -4
- package/src/components/titan-layout/titan-layout.tsx +122 -76
- package/src/test/data.tsx +2 -3
|
@@ -148,7 +148,9 @@ const ProfileDropdownTrigger: FC<ProfileDropdownTriggerProps> = ({
|
|
|
148
148
|
);
|
|
149
149
|
};
|
|
150
150
|
|
|
151
|
-
export type ProfileItemContent =
|
|
151
|
+
export type ProfileItemContent =
|
|
152
|
+
| { children: string; text?: string }
|
|
153
|
+
| { children: ReactNode; text: string };
|
|
152
154
|
|
|
153
155
|
export interface ProfileDropdownSectionPropsStrict {
|
|
154
156
|
children: ReactNode;
|
|
@@ -166,6 +168,7 @@ export const ProfileDropdownSection: FC<ProfileDropdownSectionProps> = ({
|
|
|
166
168
|
children,
|
|
167
169
|
className,
|
|
168
170
|
id,
|
|
171
|
+
text,
|
|
169
172
|
tooltip,
|
|
170
173
|
onClick,
|
|
171
174
|
...rest
|
|
@@ -221,6 +224,7 @@ export const ProfileDropdownLink: FC<ProfileDropdownLinkProps> = ({
|
|
|
221
224
|
counter,
|
|
222
225
|
tag,
|
|
223
226
|
target,
|
|
227
|
+
text,
|
|
224
228
|
to,
|
|
225
229
|
tooltip,
|
|
226
230
|
onClick,
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
background-color: @color-white;
|
|
11
11
|
color: @color-black;
|
|
12
12
|
border-bottom: 1px solid @color-neutral-60;
|
|
13
|
+
box-sizing: border-box;
|
|
13
14
|
|
|
14
15
|
& > * {
|
|
15
16
|
overflow-y: hidden;
|
|
@@ -20,6 +21,10 @@
|
|
|
20
21
|
align-items: center;
|
|
21
22
|
}
|
|
22
23
|
|
|
24
|
+
.he-top-center {
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
}
|
|
27
|
+
|
|
23
28
|
.he-top-right {
|
|
24
29
|
& > * {
|
|
25
30
|
color: @color-black;
|
|
@@ -126,7 +131,8 @@
|
|
|
126
131
|
// mobile
|
|
127
132
|
@media only screen and (max-width: 768px) {
|
|
128
133
|
.header {
|
|
129
|
-
padding: @spacing-
|
|
134
|
+
padding: @spacing-2 @spacing-0;
|
|
135
|
+
height: var(--nav-offset-top);
|
|
130
136
|
|
|
131
137
|
.navigation-link {
|
|
132
138
|
padding: 10px;
|
|
@@ -138,6 +144,14 @@
|
|
|
138
144
|
margin-left: @spacing-3;
|
|
139
145
|
margin-right: @spacing-3;
|
|
140
146
|
}
|
|
147
|
+
|
|
148
|
+
.he-top-left {
|
|
149
|
+
margin-left: @spacing-half;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.he-top-right {
|
|
153
|
+
margin-right: @spacing-half;
|
|
154
|
+
}
|
|
141
155
|
}
|
|
142
156
|
}
|
|
143
157
|
|
|
@@ -154,7 +168,8 @@
|
|
|
154
168
|
color: @color-white;
|
|
155
169
|
font-weight: @font-weight-semibold;
|
|
156
170
|
font-size: 8px !important;
|
|
157
|
-
min-width:
|
|
171
|
+
min-width: 16px !important;
|
|
172
|
+
height: 16px !important;
|
|
158
173
|
position: absolute;
|
|
159
174
|
top: 4px;
|
|
160
175
|
right: -2px;
|
|
@@ -172,3 +187,12 @@
|
|
|
172
187
|
right: -8px;
|
|
173
188
|
}
|
|
174
189
|
}
|
|
190
|
+
|
|
191
|
+
@media only screen and (min-width: 768px) {
|
|
192
|
+
.navigation-link {
|
|
193
|
+
.navigation-item-counter {
|
|
194
|
+
min-width: 12px !important;
|
|
195
|
+
height: 12px !important;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import SvgBurgerMenu from '@servicetitan/anvil2/assets/icons/material/round/menu.svg';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import { ComponentPropsWithoutRef, FC, ReactElement, ReactNode } from 'react';
|
|
4
|
-
import { LayoutPlacementContext
|
|
4
|
+
import { LayoutPlacementContext } from './layout-context';
|
|
5
5
|
import { LayoutHeaderNavigationTrigger } from './layout-header-links';
|
|
6
6
|
import * as Styles from './layout-header.module.less';
|
|
7
7
|
import { TitanLayoutLogoProps } from './layout-logo';
|
|
@@ -25,6 +25,8 @@ export type LayoutHeaderProps = Omit<ComponentPropsWithoutRef<'div'>, 'children'
|
|
|
25
25
|
logo: ReactElement<TitanLayoutLogoProps>;
|
|
26
26
|
profile?: ReactElement;
|
|
27
27
|
|
|
28
|
+
isMobile: boolean;
|
|
29
|
+
hasNotifications: boolean;
|
|
28
30
|
onBurgerClick?: (e: MouseEvent) => void;
|
|
29
31
|
};
|
|
30
32
|
|
|
@@ -35,13 +37,13 @@ export const LayoutHeader: FC<LayoutHeaderProps> = ({
|
|
|
35
37
|
rightClassName,
|
|
36
38
|
center,
|
|
37
39
|
centerClassName,
|
|
40
|
+
isMobile,
|
|
41
|
+
hasNotifications,
|
|
38
42
|
logo,
|
|
39
43
|
profile,
|
|
40
44
|
onBurgerClick,
|
|
41
45
|
...rest
|
|
42
46
|
}) => {
|
|
43
|
-
const { breakpoint } = useTitanLayoutContext();
|
|
44
|
-
|
|
45
47
|
return (
|
|
46
48
|
<LayoutPlacementContext.Provider value="top">
|
|
47
49
|
<div
|
|
@@ -50,7 +52,7 @@ export const LayoutHeader: FC<LayoutHeaderProps> = ({
|
|
|
50
52
|
data-cy="header-navigation"
|
|
51
53
|
>
|
|
52
54
|
<div className={classNames(Styles.heTopLeft)} data-cy="navigation-left">
|
|
53
|
-
{
|
|
55
|
+
{isMobile && (
|
|
54
56
|
<LayoutHeaderNavigationTrigger
|
|
55
57
|
id="burger"
|
|
56
58
|
title=""
|
|
@@ -58,6 +60,7 @@ export const LayoutHeader: FC<LayoutHeaderProps> = ({
|
|
|
58
60
|
iconActive={SvgBurgerMenu}
|
|
59
61
|
className="m-r-1"
|
|
60
62
|
onClick={onBurgerClick}
|
|
63
|
+
tag={{ value: hasNotifications }}
|
|
61
64
|
/>
|
|
62
65
|
)}
|
|
63
66
|
{logo}
|
|
@@ -33,20 +33,27 @@ export const TitanLayoutLogo: FC<TitanLayoutLogoProps> = ({
|
|
|
33
33
|
const Wrapper = logoWrapper;
|
|
34
34
|
const logoSize = isMobile ? 44 : 56;
|
|
35
35
|
const logoCompanySize = 48;
|
|
36
|
+
const showCompanyTitle = title === true && !isMobile;
|
|
36
37
|
|
|
37
38
|
return (
|
|
38
|
-
<div
|
|
39
|
-
{
|
|
39
|
+
<div
|
|
40
|
+
className={classNames(
|
|
41
|
+
'd-f align-items-center',
|
|
42
|
+
{ 'p-t-half': showCompanyTitle },
|
|
43
|
+
className
|
|
44
|
+
)}
|
|
45
|
+
>
|
|
46
|
+
{showCompanyTitle ? (
|
|
47
|
+
<Wrapper>
|
|
48
|
+
<LogoCompanyTitle height={logoCompanySize} />
|
|
49
|
+
</Wrapper>
|
|
50
|
+
) : typeof title === 'string' ? (
|
|
40
51
|
<Fragment>
|
|
41
52
|
<LogoTitan size={logoSize} mantleFill={mantleFill} logoWrapper={Wrapper} />
|
|
42
53
|
{!isMobile && (
|
|
43
54
|
<LogoTitanTitle className="c-inherit m-l-1">{title}</LogoTitanTitle>
|
|
44
55
|
)}
|
|
45
56
|
</Fragment>
|
|
46
|
-
) : title === true && !isMobile ? (
|
|
47
|
-
<Wrapper className="">
|
|
48
|
-
<LogoCompanyTitle height={logoCompanySize} />
|
|
49
|
-
</Wrapper>
|
|
50
57
|
) : (
|
|
51
58
|
<LogoTitan size={logoSize} mantleFill={mantleFill} logoWrapper={Wrapper} />
|
|
52
59
|
)}
|
|
@@ -18,7 +18,7 @@ export default {
|
|
|
18
18
|
|
|
19
19
|
export const ProfileDefault = withTitanLayout(
|
|
20
20
|
<ProfileDropdown>
|
|
21
|
-
<ProfileDropdown.Link id="first" to="https://google.com">
|
|
21
|
+
<ProfileDropdown.Link id="first" to="https://google.com" external>
|
|
22
22
|
first link
|
|
23
23
|
</ProfileDropdown.Link>
|
|
24
24
|
<ProfileDropdown.Section id="second" onClick={() => alert('second click')}>
|
|
@@ -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,6 +25,10 @@ export type {
|
|
|
24
25
|
ProfileDropdownLinkProps,
|
|
25
26
|
} from '../profile-dropdown/profile-dropdown';
|
|
26
27
|
|
|
28
|
+
const ExternalNavComponent: FC<NavLinkComponentProps> = ({ children, isActive, ...props }) => (
|
|
29
|
+
<a {...props}>{children}</a>
|
|
30
|
+
);
|
|
31
|
+
|
|
27
32
|
const ProfileDropdownContent: FC<ProfileDropdownProps> = props => {
|
|
28
33
|
const { breakpoint, NavigationComponent } = useTitanLayoutContext();
|
|
29
34
|
return breakpoint.isMobile ? (
|
|
@@ -40,24 +45,37 @@ const MobileProfileDropdown: FC<ProfileDropdownProps & NavigationComponentProps>
|
|
|
40
45
|
children,
|
|
41
46
|
...props
|
|
42
47
|
}) => {
|
|
48
|
+
const id = '__profile';
|
|
43
49
|
const [expanded, setExpanded] = useState(false);
|
|
44
|
-
const
|
|
50
|
+
const { hasNotifications, NotificationsContextProvider } = useNotificationsState();
|
|
51
|
+
const { onNotificationsUpdate } = useNotificationsContext();
|
|
52
|
+
const onExpandToggle = (e: MouseEvent<never>) => {
|
|
53
|
+
e.stopPropagation();
|
|
54
|
+
setExpanded(!expanded);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
onNotificationsUpdate(id, hasNotifications);
|
|
59
|
+
}, [hasNotifications, onNotificationsUpdate]);
|
|
60
|
+
|
|
45
61
|
return (
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
62
|
+
<NotificationsContextProvider>
|
|
63
|
+
<InternalSideNavigationGroup
|
|
64
|
+
id={id}
|
|
65
|
+
to={undefined}
|
|
66
|
+
title="Profile"
|
|
67
|
+
icon={SvgAccountInactive}
|
|
68
|
+
iconActive={SvgAccountActive}
|
|
69
|
+
isActive={expanded}
|
|
70
|
+
{...props}
|
|
71
|
+
submenuExpanded={expanded}
|
|
72
|
+
onExpandToggle={onExpandToggle}
|
|
73
|
+
onClick={onExpandToggle}
|
|
74
|
+
tag={{ value: hasNotifications }}
|
|
75
|
+
>
|
|
76
|
+
{children}
|
|
77
|
+
</InternalSideNavigationGroup>
|
|
78
|
+
</NotificationsContextProvider>
|
|
61
79
|
);
|
|
62
80
|
};
|
|
63
81
|
|
|
@@ -106,17 +124,22 @@ const ProfileDropdownLink: FC<ProfileDropdownLinkProps> = props => {
|
|
|
106
124
|
);
|
|
107
125
|
};
|
|
108
126
|
const MobileProfileDropdownLink: FC<ProfileDropdownLinkProps & NavigationComponentProps> = ({
|
|
127
|
+
external,
|
|
109
128
|
to,
|
|
110
129
|
navigationComponent,
|
|
111
130
|
...props
|
|
112
131
|
}) => {
|
|
132
|
+
const { onNotificationsUpdate } = useNotificationsContext();
|
|
113
133
|
const text = getText(props);
|
|
134
|
+
const isExternalLink = external ?? to?.startsWith('http');
|
|
135
|
+
onNotificationsUpdate(props.id, !!props.tag?.value);
|
|
136
|
+
|
|
114
137
|
return text ? (
|
|
115
138
|
<InternalSideNavigationGroupLink
|
|
116
139
|
{...props}
|
|
117
140
|
to={to}
|
|
118
141
|
title={text}
|
|
119
|
-
navigationComponent={navigationComponent}
|
|
142
|
+
navigationComponent={isExternalLink ? ExternalNavComponent : navigationComponent}
|
|
120
143
|
/>
|
|
121
144
|
) : null;
|
|
122
145
|
};
|
|
@@ -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>;
|
|
@@ -21,6 +22,10 @@ export function TitanLayoutSidebarLink({ wrapper, ...props }: TitanLayoutSidebar
|
|
|
21
22
|
NavigationComponent,
|
|
22
23
|
breakpoint: { isMobile },
|
|
23
24
|
} = useTitanLayoutContext();
|
|
25
|
+
const { onNotificationsUpdate } = useNotificationsContext();
|
|
26
|
+
const tag = getCounterTag(props.counter, props.tag);
|
|
27
|
+
|
|
28
|
+
onNotificationsUpdate(props.id, !!tag);
|
|
24
29
|
|
|
25
30
|
const element = (
|
|
26
31
|
<InternalSideNavigationLink
|
|
@@ -28,7 +33,7 @@ export function TitanLayoutSidebarLink({ wrapper, ...props }: TitanLayoutSidebar
|
|
|
28
33
|
navigationComponent={NavigationComponent}
|
|
29
34
|
submenuExpanded={undefined}
|
|
30
35
|
dataPrefix="navigation-link"
|
|
31
|
-
tag={
|
|
36
|
+
tag={tag}
|
|
32
37
|
/>
|
|
33
38
|
);
|
|
34
39
|
|
|
@@ -45,13 +50,17 @@ export function TitanLayoutSidebarTrigger({
|
|
|
45
50
|
const {
|
|
46
51
|
breakpoint: { isMobile },
|
|
47
52
|
} = useTitanLayoutContext();
|
|
53
|
+
const { onNotificationsUpdate } = useNotificationsContext();
|
|
54
|
+
const tag = getCounterTag(props.counter, props.tag);
|
|
55
|
+
|
|
56
|
+
onNotificationsUpdate(props.id, !!tag);
|
|
48
57
|
|
|
49
58
|
const element = (
|
|
50
59
|
<InternalSideNavigationTrigger
|
|
51
60
|
{...props}
|
|
52
61
|
submenuExpanded={undefined}
|
|
53
62
|
dataPrefix="navigation-trigger"
|
|
54
|
-
tag={
|
|
63
|
+
tag={tag}
|
|
55
64
|
onClick={isMobile && !!onMobileClick ? onMobileClick : onClick}
|
|
56
65
|
/>
|
|
57
66
|
);
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
position: fixed;
|
|
22
22
|
max-width: 400px;
|
|
23
23
|
width: 0;
|
|
24
|
+
height: 100vh;
|
|
24
25
|
top: 0;
|
|
25
|
-
bottom: 0;
|
|
26
26
|
left: 0;
|
|
27
27
|
z-index: 991;
|
|
28
28
|
|
|
@@ -61,6 +61,16 @@
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
.nav-drawer-backdrop {
|
|
65
|
+
position: fixed;
|
|
66
|
+
height: 100vh;
|
|
67
|
+
width: 100vw;
|
|
68
|
+
top: 0;
|
|
69
|
+
left: 0;
|
|
70
|
+
z-index: 991;
|
|
71
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
72
|
+
}
|
|
73
|
+
|
|
64
74
|
// mobile version opened
|
|
65
75
|
.nav-drawer-opened {
|
|
66
76
|
display: flex;
|
|
@@ -142,6 +152,11 @@
|
|
|
142
152
|
.nav-wide {
|
|
143
153
|
width: var(--nav-offset-left);
|
|
144
154
|
|
|
155
|
+
.nav-item {
|
|
156
|
+
margin-left: @spacing-1;
|
|
157
|
+
margin-right: @spacing-1;
|
|
158
|
+
}
|
|
159
|
+
|
|
145
160
|
.toggle {
|
|
146
161
|
.toggle-content {
|
|
147
162
|
margin: @spacing-2;
|
|
@@ -171,8 +186,6 @@
|
|
|
171
186
|
.nav-wide {
|
|
172
187
|
.nav-item {
|
|
173
188
|
flex-direction: row;
|
|
174
|
-
margin-left: @spacing-1;
|
|
175
|
-
margin-right: @spacing-1;
|
|
176
189
|
|
|
177
190
|
.nav-item-icon-wrapper {
|
|
178
191
|
flex: 1;
|
|
@@ -5,6 +5,7 @@ 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
10
|
export const navFooter: string;
|
|
10
11
|
export const navGroupItem: string;
|
|
@@ -33,9 +33,11 @@ export interface LayoutSidebarProps {
|
|
|
33
33
|
mainItems?: NavigationItemData[];
|
|
34
34
|
barExpanded: boolean;
|
|
35
35
|
submenuExpanded: string | undefined;
|
|
36
|
+
drawerOpened: boolean;
|
|
36
37
|
mobile: boolean;
|
|
37
38
|
navigationComponent: FC<NavLinkComponentProps>;
|
|
38
39
|
onBarExpandChange(expanded: boolean): void;
|
|
40
|
+
onDrawerOpenChange(expanded: boolean): void;
|
|
39
41
|
onSubmenuExpandChange(id: string, expanded: boolean): void;
|
|
40
42
|
}
|
|
41
43
|
|
|
@@ -44,29 +46,36 @@ export const LayoutSidebar: FC<LayoutSidebarProps> = ({
|
|
|
44
46
|
mobile,
|
|
45
47
|
barExpanded,
|
|
46
48
|
submenuExpanded,
|
|
49
|
+
drawerOpened,
|
|
47
50
|
onBarExpandChange,
|
|
48
51
|
onSubmenuExpandChange,
|
|
52
|
+
onDrawerOpenChange,
|
|
49
53
|
mainItems,
|
|
50
54
|
top,
|
|
51
55
|
bottom,
|
|
52
56
|
navigationComponent,
|
|
53
57
|
}) => {
|
|
54
|
-
const
|
|
55
|
-
|
|
58
|
+
const closeDrawer = () => {
|
|
59
|
+
if (mobile) {
|
|
60
|
+
onDrawerOpenChange?.(false);
|
|
61
|
+
}
|
|
56
62
|
};
|
|
57
63
|
|
|
58
64
|
return (
|
|
59
65
|
<LayoutPlacementContext.Provider value="side">
|
|
66
|
+
{mobile && drawerOpened && (
|
|
67
|
+
<div className={Styles.navDrawerBackdrop} onClick={closeDrawer} />
|
|
68
|
+
)}
|
|
60
69
|
<div
|
|
61
70
|
className={classNames(
|
|
62
71
|
Styles.nav,
|
|
63
72
|
mobile && Styles.navDrawer,
|
|
64
|
-
mobile &&
|
|
73
|
+
mobile && drawerOpened && Styles.navDrawerOpened,
|
|
65
74
|
!mobile && (barExpanded ? Styles.navWide : Styles.navSlim),
|
|
66
75
|
className
|
|
67
76
|
)}
|
|
68
77
|
data-cy="side-navigation"
|
|
69
|
-
onClick={
|
|
78
|
+
onClick={closeDrawer}
|
|
70
79
|
>
|
|
71
80
|
<ThemeProvider mode="dark" className={Styles.navMain}>
|
|
72
81
|
{mobile && (
|
|
@@ -86,7 +95,7 @@ export const LayoutSidebar: FC<LayoutSidebarProps> = ({
|
|
|
86
95
|
item.submenu ? (
|
|
87
96
|
<SideNavigationGroupItem
|
|
88
97
|
key={item.id}
|
|
89
|
-
barExpanded={barExpanded}
|
|
98
|
+
barExpanded={mobile ? drawerOpened : barExpanded}
|
|
90
99
|
submenuExpanded={!!item.id && submenuExpanded === item.id}
|
|
91
100
|
onSubmenuExpand={onSubmenuExpandChange}
|
|
92
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
|
+
};
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
margin-top: var(--nav-offset-top);
|
|
14
14
|
|
|
15
15
|
display: flex;
|
|
16
|
-
flex-direction:
|
|
16
|
+
flex-direction: column;
|
|
17
17
|
|
|
18
18
|
.side {
|
|
19
19
|
flex-basis: var(--nav-offset-left);
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
.layout-anvil2 {
|
|
34
|
-
.header {
|
|
34
|
+
.content-header {
|
|
35
35
|
position: sticky;
|
|
36
36
|
top: var(--nav-offset-top);
|
|
37
37
|
z-index: 989;
|
|
@@ -53,17 +53,22 @@
|
|
|
53
53
|
|
|
54
54
|
.layout-legacy,
|
|
55
55
|
.layout-anvil2 {
|
|
56
|
+
overflow-x: auto;
|
|
56
57
|
.top-placeholder {
|
|
57
58
|
height: var(--nav-offset-top);
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
.layout {
|
|
62
|
-
--nav-offset-top:
|
|
63
|
+
--nav-offset-top: 0;
|
|
64
|
+
--nav-offset-left: 0;
|
|
63
65
|
|
|
64
|
-
&.layout-
|
|
65
|
-
--nav-offset-top:
|
|
66
|
-
|
|
66
|
+
&.layout-desktop.layout-top {
|
|
67
|
+
--nav-offset-top: 48px;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
&.layout-mobile.layout-top {
|
|
71
|
+
--nav-offset-top: 72px;
|
|
67
72
|
}
|
|
68
73
|
|
|
69
74
|
&.layout-desktop.layout-nav-slim {
|
|
@@ -76,9 +81,27 @@
|
|
|
76
81
|
|
|
77
82
|
.top {
|
|
78
83
|
position: fixed;
|
|
84
|
+
width: 100vw;
|
|
79
85
|
top: 0;
|
|
80
86
|
left: 0;
|
|
81
|
-
right: 0;
|
|
82
87
|
z-index: 991;
|
|
83
88
|
}
|
|
89
|
+
|
|
90
|
+
.content-header {
|
|
91
|
+
position: sticky;
|
|
92
|
+
left: 0;
|
|
93
|
+
right: 0;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@media print {
|
|
98
|
+
.layout {
|
|
99
|
+
--nav-offset-left: 0px !important;
|
|
100
|
+
--nav-offset-right: 0px !important;
|
|
101
|
+
|
|
102
|
+
.side,
|
|
103
|
+
.top {
|
|
104
|
+
display: none !important;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
84
107
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const __esModule: true;
|
|
2
2
|
export const content: string;
|
|
3
|
-
export const
|
|
3
|
+
export const contentHeader: string;
|
|
4
4
|
export const layout: string;
|
|
5
5
|
export const layoutAnvil1: string;
|
|
6
6
|
export const layoutAnvil2: string;
|
|
@@ -9,6 +9,7 @@ export const layoutLegacy: string;
|
|
|
9
9
|
export const layoutMobile: string;
|
|
10
10
|
export const layoutNavSlim: string;
|
|
11
11
|
export const layoutNavWide: string;
|
|
12
|
+
export const layoutTop: string;
|
|
12
13
|
export const side: string;
|
|
13
14
|
export const top: string;
|
|
14
15
|
export const topPlaceholder: string;
|