@servicetitan/navigation 4.0.0 → 5.0.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/counter-tag.js +1 -1
- package/dist/components/counter-tag.js.map +1 -1
- package/dist/components/header-navigation/header-navigation-content.d.ts +0 -7
- package/dist/components/header-navigation/header-navigation-content.d.ts.map +1 -1
- package/dist/components/header-navigation/header-navigation-content.js +6 -7
- package/dist/components/header-navigation/header-navigation-content.js.map +1 -1
- package/dist/components/header-navigation/header-navigation-extra-stacked.stories.d.ts +9 -0
- package/dist/components/header-navigation/header-navigation-extra-stacked.stories.d.ts.map +1 -0
- package/dist/components/header-navigation/header-navigation-extra-stacked.stories.js +13 -0
- package/dist/components/header-navigation/header-navigation-extra-stacked.stories.js.map +1 -0
- package/dist/components/header-navigation/header-navigation-extra.stories.d.ts +5 -6
- package/dist/components/header-navigation/header-navigation-extra.stories.d.ts.map +1 -1
- package/dist/components/header-navigation/header-navigation-extra.stories.js +19 -11
- package/dist/components/header-navigation/header-navigation-extra.stories.js.map +1 -1
- package/dist/components/header-navigation/header-navigation-links.d.ts +2 -31
- package/dist/components/header-navigation/header-navigation-links.d.ts.map +1 -1
- package/dist/components/header-navigation/header-navigation-links.js +11 -30
- package/dist/components/header-navigation/header-navigation-links.js.map +1 -1
- package/dist/components/header-navigation/header-navigation-stacked.stories.d.ts +3 -3
- package/dist/components/header-navigation/header-navigation-stacked.stories.d.ts.map +1 -1
- package/dist/components/header-navigation/header-navigation-stacked.stories.js +9 -8
- package/dist/components/header-navigation/header-navigation-stacked.stories.js.map +1 -1
- package/dist/components/header-navigation/header-navigation.d.ts +1 -28
- package/dist/components/header-navigation/header-navigation.d.ts.map +1 -1
- package/dist/components/header-navigation/header-navigation.js +9 -24
- package/dist/components/header-navigation/header-navigation.js.map +1 -1
- package/dist/components/header-navigation/header-navigation.module.less +2 -84
- package/dist/components/header-navigation/header-navigation.stories.d.ts +3 -3
- package/dist/components/header-navigation/header-navigation.stories.d.ts.map +1 -1
- package/dist/components/header-navigation/header-navigation.stories.js +9 -8
- package/dist/components/header-navigation/header-navigation.stories.js.map +1 -1
- package/dist/components/header-navigation/index.d.ts +0 -1
- package/dist/components/header-navigation/index.d.ts.map +1 -1
- package/dist/components/header-navigation/index.js +0 -1
- package/dist/components/header-navigation/index.js.map +1 -1
- package/dist/components/layout.stories.js +3 -3
- package/dist/components/layout.stories.js.map +1 -1
- package/dist/components/left-navigation/header-navigation-extra-tiny.stories.d.ts +9 -0
- package/dist/components/left-navigation/header-navigation-extra-tiny.stories.d.ts.map +1 -0
- package/dist/components/left-navigation/header-navigation-extra-tiny.stories.js +13 -0
- package/dist/components/left-navigation/header-navigation-extra-tiny.stories.js.map +1 -0
- package/dist/components/left-navigation/header-navigation-tiny-links.d.ts +18 -0
- package/dist/components/left-navigation/header-navigation-tiny-links.d.ts.map +1 -0
- package/dist/components/left-navigation/header-navigation-tiny-links.js +30 -0
- package/dist/components/left-navigation/header-navigation-tiny-links.js.map +1 -0
- package/dist/components/left-navigation/header-navigation-tiny.d.ts +23 -0
- package/dist/components/left-navigation/header-navigation-tiny.d.ts.map +1 -0
- package/dist/components/left-navigation/header-navigation-tiny.js +7 -0
- package/dist/components/left-navigation/header-navigation-tiny.js.map +1 -0
- package/dist/components/left-navigation/header-navigation-tiny.module.less +117 -0
- package/dist/components/{header-navigation → left-navigation}/header-navigation-tiny.stories.d.ts +2 -2
- package/dist/components/left-navigation/header-navigation-tiny.stories.d.ts.map +1 -0
- package/dist/components/left-navigation/header-navigation-tiny.stories.js +30 -0
- package/dist/components/left-navigation/header-navigation-tiny.stories.js.map +1 -0
- package/dist/components/left-navigation/index.d.ts +3 -0
- package/dist/components/left-navigation/index.d.ts.map +1 -0
- package/dist/components/left-navigation/index.js +3 -0
- package/dist/components/left-navigation/index.js.map +1 -0
- package/dist/components/{side-navigation → left-navigation}/side-navigation.d.ts.map +1 -1
- package/dist/components/{side-navigation → left-navigation}/side-navigation.js +2 -2
- package/dist/components/left-navigation/side-navigation.js.map +1 -0
- package/dist/components/{side-navigation → left-navigation}/side-navigation.module.less +3 -3
- package/dist/components/{side-navigation → left-navigation}/side-navigation.stories.d.ts +0 -1
- package/dist/components/left-navigation/side-navigation.stories.d.ts.map +1 -0
- package/dist/components/{side-navigation → left-navigation}/side-navigation.stories.js +1 -1
- package/dist/components/{side-navigation → left-navigation}/side-navigation.stories.js.map +1 -1
- package/dist/components/links.d.ts +5 -0
- package/dist/components/links.d.ts.map +1 -0
- package/dist/components/links.js +14 -0
- package/dist/components/links.js.map +1 -0
- package/dist/components/logo/logo-titan.js +1 -1
- package/dist/components/logo/logo-titan.js.map +1 -1
- package/dist/components/logo/logo.stories.d.ts +6 -6
- package/dist/components/logo/logo.stories.d.ts.map +1 -1
- package/dist/components/logo/logo.stories.js +6 -6
- package/dist/components/logo/logo.stories.js.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown-stacked.stories.d.ts +1 -1
- package/dist/components/profile-dropdown/profile-dropdown-stacked.stories.d.ts.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown-stacked.stories.js +4 -4
- package/dist/components/profile-dropdown/profile-dropdown-stacked.stories.js.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown-tiny.stories.d.ts +1 -1
- package/dist/components/profile-dropdown/profile-dropdown-tiny.stories.d.ts.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown-tiny.stories.js +5 -5
- package/dist/components/profile-dropdown/profile-dropdown-tiny.stories.js.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.d.ts.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.js +9 -22
- package/dist/components/profile-dropdown/profile-dropdown.js.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.module.less +9 -0
- package/dist/components/profile-dropdown/profile-dropdown.stories.js +3 -3
- package/dist/components/profile-dropdown/profile-dropdown.stories.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/test/data-stories.module.less +5 -3
- package/dist/test/{data.stories.d.ts → data.d.ts} +1 -2
- package/dist/test/data.d.ts.map +1 -0
- package/dist/test/{data.stories.js → data.js} +16 -19
- package/dist/test/data.js.map +1 -0
- package/dist/utils/navigation-context.d.ts +2 -5
- package/dist/utils/navigation-context.d.ts.map +1 -1
- package/dist/utils/navigation-context.js +3 -19
- package/dist/utils/navigation-context.js.map +1 -1
- package/dist/utils/navigation.d.ts +46 -0
- package/dist/utils/navigation.d.ts.map +1 -1
- package/dist/utils/with-tooltip.d.ts +1 -1
- package/package.json +5 -5
- package/src/components/header-navigation/header-navigation-content.tsx +10 -38
- package/src/components/header-navigation/header-navigation-extra-stacked.stories.tsx +19 -0
- package/src/components/header-navigation/header-navigation-extra.stories.tsx +84 -52
- package/src/components/header-navigation/header-navigation-links.tsx +13 -55
- package/src/components/header-navigation/header-navigation-stacked.stories.tsx +6 -8
- package/src/components/header-navigation/header-navigation.module.less +2 -84
- package/src/components/header-navigation/header-navigation.module.less.d.ts +0 -3
- package/src/components/header-navigation/header-navigation.stories.tsx +6 -8
- package/src/components/header-navigation/header-navigation.tsx +7 -120
- package/src/components/header-navigation/index.ts +0 -1
- package/src/components/layout.stories.tsx +3 -3
- package/src/components/left-navigation/header-navigation-extra-tiny.stories.tsx +21 -0
- package/src/components/left-navigation/header-navigation-tiny-links.tsx +134 -0
- package/src/components/left-navigation/header-navigation-tiny.module.less +117 -0
- package/src/components/left-navigation/header-navigation-tiny.module.less.d.ts +15 -0
- package/src/components/{header-navigation → left-navigation}/header-navigation-tiny.stories.tsx +5 -13
- package/src/components/left-navigation/header-navigation-tiny.tsx +65 -0
- package/src/components/left-navigation/index.ts +2 -0
- package/src/components/{side-navigation → left-navigation}/side-navigation.module.less +3 -3
- package/src/components/{side-navigation → left-navigation}/side-navigation.module.less.d.ts +1 -0
- package/src/components/{side-navigation → left-navigation}/side-navigation.stories.tsx +1 -1
- package/src/components/{side-navigation → left-navigation}/side-navigation.tsx +2 -2
- package/src/components/links.tsx +31 -0
- package/src/components/logo/logo.stories.tsx +6 -6
- package/src/components/profile-dropdown/profile-dropdown-stacked.stories.tsx +14 -6
- package/src/components/profile-dropdown/profile-dropdown-tiny.stories.tsx +15 -5
- package/src/components/profile-dropdown/profile-dropdown.module.less +9 -0
- package/src/components/profile-dropdown/profile-dropdown.module.less.d.ts +1 -0
- package/src/components/profile-dropdown/profile-dropdown.stories.tsx +3 -3
- package/src/components/profile-dropdown/profile-dropdown.tsx +7 -4
- package/src/index.ts +3 -1
- package/src/test/data-stories.module.less +5 -3
- package/src/test/{data.stories.tsx → data.tsx} +5 -2
- package/src/utils/navigation-context.tsx +3 -8
- package/src/utils/navigation.ts +51 -0
- package/dist/components/header-navigation/header-navigation-tiny.stories.d.ts.map +0 -1
- package/dist/components/header-navigation/header-navigation-tiny.stories.js +0 -29
- package/dist/components/header-navigation/header-navigation-tiny.stories.js.map +0 -1
- package/dist/components/side-navigation/icons.d.ts +0 -7
- package/dist/components/side-navigation/icons.d.ts.map +0 -1
- package/dist/components/side-navigation/icons.js +0 -5
- package/dist/components/side-navigation/icons.js.map +0 -1
- package/dist/components/side-navigation/index.d.ts +0 -2
- package/dist/components/side-navigation/index.d.ts.map +0 -1
- package/dist/components/side-navigation/index.js +0 -2
- package/dist/components/side-navigation/index.js.map +0 -1
- package/dist/components/side-navigation/side-navigation.js.map +0 -1
- package/dist/components/side-navigation/side-navigation.stories.d.ts.map +0 -1
- package/dist/test/data.stories.d.ts.map +0 -1
- package/dist/test/data.stories.js.map +0 -1
- package/src/components/side-navigation/icons.tsx +0 -74
- package/src/components/side-navigation/index.ts +0 -1
- /package/dist/components/{side-navigation → left-navigation}/side-navigation.d.ts +0 -0
|
@@ -1,21 +1,8 @@
|
|
|
1
1
|
import { Icon, Popover, PopoverPropsStrict } from '@servicetitan/design-system';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
ReactNode,
|
|
7
|
-
useCallback,
|
|
8
|
-
useEffect,
|
|
9
|
-
useMemo,
|
|
10
|
-
useRef,
|
|
11
|
-
useState,
|
|
12
|
-
} from 'react';
|
|
13
|
-
import { HeaderNavigationItemData, NavLinkComponentProps } from '../../utils/navigation';
|
|
14
|
-
import {
|
|
15
|
-
DefaultNavLinkComponent,
|
|
16
|
-
NavigationContext,
|
|
17
|
-
NavigationContextType,
|
|
18
|
-
} from '../../utils/navigation-context';
|
|
3
|
+
import { FC, ReactElement, ReactNode, useCallback, useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { HeaderNavigationItemData } from '../../utils/navigation';
|
|
5
|
+
import { NavigationLegacyContext } from '../../utils/navigation-context';
|
|
19
6
|
import { HeaderNavigationItem } from './header-navigation-content';
|
|
20
7
|
import * as Styles from './header-navigation.module.less';
|
|
21
8
|
|
|
@@ -91,8 +78,6 @@ export interface HeaderNavigationProps {
|
|
|
91
78
|
items?: HeaderNavigationItemData[];
|
|
92
79
|
/** main navigation overflow items */
|
|
93
80
|
itemsOverflow?: HeaderNavigationItemData[];
|
|
94
|
-
/** navigation component used for routing */
|
|
95
|
-
navigationComponent?: FC<NavLinkComponentProps>;
|
|
96
81
|
/** props for main items overflow component */
|
|
97
82
|
overflow?: HeaderNavigationOverflowProps;
|
|
98
83
|
}
|
|
@@ -113,7 +98,6 @@ export const HeaderNavigation: FC<HeaderNavigationProps> = ({
|
|
|
113
98
|
leftClassName,
|
|
114
99
|
rightClassName,
|
|
115
100
|
minWidth = 800,
|
|
116
|
-
navigationComponent = DefaultNavLinkComponent,
|
|
117
101
|
overflow,
|
|
118
102
|
}) => {
|
|
119
103
|
const leftRef = useRef<HTMLDivElement>(null);
|
|
@@ -152,16 +136,8 @@ export const HeaderNavigation: FC<HeaderNavigationProps> = ({
|
|
|
152
136
|
updateIsMinimized();
|
|
153
137
|
});
|
|
154
138
|
|
|
155
|
-
const context: NavigationContextType = useMemo(
|
|
156
|
-
() => ({
|
|
157
|
-
NavigationComponent: navigationComponent,
|
|
158
|
-
isLegacy: true,
|
|
159
|
-
}),
|
|
160
|
-
[navigationComponent]
|
|
161
|
-
);
|
|
162
|
-
|
|
163
139
|
return (
|
|
164
|
-
<
|
|
140
|
+
<NavigationLegacyContext.Provider value>
|
|
165
141
|
<div
|
|
166
142
|
className={classNames(Styles.header, className, {
|
|
167
143
|
[Styles.calculating]: minimized === MinimizedState.Calculating,
|
|
@@ -207,7 +183,7 @@ export const HeaderNavigation: FC<HeaderNavigationProps> = ({
|
|
|
207
183
|
{children}
|
|
208
184
|
</div>
|
|
209
185
|
</div>
|
|
210
|
-
</
|
|
186
|
+
</NavigationLegacyContext.Provider>
|
|
211
187
|
);
|
|
212
188
|
};
|
|
213
189
|
|
|
@@ -234,8 +210,6 @@ export interface HeaderNavigationStackedProps {
|
|
|
234
210
|
items?: HeaderNavigationItemData[];
|
|
235
211
|
/** main navigation overflow items */
|
|
236
212
|
itemsOverflow?: HeaderNavigationItemData[];
|
|
237
|
-
/** navigation component used for routing */
|
|
238
|
-
navigationComponent?: FC<NavLinkComponentProps>;
|
|
239
213
|
/** props for main items overflow component */
|
|
240
214
|
overflow?: HeaderNavigationOverflowProps;
|
|
241
215
|
}
|
|
@@ -252,7 +226,6 @@ export const HeaderNavigationStacked: FC<HeaderNavigationStackedProps> = ({
|
|
|
252
226
|
center,
|
|
253
227
|
centerClassName,
|
|
254
228
|
minWidth = 800,
|
|
255
|
-
navigationComponent = DefaultNavLinkComponent,
|
|
256
229
|
overflow,
|
|
257
230
|
}) => {
|
|
258
231
|
const bottomRef = useRef<HTMLDivElement>(null);
|
|
@@ -289,16 +262,8 @@ export const HeaderNavigationStacked: FC<HeaderNavigationStackedProps> = ({
|
|
|
289
262
|
updateIsMinimized();
|
|
290
263
|
});
|
|
291
264
|
|
|
292
|
-
const context: NavigationContextType = useMemo(
|
|
293
|
-
() => ({
|
|
294
|
-
NavigationComponent: navigationComponent,
|
|
295
|
-
isLegacy: true,
|
|
296
|
-
}),
|
|
297
|
-
[navigationComponent]
|
|
298
|
-
);
|
|
299
|
-
|
|
300
265
|
return (
|
|
301
|
-
<
|
|
266
|
+
<NavigationLegacyContext.Provider value>
|
|
302
267
|
<div
|
|
303
268
|
className={classNames(
|
|
304
269
|
Styles.headerStacked,
|
|
@@ -357,84 +322,6 @@ export const HeaderNavigationStacked: FC<HeaderNavigationStackedProps> = ({
|
|
|
357
322
|
</div>
|
|
358
323
|
</div>
|
|
359
324
|
</div>
|
|
360
|
-
</
|
|
361
|
-
);
|
|
362
|
-
};
|
|
363
|
-
|
|
364
|
-
export interface HeaderNavigationTinyProps {
|
|
365
|
-
/** container class name */
|
|
366
|
-
className?: string;
|
|
367
|
-
/** extra navigation */
|
|
368
|
-
right?: ReactNode;
|
|
369
|
-
/** extra navigation container class name */
|
|
370
|
-
rightClassName?: string;
|
|
371
|
-
/** container id */
|
|
372
|
-
id?: string;
|
|
373
|
-
/** left content (usually used for logo) */
|
|
374
|
-
left?: ReactElement;
|
|
375
|
-
/** left container class name */
|
|
376
|
-
leftClassName?: string;
|
|
377
|
-
/** center content */
|
|
378
|
-
center?: ReactElement;
|
|
379
|
-
/** center container class name */
|
|
380
|
-
centerClassName?: string;
|
|
381
|
-
/** minimal width for navigation bar */
|
|
382
|
-
minWidth?: number;
|
|
383
|
-
/** navigation component used for routing */
|
|
384
|
-
navigationComponent?: FC<NavLinkComponentProps>;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
export const HeaderNavigationTiny: FC<HeaderNavigationTinyProps> = ({
|
|
388
|
-
className,
|
|
389
|
-
id,
|
|
390
|
-
left,
|
|
391
|
-
leftClassName,
|
|
392
|
-
right,
|
|
393
|
-
rightClassName,
|
|
394
|
-
center,
|
|
395
|
-
centerClassName,
|
|
396
|
-
minWidth = 800,
|
|
397
|
-
navigationComponent = DefaultNavLinkComponent,
|
|
398
|
-
}) => {
|
|
399
|
-
const context: NavigationContextType = useMemo(
|
|
400
|
-
() => ({
|
|
401
|
-
NavigationComponent: navigationComponent,
|
|
402
|
-
isLegacy: false,
|
|
403
|
-
}),
|
|
404
|
-
[navigationComponent]
|
|
405
|
-
);
|
|
406
|
-
|
|
407
|
-
return (
|
|
408
|
-
<NavigationContext.Provider value={context}>
|
|
409
|
-
<div
|
|
410
|
-
className={classNames(Styles.headerTiny, className)}
|
|
411
|
-
style={{ minWidth: `${minWidth}px` }}
|
|
412
|
-
id={id}
|
|
413
|
-
data-cy="header-navigation"
|
|
414
|
-
>
|
|
415
|
-
<div
|
|
416
|
-
className={classNames(Styles.heTopLeft, leftClassName)}
|
|
417
|
-
data-cy="navigation-left"
|
|
418
|
-
>
|
|
419
|
-
{left}
|
|
420
|
-
</div>
|
|
421
|
-
<div
|
|
422
|
-
className={classNames(Styles.heTopCenter, centerClassName)}
|
|
423
|
-
data-cy="navigation-center"
|
|
424
|
-
>
|
|
425
|
-
{center}
|
|
426
|
-
</div>
|
|
427
|
-
<div
|
|
428
|
-
className={classNames(
|
|
429
|
-
'd-f flex-row justify-content-end align-items-center',
|
|
430
|
-
Styles.heTopRight,
|
|
431
|
-
rightClassName
|
|
432
|
-
)}
|
|
433
|
-
data-cy="navigation-right"
|
|
434
|
-
>
|
|
435
|
-
{right}
|
|
436
|
-
</div>
|
|
437
|
-
</div>
|
|
438
|
-
</NavigationContext.Provider>
|
|
325
|
+
</NavigationLegacyContext.Provider>
|
|
439
326
|
);
|
|
440
327
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { withAnvil, withMemoryRouter } from '../test/data
|
|
1
|
+
import { withAnvil, withMemoryRouter } from '../test/data';
|
|
2
2
|
import {
|
|
3
3
|
WithAllMonolithData,
|
|
4
4
|
WithAllMonolithDataCommercial,
|
|
5
|
-
} from './
|
|
6
|
-
import { DefaultSideNavigation } from './
|
|
5
|
+
} from './left-navigation/header-navigation-tiny.stories';
|
|
6
|
+
import { DefaultSideNavigation } from './left-navigation/side-navigation.stories';
|
|
7
7
|
|
|
8
8
|
export default {
|
|
9
9
|
title: 'Navigation/Layout',
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { withAnvil, withMemoryRouter } from '../../test/data';
|
|
2
|
+
import { HeaderNavigationLink } from '../links';
|
|
3
|
+
import { HeaderNavigationTiny } from './header-navigation-tiny';
|
|
4
|
+
|
|
5
|
+
const withHeaderNavigationTiny = (Story: any) => (
|
|
6
|
+
<HeaderNavigationTiny className="border" right={<Story />} />
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
title: 'Navigation/Extra/Tiny',
|
|
11
|
+
component: HeaderNavigationLink,
|
|
12
|
+
decorators: [withHeaderNavigationTiny, withMemoryRouter, withAnvil],
|
|
13
|
+
parameters: {},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
ExtraWithTooltip,
|
|
18
|
+
ExtraLink,
|
|
19
|
+
ExtraTrigger,
|
|
20
|
+
ExtraWithLabel,
|
|
21
|
+
} from '../header-navigation/header-navigation-extra.stories';
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { Icon, IconProps } from '@servicetitan/anvil2';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { FC, Fragment, useContext } from 'react';
|
|
4
|
+
import { HeaderNavigationLinkProps, HeaderNavigationTriggerProps } from '../../utils/navigation';
|
|
5
|
+
import { NavigationComponentContext } from '../../utils/navigation-context';
|
|
6
|
+
import { withTooltip } from '../../utils/with-tooltip';
|
|
7
|
+
import { CounterTag, CounterTagPropsType } from '../counter-tag';
|
|
8
|
+
import * as Styles from './header-navigation-tiny.module.less';
|
|
9
|
+
|
|
10
|
+
/** Content for navigation items */
|
|
11
|
+
export const HeaderNavigationItemContent: FC<{
|
|
12
|
+
counter?: CounterTagPropsType;
|
|
13
|
+
counterClassName?: string;
|
|
14
|
+
icon: IconProps['svg'] | undefined;
|
|
15
|
+
iconActive: IconProps['svg'] | undefined;
|
|
16
|
+
label?: string;
|
|
17
|
+
labelClassName?: string;
|
|
18
|
+
}> = ({ counter, counterClassName, icon, iconActive, label, labelClassName }) => {
|
|
19
|
+
return (
|
|
20
|
+
<Fragment>
|
|
21
|
+
{!!icon && <Icon svg={icon} className={Styles.navigationIcon} />}
|
|
22
|
+
{!!iconActive && (
|
|
23
|
+
<Icon
|
|
24
|
+
svg={iconActive}
|
|
25
|
+
className={classNames(Styles.navigationIcon, Styles.navigationIconActive)}
|
|
26
|
+
/>
|
|
27
|
+
)}
|
|
28
|
+
|
|
29
|
+
{!!label && (
|
|
30
|
+
<span className={classNames(Styles.navigationItemLabel, labelClassName)}>
|
|
31
|
+
{label}
|
|
32
|
+
</span>
|
|
33
|
+
)}
|
|
34
|
+
|
|
35
|
+
{!!counter && (
|
|
36
|
+
<CounterTag
|
|
37
|
+
data={counter}
|
|
38
|
+
className={classNames(Styles.navigationItemCounter, counterClassName)}
|
|
39
|
+
longClassName={Styles.navigationItemCounterLong}
|
|
40
|
+
/>
|
|
41
|
+
)}
|
|
42
|
+
</Fragment>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/** Navigation extra item with link */
|
|
47
|
+
export const HeaderNavigationLink: FC<HeaderNavigationLinkProps> = ({
|
|
48
|
+
id,
|
|
49
|
+
to,
|
|
50
|
+
hint,
|
|
51
|
+
tooltip,
|
|
52
|
+
counter,
|
|
53
|
+
className,
|
|
54
|
+
icon,
|
|
55
|
+
iconActive,
|
|
56
|
+
isActive,
|
|
57
|
+
label,
|
|
58
|
+
labelClassName,
|
|
59
|
+
target,
|
|
60
|
+
...rest
|
|
61
|
+
}) => {
|
|
62
|
+
const NavigationComponent = useContext(NavigationComponentContext);
|
|
63
|
+
|
|
64
|
+
return withTooltip(
|
|
65
|
+
<NavigationComponent
|
|
66
|
+
data-cy={`navigation-link-${id}`}
|
|
67
|
+
data-pendo={`navigation-link-${id}`}
|
|
68
|
+
{...rest}
|
|
69
|
+
key={id}
|
|
70
|
+
to={to}
|
|
71
|
+
title={hint}
|
|
72
|
+
className={classNames(Styles.navigationLink, className, {
|
|
73
|
+
[Styles.navigationItemActive]: isActive === true,
|
|
74
|
+
[Styles.navigationItemIconState]: !!icon && !!iconActive,
|
|
75
|
+
})}
|
|
76
|
+
isActive={typeof isActive === 'function' ? isActive : undefined}
|
|
77
|
+
activeClassName={Styles.navigationItemActive}
|
|
78
|
+
target={target}
|
|
79
|
+
>
|
|
80
|
+
<HeaderNavigationItemContent
|
|
81
|
+
counter={counter}
|
|
82
|
+
icon={icon}
|
|
83
|
+
iconActive={iconActive}
|
|
84
|
+
label={label}
|
|
85
|
+
labelClassName={labelClassName}
|
|
86
|
+
/>
|
|
87
|
+
</NavigationComponent>,
|
|
88
|
+
tooltip
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/** Navigation extra item with icon button */
|
|
93
|
+
export const HeaderNavigationTrigger: FC<HeaderNavigationTriggerProps> = ({
|
|
94
|
+
id,
|
|
95
|
+
className,
|
|
96
|
+
counter,
|
|
97
|
+
icon,
|
|
98
|
+
iconActive,
|
|
99
|
+
isActive,
|
|
100
|
+
hint,
|
|
101
|
+
label,
|
|
102
|
+
labelClassName,
|
|
103
|
+
tooltip,
|
|
104
|
+
title,
|
|
105
|
+
titleClassName,
|
|
106
|
+
...rest
|
|
107
|
+
}) => {
|
|
108
|
+
return withTooltip(
|
|
109
|
+
<div
|
|
110
|
+
data-cy={`navigation-trigger-${id}`}
|
|
111
|
+
data-pendo={`navigation-trigger-${id}`}
|
|
112
|
+
{...rest}
|
|
113
|
+
title={hint}
|
|
114
|
+
className={classNames(
|
|
115
|
+
Styles.navigationLink,
|
|
116
|
+
{
|
|
117
|
+
[Styles.navigationItemActive]: isActive === true,
|
|
118
|
+
[Styles.navigationItemIconState]: !!icon && !!iconActive,
|
|
119
|
+
},
|
|
120
|
+
'cursor-pointer',
|
|
121
|
+
className
|
|
122
|
+
)}
|
|
123
|
+
>
|
|
124
|
+
<HeaderNavigationItemContent
|
|
125
|
+
counter={counter}
|
|
126
|
+
icon={icon}
|
|
127
|
+
iconActive={iconActive}
|
|
128
|
+
label={label}
|
|
129
|
+
labelClassName={labelClassName}
|
|
130
|
+
/>
|
|
131
|
+
</div>,
|
|
132
|
+
tooltip
|
|
133
|
+
);
|
|
134
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/* stylelint-disable no-descending-specificity */
|
|
2
|
+
@import (reference) '@servicetitan/tokens/core/tokens.less';
|
|
3
|
+
|
|
4
|
+
@size-links-tiny: 24px;
|
|
5
|
+
|
|
6
|
+
.header-tiny {
|
|
7
|
+
display: grid;
|
|
8
|
+
grid-template-columns: repeat(3, 1fr);
|
|
9
|
+
grid-template-rows: 48px;
|
|
10
|
+
|
|
11
|
+
background-color: @color-white;
|
|
12
|
+
color: @color-black;
|
|
13
|
+
|
|
14
|
+
& > * {
|
|
15
|
+
overflow-y: hidden;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.he-top-left {
|
|
19
|
+
grid-column: span 1;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.he-top-center {
|
|
23
|
+
grid-column: span 1;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.he-top-right {
|
|
27
|
+
grid-column: span 1;
|
|
28
|
+
|
|
29
|
+
& > * {
|
|
30
|
+
color: @color-black;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
:global(.profile-dropdown-image) {
|
|
35
|
+
height: 24px;
|
|
36
|
+
width: 24px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
:global(.profile-dropdown-trigger) {
|
|
40
|
+
height: 32px;
|
|
41
|
+
font-size: @size-links-tiny;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.navigation-link {
|
|
45
|
+
margin: 6px 2px;
|
|
46
|
+
padding: 6px 6px;
|
|
47
|
+
border-radius: 12px;
|
|
48
|
+
font-size: @size-links-tiny;
|
|
49
|
+
color: inherit;
|
|
50
|
+
|
|
51
|
+
&.navigation-item-active:not(.navigation-item-overflow) {
|
|
52
|
+
background-color: @color-blue-100 !important;
|
|
53
|
+
color: @color-blue-500 !important;
|
|
54
|
+
}
|
|
55
|
+
&:hover:not(.navigation-item-active):not(.navigation-item-overflow) {
|
|
56
|
+
background-color: rgba(0, 0, 0, 0.12) !important;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
&.navigation-item-icon-state.navigation-item-active {
|
|
60
|
+
.navigation-icon:not(.navigation-icon-active) {
|
|
61
|
+
display: none;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.navigation-icon.navigation-icon-active[data-anv][data-anv] {
|
|
65
|
+
display: block;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.navigation-icon[data-anv][data-anv] {
|
|
71
|
+
display: inline-block;
|
|
72
|
+
color: inherit;
|
|
73
|
+
height: 24px;
|
|
74
|
+
width: 24px;
|
|
75
|
+
|
|
76
|
+
> svg {
|
|
77
|
+
height: @size-links-tiny;
|
|
78
|
+
width: @size-links-tiny;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
&.navigation-icon-active {
|
|
82
|
+
display: none;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.navigation-link {
|
|
88
|
+
// styles specific to extra nav links
|
|
89
|
+
color: @color-black;
|
|
90
|
+
position: relative;
|
|
91
|
+
display: flex;
|
|
92
|
+
align-items: center;
|
|
93
|
+
flex-wrap: nowrap;
|
|
94
|
+
text-wrap: nowrap;
|
|
95
|
+
|
|
96
|
+
.navigation-item-counter {
|
|
97
|
+
color: @color-white;
|
|
98
|
+
font-weight: @font-weight-semibold;
|
|
99
|
+
font-size: 8px !important;
|
|
100
|
+
min-width: 12px;
|
|
101
|
+
position: absolute;
|
|
102
|
+
top: 4px;
|
|
103
|
+
right: -2px;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.navigation-item-label {
|
|
107
|
+
color: inherit;
|
|
108
|
+
font-size: @typescale-1;
|
|
109
|
+
font-family: @base-font-family;
|
|
110
|
+
font-weight: @font-weight-semibold;
|
|
111
|
+
margin-left: @spacing-half;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
&.navigation-item-counter-long {
|
|
115
|
+
right: -8px;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const __esModule: true;
|
|
2
|
+
export const heTopCenter: string;
|
|
3
|
+
export const heTopLeft: string;
|
|
4
|
+
export const heTopRight: string;
|
|
5
|
+
export const headerTiny: string;
|
|
6
|
+
export const navigationIcon: string;
|
|
7
|
+
export const navigationIconActive: string;
|
|
8
|
+
export const navigationItemActive: string;
|
|
9
|
+
export const navigationItemCounter: string;
|
|
10
|
+
export const navigationItemCounterLong: string;
|
|
11
|
+
export const navigationItemIconState: string;
|
|
12
|
+
export const navigationItemLabel: string;
|
|
13
|
+
export const navigationItemOverflow: string;
|
|
14
|
+
export const navigationLink: string;
|
|
15
|
+
|
package/src/components/{header-navigation → left-navigation}/header-navigation-tiny.stories.tsx
RENAMED
|
@@ -6,18 +6,13 @@ import SvgRocket from '@servicetitan/anvil2/assets/icons/st/gnav_titan_advisor_i
|
|
|
6
6
|
|
|
7
7
|
import { Input, Stack } from '@servicetitan/design-system';
|
|
8
8
|
import { FC, Fragment } from 'react';
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
NavLinkMock,
|
|
12
|
-
SearchIcon,
|
|
13
|
-
withAnvil,
|
|
14
|
-
withMemoryRouter,
|
|
15
|
-
} from '../../test/data.stories';
|
|
9
|
+
import { CallsNavigationTrigger, SearchIcon, withAnvil, withMemoryRouter } from '../../test/data';
|
|
10
|
+
import * as Styles from '../header-navigation/header-navigation-stories.module.less';
|
|
16
11
|
import { LogoCompanyTitle } from '../logo/logo-company-title';
|
|
17
12
|
import { LogoTitan, LogoTitanTitle } from '../logo/logo-titan-text';
|
|
18
13
|
import { ProfileDropdown } from '../profile-dropdown/profile-dropdown';
|
|
19
|
-
import
|
|
20
|
-
import { HeaderNavigationLink
|
|
14
|
+
import { HeaderNavigationTiny } from './header-navigation-tiny';
|
|
15
|
+
import { HeaderNavigationLink } from './header-navigation-tiny-links';
|
|
21
16
|
|
|
22
17
|
export default {
|
|
23
18
|
title: 'Navigation/HeaderNavigationTiny',
|
|
@@ -34,12 +29,11 @@ export default {
|
|
|
34
29
|
],
|
|
35
30
|
};
|
|
36
31
|
|
|
37
|
-
export const
|
|
32
|
+
export const DefaultTinyNavigation = () => (
|
|
38
33
|
<HeaderNavigationTiny
|
|
39
34
|
className="border-bottom"
|
|
40
35
|
left={<LogoCompanyTitle className="m-l-1" size="150" />}
|
|
41
36
|
leftClassName="d-f align-items-center"
|
|
42
|
-
navigationComponent={NavLinkMock}
|
|
43
37
|
/>
|
|
44
38
|
);
|
|
45
39
|
|
|
@@ -54,7 +48,6 @@ export const WithAllMonolithData = () => (
|
|
|
54
48
|
className="border-bottom"
|
|
55
49
|
left={<LogoCompanyTitle className="m-l-1" size="150" />}
|
|
56
50
|
leftClassName="d-f align-items-center"
|
|
57
|
-
navigationComponent={NavLinkMock}
|
|
58
51
|
right={
|
|
59
52
|
<Fragment>
|
|
60
53
|
<TimeZoneOffset />
|
|
@@ -122,7 +115,6 @@ export const WithAllMonolithDataCommercial = () => (
|
|
|
122
115
|
</Stack>
|
|
123
116
|
}
|
|
124
117
|
leftClassName="d-f align-items-center"
|
|
125
|
-
navigationComponent={NavLinkMock}
|
|
126
118
|
right={
|
|
127
119
|
<Fragment>
|
|
128
120
|
<TimeZoneOffset />
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import { FC, ReactElement, ReactNode } from 'react';
|
|
3
|
+
import * as Styles from './header-navigation-tiny.module.less';
|
|
4
|
+
|
|
5
|
+
export interface HeaderNavigationTinyProps {
|
|
6
|
+
/** container class name */
|
|
7
|
+
className?: string;
|
|
8
|
+
/** extra navigation */
|
|
9
|
+
right?: ReactNode;
|
|
10
|
+
/** extra navigation container class name */
|
|
11
|
+
rightClassName?: string;
|
|
12
|
+
/** container id */
|
|
13
|
+
id?: string;
|
|
14
|
+
/** left content (usually used for logo) */
|
|
15
|
+
left?: ReactElement;
|
|
16
|
+
/** left container class name */
|
|
17
|
+
leftClassName?: string;
|
|
18
|
+
/** center content */
|
|
19
|
+
center?: ReactElement;
|
|
20
|
+
/** center container class name */
|
|
21
|
+
centerClassName?: string;
|
|
22
|
+
/** minimal width for navigation bar */
|
|
23
|
+
minWidth?: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const HeaderNavigationTiny: FC<HeaderNavigationTinyProps> = ({
|
|
27
|
+
className,
|
|
28
|
+
id,
|
|
29
|
+
left,
|
|
30
|
+
leftClassName,
|
|
31
|
+
right,
|
|
32
|
+
rightClassName,
|
|
33
|
+
center,
|
|
34
|
+
centerClassName,
|
|
35
|
+
minWidth = 800,
|
|
36
|
+
}) => {
|
|
37
|
+
return (
|
|
38
|
+
<div
|
|
39
|
+
className={classNames(Styles.headerTiny, className)}
|
|
40
|
+
style={{ minWidth: `${minWidth}px` }}
|
|
41
|
+
id={id}
|
|
42
|
+
data-cy="header-navigation"
|
|
43
|
+
>
|
|
44
|
+
<div className={classNames(Styles.heTopLeft, leftClassName)} data-cy="navigation-left">
|
|
45
|
+
{left}
|
|
46
|
+
</div>
|
|
47
|
+
<div
|
|
48
|
+
className={classNames(Styles.heTopCenter, centerClassName)}
|
|
49
|
+
data-cy="navigation-center"
|
|
50
|
+
>
|
|
51
|
+
{center}
|
|
52
|
+
</div>
|
|
53
|
+
<div
|
|
54
|
+
className={classNames(
|
|
55
|
+
'd-f flex-row justify-content-end align-items-center',
|
|
56
|
+
Styles.heTopRight,
|
|
57
|
+
rightClassName
|
|
58
|
+
)}
|
|
59
|
+
data-cy="navigation-right"
|
|
60
|
+
>
|
|
61
|
+
{right}
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
);
|
|
65
|
+
};
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
.navigation-icon {
|
|
114
|
+
.navigation-icon[data-anv][data-anv] {
|
|
115
115
|
height: 24px;
|
|
116
116
|
width: 24px;
|
|
117
117
|
color: inherit;
|
|
@@ -146,13 +146,13 @@
|
|
|
146
146
|
background-color: @bg-color-hover;
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
.options-icon {
|
|
149
|
+
.options-icon-wrapper {
|
|
150
150
|
height: 24px;
|
|
151
151
|
width: 24px;
|
|
152
152
|
padding-left: @spacing-1;
|
|
153
153
|
padding-right: @spacing-1;
|
|
154
154
|
|
|
155
|
-
|
|
155
|
+
.options-icon[data-anv][data-anv] > svg {
|
|
156
156
|
height: 24px;
|
|
157
157
|
width: 24px;
|
|
158
158
|
color: @text-color;
|
|
@@ -8,6 +8,7 @@ export const navigationItemCounter: string;
|
|
|
8
8
|
export const navigationItemIconState: string;
|
|
9
9
|
export const navigationItemText: string;
|
|
10
10
|
export const optionsIcon: string;
|
|
11
|
+
export const optionsIconWrapper: string;
|
|
11
12
|
export const optionsItem: string;
|
|
12
13
|
export const optionsItemText: string;
|
|
13
14
|
export const sideNav: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentType, useState } from 'react';
|
|
2
|
-
import { NavLinkMock, items, withAnvil, withMemoryRouter } from '../../test/data
|
|
2
|
+
import { NavLinkMock, items, withAnvil, withMemoryRouter } from '../../test/data';
|
|
3
3
|
import { SideNavigation } from './';
|
|
4
4
|
|
|
5
5
|
const layout = (Story: ComponentType) => {
|
|
@@ -160,8 +160,8 @@ export const SideNavigationOptionsToggle: FC<{
|
|
|
160
160
|
className={classNames(Styles.optionsItem)}
|
|
161
161
|
onClick={() => onExpandedChange(!expanded)}
|
|
162
162
|
>
|
|
163
|
-
<div className={Styles.
|
|
164
|
-
<Icon svg={expanded ? SvgCollapse : SvgExpand} />
|
|
163
|
+
<div className={Styles.optionsIconWrapper}>
|
|
164
|
+
<Icon className={Styles.optionsIcon} svg={expanded ? SvgCollapse : SvgExpand} />
|
|
165
165
|
</div>
|
|
166
166
|
|
|
167
167
|
{!!expanded && <span className={Styles.optionsItemText}>Collapse Menu</span>}
|