@servicetitan/navigation 11.0.0-canary.237.64cfcfe.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/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 +10 -7
- 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 +44 -6
- 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 +32 -8
- 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 +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 +43 -20
- package/dist/components/titan-layout/titan-layout.stories.d.ts +5 -0
- package/dist/components/titan-layout/titan-layout.stories.d.ts.map +1 -1
- package/dist/components/titan-layout/titan-layout.stories.js +18 -7
- 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/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.tsx +13 -6
- package/src/components/titan-layout/layout-header.module.less +44 -6
- 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 +10 -1
- package/src/components/titan-layout/layout-profile.tsx +60 -25
- 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 +43 -20
- package/src/components/titan-layout/titan-layout.module.less.d.ts +2 -1
- package/src/components/titan-layout/titan-layout.stories.tsx +118 -7
- package/src/components/titan-layout/titan-layout.tsx +132 -75
- package/src/test/data.tsx +2 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Announcement, Page as Anvil2Page, Button, Popover } from '@servicetitan/anvil2';
|
|
1
|
+
import { Announcement, Page as Anvil2Page, Button, Popover, TextField } from '@servicetitan/anvil2';
|
|
2
2
|
import SvgSearch from '@servicetitan/anvil2/assets/icons/material/round/search.svg';
|
|
3
3
|
import SvgAtlas from '@servicetitan/anvil2/assets/icons/st/atlas_logo.svg';
|
|
4
4
|
import SvgSettingsActive from '@servicetitan/anvil2/assets/icons/st/gnav_settings_active.svg';
|
|
@@ -24,6 +24,11 @@ interface LayoutContentArgs {
|
|
|
24
24
|
header: boolean;
|
|
25
25
|
sideTop: boolean;
|
|
26
26
|
extraText: boolean;
|
|
27
|
+
search: boolean;
|
|
28
|
+
longContent: boolean;
|
|
29
|
+
wideContent: boolean;
|
|
30
|
+
minWidth: boolean;
|
|
31
|
+
emptyNav: boolean;
|
|
27
32
|
}
|
|
28
33
|
|
|
29
34
|
export default {
|
|
@@ -35,6 +40,11 @@ export default {
|
|
|
35
40
|
header: true,
|
|
36
41
|
sideTop: true,
|
|
37
42
|
extraText: true,
|
|
43
|
+
search: true,
|
|
44
|
+
longContent: true,
|
|
45
|
+
wideContent: false,
|
|
46
|
+
minWidth: false,
|
|
47
|
+
emptyNav: false,
|
|
38
48
|
} as LayoutContentArgs,
|
|
39
49
|
};
|
|
40
50
|
|
|
@@ -62,6 +72,7 @@ const profile = (
|
|
|
62
72
|
to="https://google.com"
|
|
63
73
|
tooltip="Google it"
|
|
64
74
|
target="_blank"
|
|
75
|
+
tag={{ value: true }}
|
|
65
76
|
>
|
|
66
77
|
first link
|
|
67
78
|
</ProfileDropdown.Link>
|
|
@@ -174,6 +185,10 @@ const ContentHeader = () => {
|
|
|
174
185
|
</Fragment>
|
|
175
186
|
);
|
|
176
187
|
};
|
|
188
|
+
const SearchBar = () => (
|
|
189
|
+
<TextField size="small" placeholder="Search" className="w-100-i m-x-half-i" />
|
|
190
|
+
);
|
|
191
|
+
|
|
177
192
|
const useLayoutProps = (args: LayoutContentArgs): TitanLayoutProps => {
|
|
178
193
|
const [state, setState] = useState<TitanLayoutState | undefined>(undefined);
|
|
179
194
|
|
|
@@ -182,25 +197,121 @@ const useLayoutProps = (args: LayoutContentArgs): TitanLayoutProps => {
|
|
|
182
197
|
onStateChange: setState,
|
|
183
198
|
|
|
184
199
|
navigationComponent: NavLinkMock,
|
|
185
|
-
navigationMainItems: mainNavItems,
|
|
200
|
+
navigationMainItems: args.emptyNav ? [] : mainNavItems,
|
|
186
201
|
|
|
187
202
|
profile,
|
|
188
|
-
|
|
203
|
+
top: args.search ? <SearchBar /> : undefined,
|
|
189
204
|
header: args.header ? <ContentHeader /> : undefined,
|
|
190
205
|
|
|
191
206
|
extraLinks,
|
|
192
207
|
extraLinksTop,
|
|
193
208
|
extraText: args.extraText ? 'EST (-8 hrs)' : undefined,
|
|
194
209
|
|
|
195
|
-
sideTop: args.sideTop ? sidebarTop() : undefined,
|
|
210
|
+
sideTop: args.sideTop && !args.emptyNav ? sidebarTop() : undefined,
|
|
211
|
+
|
|
212
|
+
minContentWidth: args.minWidth ? 900 : undefined,
|
|
196
213
|
};
|
|
197
214
|
};
|
|
198
215
|
|
|
216
|
+
const Content = (args: LayoutContentArgs) => {
|
|
217
|
+
return (
|
|
218
|
+
<Fragment>
|
|
219
|
+
<LocationInfo className="m-b-3" />
|
|
220
|
+
{args.wideContent && (
|
|
221
|
+
<div style={{ width: '1200px' }}>
|
|
222
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
|
|
223
|
+
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
|
|
224
|
+
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
|
225
|
+
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
|
|
226
|
+
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
|
|
227
|
+
culpa qui officia deserunt mollit anim id est laborum.
|
|
228
|
+
</div>
|
|
229
|
+
)}
|
|
230
|
+
|
|
231
|
+
{args.longContent && (
|
|
232
|
+
<div>
|
|
233
|
+
<p>Lorem</p>
|
|
234
|
+
<p>ipsum</p>
|
|
235
|
+
<p>dolor</p>
|
|
236
|
+
<p>sit</p>
|
|
237
|
+
<p>amet,</p>
|
|
238
|
+
<p>consectetur</p>
|
|
239
|
+
<p>adipiscing</p>
|
|
240
|
+
<p>elit,</p>
|
|
241
|
+
<p>sed</p>
|
|
242
|
+
<p>do</p>
|
|
243
|
+
<p>eiusmod</p>
|
|
244
|
+
<p>tempor</p>
|
|
245
|
+
<p>incididunt</p>
|
|
246
|
+
<p>ut</p>
|
|
247
|
+
<p>labore</p>
|
|
248
|
+
<p>et</p>
|
|
249
|
+
<p>dolore</p>
|
|
250
|
+
<p>magna</p>
|
|
251
|
+
<p>aliqua.</p>
|
|
252
|
+
<p>Ut</p>
|
|
253
|
+
<p>enim</p>
|
|
254
|
+
<p>ad</p>
|
|
255
|
+
<p>minim</p>
|
|
256
|
+
<p>veniam,</p>
|
|
257
|
+
<p>quis</p>
|
|
258
|
+
<p>nostrud</p>
|
|
259
|
+
<p>exercitation</p>
|
|
260
|
+
<p>ullamco</p>
|
|
261
|
+
<p>laboris</p>
|
|
262
|
+
<p>nisi</p>
|
|
263
|
+
<p>ut</p>
|
|
264
|
+
<p>aliquip</p>
|
|
265
|
+
<p>ex</p>
|
|
266
|
+
<p>ea</p>
|
|
267
|
+
<p>commodo</p>
|
|
268
|
+
<p>consequat.</p>
|
|
269
|
+
<p>Duis</p>
|
|
270
|
+
<p>aute</p>
|
|
271
|
+
<p>irure</p>
|
|
272
|
+
<p>dolor</p>
|
|
273
|
+
<p>in</p>
|
|
274
|
+
<p>reprehenderit</p>
|
|
275
|
+
<p>in</p>
|
|
276
|
+
<p>voluptate</p>
|
|
277
|
+
<p>velit</p>
|
|
278
|
+
<p>esse</p>
|
|
279
|
+
<p>cillum</p>
|
|
280
|
+
<p>dolore</p>
|
|
281
|
+
<p>eu</p>
|
|
282
|
+
<p>fugiat</p>
|
|
283
|
+
<p>nulla</p>
|
|
284
|
+
<p>pariatur.</p>
|
|
285
|
+
<p>Excepteur</p>
|
|
286
|
+
<p>sint</p>
|
|
287
|
+
<p>occaecat</p>
|
|
288
|
+
<p>cupidatat</p>
|
|
289
|
+
<p>non</p>
|
|
290
|
+
<p>proident,</p>
|
|
291
|
+
<p>sunt</p>
|
|
292
|
+
<p>in</p>
|
|
293
|
+
<p>culpa</p>
|
|
294
|
+
<p>qui</p>
|
|
295
|
+
<p>officia</p>
|
|
296
|
+
<p>deserunt</p>
|
|
297
|
+
<p>mollit</p>
|
|
298
|
+
<p>anim</p>
|
|
299
|
+
<p>id</p>
|
|
300
|
+
<p>est</p>
|
|
301
|
+
<p>laborum.</p>
|
|
302
|
+
</div>
|
|
303
|
+
)}
|
|
304
|
+
</Fragment>
|
|
305
|
+
);
|
|
306
|
+
};
|
|
307
|
+
|
|
199
308
|
export const TitanLayoutLegacy = (args: LayoutContentArgs) => (
|
|
200
309
|
<TitanLayout {...useLayoutProps(args)} appearance="legacy">
|
|
201
310
|
<TitanLayout.Logo title />
|
|
202
311
|
<TitanLayout.Content>
|
|
203
|
-
<
|
|
312
|
+
<div className="p-3">
|
|
313
|
+
<Content {...args} />
|
|
314
|
+
</div>
|
|
204
315
|
</TitanLayout.Content>
|
|
205
316
|
</TitanLayout>
|
|
206
317
|
);
|
|
@@ -210,7 +321,7 @@ export const TitanLayoutAnvil1 = (args: LayoutContentArgs) => (
|
|
|
210
321
|
<TitanLayout.Logo title />
|
|
211
322
|
<TitanLayout.Content>
|
|
212
323
|
<Anvil1Page>
|
|
213
|
-
<
|
|
324
|
+
<Content {...args} />
|
|
214
325
|
</Anvil1Page>
|
|
215
326
|
</TitanLayout.Content>
|
|
216
327
|
</TitanLayout>
|
|
@@ -222,7 +333,7 @@ export const TitanLayoutAnvil2 = (args: LayoutContentArgs) => (
|
|
|
222
333
|
<TitanLayout.Content>
|
|
223
334
|
<Anvil2Page>
|
|
224
335
|
<Anvil2Page.Content>
|
|
225
|
-
<
|
|
336
|
+
<Content {...args} />
|
|
226
337
|
</Anvil2Page.Content>
|
|
227
338
|
</Anvil2Page>
|
|
228
339
|
</TitanLayout.Content>
|
|
@@ -29,24 +29,27 @@ import { TitanLayoutLogo, TitanLayoutLogoProps } from './layout-logo';
|
|
|
29
29
|
import { LayoutSidebar } from './layout-sidebar';
|
|
30
30
|
import { TitanLayoutSidebarLink, TitanLayoutSidebarTrigger } from './layout-sidebar-links';
|
|
31
31
|
import { InternalSideNavigationTrigger } from './layout-sidebar-links-internal';
|
|
32
|
+
import { useNotificationsState } from './notifications-context';
|
|
32
33
|
import * as Styles from './titan-layout.module.less';
|
|
33
34
|
|
|
34
35
|
type TitanLayoutChild = ReactElement<TitanLayoutContentProps> | ReactElement<TitanLayoutLogoProps>;
|
|
35
36
|
|
|
36
37
|
export type TitanLayoutProps = Omit<ComponentPropsWithoutRef<'div'>, 'children' | 'style'> & {
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
/** layout appearance */
|
|
39
39
|
appearance?: 'legacy' | 'anvil1' | 'anvil2';
|
|
40
40
|
|
|
41
|
+
/** layout's content */
|
|
42
|
+
children?: TitanLayoutChild | TitanLayoutChild[];
|
|
43
|
+
|
|
44
|
+
/** show only content without side and top bars */
|
|
45
|
+
contentOnly?: boolean;
|
|
46
|
+
|
|
41
47
|
/** component used for navigation */
|
|
42
48
|
navigationComponent?: FC<NavLinkComponentProps>;
|
|
43
49
|
|
|
44
50
|
/** data for main navigation links */
|
|
45
51
|
navigationMainItems?: NavigationItemData[];
|
|
46
52
|
|
|
47
|
-
/** layout's content */
|
|
48
|
-
children?: TitanLayoutChild | TitanLayoutChild[];
|
|
49
|
-
|
|
50
53
|
state?: TitanLayoutState;
|
|
51
54
|
onStateChange?: (state: TitanLayoutState) => void;
|
|
52
55
|
|
|
@@ -57,6 +60,7 @@ export type TitanLayoutProps = Omit<ComponentPropsWithoutRef<'div'>, 'children'
|
|
|
57
60
|
extraLinks?: ReactElement;
|
|
58
61
|
extraLinksTop?: ReactElement;
|
|
59
62
|
extraText?: string;
|
|
63
|
+
minContentWidth?: number;
|
|
60
64
|
};
|
|
61
65
|
|
|
62
66
|
const defaultSidebarContext: TitanLayoutSidebarContextType = {
|
|
@@ -115,6 +119,7 @@ const TitanLayoutComponent: FC<TitanLayoutProps> = ({
|
|
|
115
119
|
appearance = 'anvil2',
|
|
116
120
|
id,
|
|
117
121
|
children,
|
|
122
|
+
contentOnly,
|
|
118
123
|
navigationComponent,
|
|
119
124
|
header,
|
|
120
125
|
top,
|
|
@@ -125,10 +130,10 @@ const TitanLayoutComponent: FC<TitanLayoutProps> = ({
|
|
|
125
130
|
extraLinks,
|
|
126
131
|
extraLinksTop,
|
|
127
132
|
extraText,
|
|
133
|
+
minContentWidth,
|
|
128
134
|
sideTop,
|
|
129
135
|
}) => {
|
|
130
136
|
const breakpoint = useTitanBreakpoint();
|
|
131
|
-
const isMobile = breakpoint.isMobile;
|
|
132
137
|
const context: TitanLayoutContextType = useMemo(
|
|
133
138
|
() => ({
|
|
134
139
|
NavigationComponent: navigationComponent ?? DefaultNavLinkComponent,
|
|
@@ -141,21 +146,19 @@ const TitanLayoutComponent: FC<TitanLayoutProps> = ({
|
|
|
141
146
|
const variant = useVariant(appearance);
|
|
142
147
|
const [mobileDrawerOpened, setMobileDrawerOpened] = useState(false);
|
|
143
148
|
const { content, logo } = useLayoutChildren(children);
|
|
149
|
+
const { hasNotifications, NotificationsContextProvider } = useNotificationsState();
|
|
150
|
+
|
|
151
|
+
const isMobile = breakpoint.isMobile;
|
|
152
|
+
const hasSideBar = !contentOnly && (!!navigationMainItems?.length || !!sideTop?.length);
|
|
153
|
+
const hasTopBar = !contentOnly;
|
|
144
154
|
|
|
145
155
|
useEffect(() => {
|
|
146
|
-
if (
|
|
147
|
-
|
|
148
|
-
|
|
156
|
+
if (variant.isAnvil1) {
|
|
157
|
+
const bodyClassName = 'of-hidden-i';
|
|
158
|
+
document.body.classList.add(bodyClassName);
|
|
159
|
+
return () => document.body.classList.remove(bodyClassName);
|
|
149
160
|
}
|
|
150
|
-
|
|
151
|
-
const listener = () => {
|
|
152
|
-
setMobileDrawerOpened(false);
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
document.addEventListener('click', listener);
|
|
156
|
-
|
|
157
|
-
return () => document.removeEventListener('click', listener);
|
|
158
|
-
}, [isMobile]);
|
|
161
|
+
}, [variant.isAnvil1]);
|
|
159
162
|
|
|
160
163
|
const onBurgerClick = useCallback((e: MouseEvent) => {
|
|
161
164
|
setMobileDrawerOpened(true);
|
|
@@ -181,6 +184,24 @@ const TitanLayoutComponent: FC<TitanLayoutProps> = ({
|
|
|
181
184
|
},
|
|
182
185
|
[state, onStateChange]
|
|
183
186
|
);
|
|
187
|
+
const hasMenuNotifications = useMemo(() => {
|
|
188
|
+
try {
|
|
189
|
+
return (
|
|
190
|
+
navigationMainItems?.some(item => {
|
|
191
|
+
if (item.counter || item.tag?.value) {
|
|
192
|
+
return true;
|
|
193
|
+
} else if (item.submenu) {
|
|
194
|
+
return item.submenu.groups.some(group =>
|
|
195
|
+
group.links.some(link => !!link.counter || !!link.tag?.value)
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
return false;
|
|
199
|
+
}) ?? false
|
|
200
|
+
);
|
|
201
|
+
} catch {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
}, [navigationMainItems]);
|
|
184
205
|
|
|
185
206
|
const layoutClass = variant.isLegacy
|
|
186
207
|
? Styles.layoutLegacy
|
|
@@ -196,60 +217,76 @@ const TitanLayoutComponent: FC<TitanLayoutProps> = ({
|
|
|
196
217
|
className={classNames(
|
|
197
218
|
Styles.layout,
|
|
198
219
|
isMobile ? Styles.layoutMobile : Styles.layoutDesktop,
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
:
|
|
220
|
+
{
|
|
221
|
+
[Styles.layoutTop]: hasTopBar,
|
|
222
|
+
[Styles.layoutNavSlim]: !isMobile && hasSideBar && state?.navCollapsed,
|
|
223
|
+
[Styles.layoutNavWide]: !isMobile && hasSideBar && !state?.navCollapsed,
|
|
224
|
+
},
|
|
202
225
|
layoutClass
|
|
203
226
|
)}
|
|
204
227
|
>
|
|
205
228
|
{variant.isSequent && <div className={Styles.topPlaceholder} />}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
{extraLinksTop}
|
|
215
|
-
{!isMobile && extraLinks}
|
|
216
|
-
</Fragment>
|
|
217
|
-
}
|
|
218
|
-
onBurgerClick={onBurgerClick}
|
|
219
|
-
/>
|
|
220
|
-
|
|
221
|
-
<LayoutSidebar
|
|
222
|
-
className={Styles.side}
|
|
223
|
-
mobile={breakpoint.isMobile}
|
|
224
|
-
barExpanded={isMobile ? mobileDrawerOpened : !state?.navCollapsed}
|
|
225
|
-
submenuExpanded={state?.submenuExpanded}
|
|
226
|
-
onBarExpandChange={onBarExpandChange}
|
|
227
|
-
onSubmenuExpandChange={onSubmenuExpandChange}
|
|
228
|
-
top={sideTop}
|
|
229
|
-
mainItems={navigationMainItems}
|
|
230
|
-
navigationComponent={context.NavigationComponent}
|
|
231
|
-
bottom={
|
|
232
|
-
isMobile ? (
|
|
229
|
+
{hasTopBar && (
|
|
230
|
+
<LayoutHeader
|
|
231
|
+
className={Styles.top}
|
|
232
|
+
logo={logo}
|
|
233
|
+
profile={isMobile ? undefined : profile}
|
|
234
|
+
center={top}
|
|
235
|
+
rightText={isMobile ? undefined : extraText}
|
|
236
|
+
right={
|
|
233
237
|
<Fragment>
|
|
234
|
-
{
|
|
235
|
-
{extraLinks}
|
|
236
|
-
{!!extraText && (
|
|
237
|
-
<InternalSideNavigationTrigger
|
|
238
|
-
id="__extra_text"
|
|
239
|
-
title={extraText}
|
|
240
|
-
submenuExpanded={undefined}
|
|
241
|
-
dataPrefix="navigation-extra-text"
|
|
242
|
-
tag={undefined}
|
|
243
|
-
icon={undefined}
|
|
244
|
-
iconActive={undefined}
|
|
245
|
-
/>
|
|
246
|
-
)}
|
|
238
|
+
{extraLinksTop}
|
|
239
|
+
{!isMobile && extraLinks}
|
|
247
240
|
</Fragment>
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
241
|
+
}
|
|
242
|
+
isMobile={isMobile}
|
|
243
|
+
hasNotifications={hasNotifications || hasMenuNotifications}
|
|
244
|
+
onBurgerClick={onBurgerClick}
|
|
245
|
+
/>
|
|
246
|
+
)}
|
|
251
247
|
|
|
252
|
-
|
|
248
|
+
{hasSideBar && (
|
|
249
|
+
<NotificationsContextProvider>
|
|
250
|
+
<LayoutSidebar
|
|
251
|
+
className={Styles.side}
|
|
252
|
+
mobile={breakpoint.isMobile}
|
|
253
|
+
barExpanded={!state?.navCollapsed}
|
|
254
|
+
onBarExpandChange={onBarExpandChange}
|
|
255
|
+
submenuExpanded={state?.submenuExpanded}
|
|
256
|
+
onSubmenuExpandChange={onSubmenuExpandChange}
|
|
257
|
+
drawerOpened={mobileDrawerOpened}
|
|
258
|
+
onDrawerOpenChange={setMobileDrawerOpened}
|
|
259
|
+
top={sideTop}
|
|
260
|
+
mainItems={navigationMainItems}
|
|
261
|
+
navigationComponent={context.NavigationComponent}
|
|
262
|
+
bottom={
|
|
263
|
+
isMobile ? (
|
|
264
|
+
<Fragment>
|
|
265
|
+
{profile}
|
|
266
|
+
{extraLinks}
|
|
267
|
+
{!!extraText && (
|
|
268
|
+
<InternalSideNavigationTrigger
|
|
269
|
+
id="__extra_text"
|
|
270
|
+
title={extraText}
|
|
271
|
+
submenuExpanded={undefined}
|
|
272
|
+
dataPrefix="navigation-extra-text"
|
|
273
|
+
tag={undefined}
|
|
274
|
+
icon={undefined}
|
|
275
|
+
iconActive={undefined}
|
|
276
|
+
/>
|
|
277
|
+
)}
|
|
278
|
+
</Fragment>
|
|
279
|
+
) : undefined
|
|
280
|
+
}
|
|
281
|
+
/>
|
|
282
|
+
</NotificationsContextProvider>
|
|
283
|
+
)}
|
|
284
|
+
<LayoutContent
|
|
285
|
+
header={header}
|
|
286
|
+
anvil2={variant.isAnvil2}
|
|
287
|
+
anvil1={variant.isAnvil1}
|
|
288
|
+
minWidth={minContentWidth}
|
|
289
|
+
>
|
|
253
290
|
{content}
|
|
254
291
|
</LayoutContent>
|
|
255
292
|
</div>
|
|
@@ -287,7 +324,7 @@ const TitanLayoutHeaderObserved: FC<{
|
|
|
287
324
|
};
|
|
288
325
|
}, [heightChange]);
|
|
289
326
|
return (
|
|
290
|
-
<div ref={ref} className={Styles.header
|
|
327
|
+
<div ref={ref} className={Styles.contentHeader} data-cy="layout-content-header">
|
|
291
328
|
{children}
|
|
292
329
|
</div>
|
|
293
330
|
);
|
|
@@ -298,28 +335,48 @@ export interface TitanLayoutContentProps {
|
|
|
298
335
|
}
|
|
299
336
|
const TitanLayoutContent: FC<TitanLayoutContentProps> = ({ children }) => children;
|
|
300
337
|
|
|
301
|
-
const LayoutContent: FC<{
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
338
|
+
const LayoutContent: FC<{
|
|
339
|
+
children: ReactNode;
|
|
340
|
+
header?: ReactNode;
|
|
341
|
+
anvil1: boolean;
|
|
342
|
+
anvil2: boolean;
|
|
343
|
+
minWidth: number | undefined;
|
|
344
|
+
}> = ({ anvil1, anvil2, children, header, minWidth }) => {
|
|
306
345
|
const [anvil2Styles, setAnvil2Styles] = useState<object>({});
|
|
307
346
|
const updateIndicatorsHeight = useCallback((offset: number) => {
|
|
308
347
|
setAnvil2Styles({ '--offset': `calc(var(--nav-offset-top) + ${offset}px)` });
|
|
309
348
|
}, []);
|
|
310
349
|
|
|
350
|
+
const contentStyles = useMemo(
|
|
351
|
+
() => ({
|
|
352
|
+
...(minWidth ? { minWidth: `${minWidth}px` } : {}),
|
|
353
|
+
...(anvil2 ? anvil2Styles : {}),
|
|
354
|
+
}),
|
|
355
|
+
[anvil2, minWidth, anvil2Styles]
|
|
356
|
+
);
|
|
357
|
+
|
|
311
358
|
return (
|
|
312
|
-
<
|
|
359
|
+
<Fragment>
|
|
313
360
|
{!!header &&
|
|
314
361
|
(anvil2 ? (
|
|
315
362
|
<TitanLayoutHeaderObserved heightChange={updateIndicatorsHeight}>
|
|
316
363
|
{header}
|
|
317
364
|
</TitanLayoutHeaderObserved>
|
|
318
365
|
) : (
|
|
319
|
-
header
|
|
366
|
+
<div className={Styles.contentHeader} data-cy="layout-content-header">
|
|
367
|
+
{header}
|
|
368
|
+
</div>
|
|
320
369
|
))}
|
|
321
|
-
{
|
|
322
|
-
|
|
370
|
+
<div className={Styles.content} style={contentStyles} data-cy="layout-content">
|
|
371
|
+
{anvil1 ? (
|
|
372
|
+
<div className="position-relative d-f flex-grow-1 flex-basis-0 of-hidden">
|
|
373
|
+
{children}
|
|
374
|
+
</div>
|
|
375
|
+
) : (
|
|
376
|
+
children
|
|
377
|
+
)}
|
|
378
|
+
</div>
|
|
379
|
+
</Fragment>
|
|
323
380
|
);
|
|
324
381
|
};
|
|
325
382
|
|
package/src/test/data.tsx
CHANGED
|
@@ -66,7 +66,6 @@ export const NavLinkMock = forwardRef<any, NavLinkComponentProps>(
|
|
|
66
66
|
{...rest}
|
|
67
67
|
onClick={e => {
|
|
68
68
|
e.preventDefault();
|
|
69
|
-
e.stopPropagation();
|
|
70
69
|
|
|
71
70
|
if (!to.startsWith('http')) {
|
|
72
71
|
history.replace(to);
|
|
@@ -82,10 +81,10 @@ export const NavLinkMock = forwardRef<any, NavLinkComponentProps>(
|
|
|
82
81
|
}
|
|
83
82
|
);
|
|
84
83
|
|
|
85
|
-
export const LocationInfo = () => {
|
|
84
|
+
export const LocationInfo: FC<{ className?: string }> = ({ className }) => {
|
|
86
85
|
const location = useLocation();
|
|
87
86
|
|
|
88
|
-
return <BodyText>current location - {location.pathname}</BodyText>;
|
|
87
|
+
return <BodyText className={className}>current location - {location.pathname}</BodyText>;
|
|
89
88
|
};
|
|
90
89
|
|
|
91
90
|
const LocationProvider: FC<{ children: any }> = ({ children }) => {
|