@servicetitan/navigation 4.0.0 → 4.1.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/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.stories.d.ts +1 -2
- package/dist/components/header-navigation/header-navigation-extra.stories.d.ts.map +1 -1
- package/dist/components/header-navigation/header-navigation-extra.stories.js +6 -6
- 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 +7 -10
- package/dist/components/header-navigation/header-navigation-links.js.map +1 -1
- package/dist/components/header-navigation/header-navigation-stacked.stories.d.ts.map +1 -1
- package/dist/components/header-navigation/header-navigation-stacked.stories.js +6 -5
- 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 +6 -21
- 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.map +1 -1
- package/dist/components/header-navigation/header-navigation.stories.js +6 -5
- 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 +2 -2
- package/dist/components/layout.stories.js.map +1 -1
- package/dist/components/left-navigation/header-navigation-tiny-links.d.ts +16 -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 +43 -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 +109 -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 +1 -1
- package/dist/components/{side-navigation → left-navigation}/side-navigation.js.map +1 -1
- 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.map +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/profile-dropdown/profile-dropdown-stacked.stories.d.ts.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown-stacked.stories.js +2 -2
- package/dist/components/profile-dropdown/profile-dropdown-stacked.stories.js.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown-tiny.stories.js +3 -3
- 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 +3 -3
- package/dist/components/profile-dropdown/profile-dropdown.js.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.stories.js +2 -2
- package/dist/components/profile-dropdown/profile-dropdown.stories.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/test/data-stories.module.less +5 -3
- package/dist/test/data.stories.d.ts.map +1 -1
- package/dist/test/data.stories.js +3 -2
- package/dist/test/data.stories.js.map +1 -1
- 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 +2 -4
- package/dist/utils/navigation-context.js.map +1 -1
- package/dist/utils/navigation.d.ts +42 -0
- package/dist/utils/navigation.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/components/header-navigation/header-navigation-content.tsx +10 -38
- package/src/components/header-navigation/header-navigation-extra.stories.tsx +6 -18
- package/src/components/header-navigation/header-navigation-links.tsx +5 -55
- package/src/components/header-navigation/header-navigation-stacked.stories.tsx +3 -5
- 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 +3 -5
- 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 +2 -2
- package/src/components/left-navigation/header-navigation-tiny-links.tsx +110 -0
- package/src/components/left-navigation/header-navigation-tiny.module.less +109 -0
- package/src/components/left-navigation/header-navigation-tiny.module.less.d.ts +14 -0
- package/src/components/{header-navigation → left-navigation}/header-navigation-tiny.stories.tsx +4 -7
- 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.tsx +2 -2
- package/src/components/links.tsx +31 -0
- package/src/components/profile-dropdown/profile-dropdown-stacked.stories.tsx +2 -4
- package/src/components/profile-dropdown/profile-dropdown-tiny.stories.tsx +3 -3
- package/src/components/profile-dropdown/profile-dropdown.stories.tsx +2 -2
- package/src/components/profile-dropdown/profile-dropdown.tsx +6 -3
- package/src/index.ts +2 -1
- package/src/test/data-stories.module.less +5 -3
- package/src/test/data.stories.tsx +5 -2
- package/src/utils/navigation-context.tsx +3 -8
- package/src/utils/navigation.ts +47 -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/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
- /package/dist/components/{side-navigation → left-navigation}/side-navigation.stories.d.ts +0 -0
- /package/dist/components/{side-navigation → left-navigation}/side-navigation.stories.js +0 -0
- /package/src/components/{side-navigation → left-navigation}/side-navigation.stories.tsx +0 -0
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
|
|
66
66
|
.navigation-link {
|
|
67
67
|
padding: @spacing-2 @spacing-1;
|
|
68
|
+
font-size: 24px;
|
|
68
69
|
|
|
69
70
|
.navigation-item-counter {
|
|
70
71
|
top: 8px;
|
|
@@ -171,6 +172,7 @@
|
|
|
171
172
|
|
|
172
173
|
.navigation-link {
|
|
173
174
|
padding: 12px @spacing-1;
|
|
175
|
+
font-size: @typescale-4;
|
|
174
176
|
|
|
175
177
|
.navigation-item-counter {
|
|
176
178
|
top: 8px;
|
|
@@ -193,86 +195,6 @@
|
|
|
193
195
|
}
|
|
194
196
|
}
|
|
195
197
|
|
|
196
|
-
@size-links-tiny: 24px;
|
|
197
|
-
|
|
198
|
-
.header-tiny {
|
|
199
|
-
display: grid;
|
|
200
|
-
grid-template-columns: repeat(3, 1fr);
|
|
201
|
-
grid-template-rows: 48px;
|
|
202
|
-
|
|
203
|
-
background-color: @color-white;
|
|
204
|
-
color: @color-black;
|
|
205
|
-
|
|
206
|
-
& > * {
|
|
207
|
-
overflow-y: hidden;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
.he-top-left {
|
|
211
|
-
grid-column: span 1;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
.he-top-center {
|
|
215
|
-
grid-column: span 1;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
.he-top-right {
|
|
219
|
-
grid-column: span 1;
|
|
220
|
-
|
|
221
|
-
.navigation-icon {
|
|
222
|
-
height: @size-links-tiny;
|
|
223
|
-
width: @size-links-tiny;
|
|
224
|
-
font-size: @size-links-tiny;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
& > * {
|
|
228
|
-
color: @color-black;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
:global(.profile-dropdown-image) {
|
|
233
|
-
height: 24px;
|
|
234
|
-
width: 24px;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
:global(.profile-dropdown-trigger) {
|
|
238
|
-
height: 32px;
|
|
239
|
-
font-size: @size-links-tiny;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
.navigation-item-counter {
|
|
243
|
-
font-size: 8px !important;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
.navigation-link {
|
|
247
|
-
margin: 6px 2px;
|
|
248
|
-
padding: 6px 6px;
|
|
249
|
-
border-radius: 12px;
|
|
250
|
-
|
|
251
|
-
&.navigation-item-active:not(.navigation-item-overflow) {
|
|
252
|
-
background-color: @color-blue-100 !important;
|
|
253
|
-
color: @color-blue-500 !important;
|
|
254
|
-
}
|
|
255
|
-
&:hover:not(.navigation-item-active):not(.navigation-item-overflow) {
|
|
256
|
-
background-color: rgba(0, 0, 0, 0.12) !important;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
&.navigation-item-icon-state.navigation-item-active {
|
|
260
|
-
.navigation-icon:not(.navigation-icon-active) {
|
|
261
|
-
display: none;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
.navigation-icon.navigation-icon-active {
|
|
265
|
-
display: block;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
.navigation-item-counter {
|
|
270
|
-
top: 4px;
|
|
271
|
-
right: -2px;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
198
|
.navigation-icon {
|
|
277
199
|
display: inline-block;
|
|
278
200
|
color: inherit;
|
|
@@ -282,10 +204,6 @@
|
|
|
282
204
|
width: 1em;
|
|
283
205
|
font-size: 1em;
|
|
284
206
|
}
|
|
285
|
-
|
|
286
|
-
&.navigation-icon-active {
|
|
287
|
-
display: none;
|
|
288
|
-
}
|
|
289
207
|
}
|
|
290
208
|
|
|
291
209
|
.navigation-item {
|
|
@@ -7,14 +7,11 @@ export const heTopLeft: string;
|
|
|
7
7
|
export const heTopRight: string;
|
|
8
8
|
export const header: string;
|
|
9
9
|
export const headerStacked: string;
|
|
10
|
-
export const headerTiny: string;
|
|
11
10
|
export const navigationIcon: string;
|
|
12
|
-
export const navigationIconActive: string;
|
|
13
11
|
export const navigationItem: string;
|
|
14
12
|
export const navigationItemActive: string;
|
|
15
13
|
export const navigationItemCounter: string;
|
|
16
14
|
export const navigationItemCounterLong: string;
|
|
17
|
-
export const navigationItemIconState: string;
|
|
18
15
|
export const navigationItemMain: string;
|
|
19
16
|
export const navigationItemOverflow: string;
|
|
20
17
|
export const navigationItemTitle: string;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Popover } from '@servicetitan/design-system';
|
|
2
2
|
import { FC, useState } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { SearchIcon, items, withMemoryRouter } from '../../test/data.stories';
|
|
4
4
|
import { LogoCompanyTitle } from '../logo/logo-company-title';
|
|
5
5
|
import { LogoTitanText } from '../logo/logo-titan-text';
|
|
6
6
|
import { ProfileDropdown } from '../profile-dropdown/profile-dropdown';
|
|
7
|
+
import { HeaderNavigationLink, HeaderNavigationTrigger } from './header-navigation-links';
|
|
7
8
|
import * as Styles from './header-navigation-stories.module.less';
|
|
8
|
-
import { HeaderNavigation
|
|
9
|
+
import { HeaderNavigation } from './';
|
|
9
10
|
|
|
10
11
|
export default {
|
|
11
12
|
title: 'Navigation/HeaderNavigation',
|
|
@@ -26,7 +27,6 @@ export const defaultNavigation = () => (
|
|
|
26
27
|
items.dispatch,
|
|
27
28
|
items.fleet,
|
|
28
29
|
]}
|
|
29
|
-
navigationComponent={NavLinkMock}
|
|
30
30
|
/>
|
|
31
31
|
);
|
|
32
32
|
|
|
@@ -49,7 +49,6 @@ export const withLogoTextAndOverflow = () => (
|
|
|
49
49
|
items.fleet,
|
|
50
50
|
]}
|
|
51
51
|
itemsOverflow={[items.calls, items.accounting, items.purchasing, items.dispatch]}
|
|
52
|
-
navigationComponent={NavLinkMock}
|
|
53
52
|
/>
|
|
54
53
|
);
|
|
55
54
|
|
|
@@ -103,7 +102,6 @@ export const withAllMonolithData = () => (
|
|
|
103
102
|
items.pointOfSale,
|
|
104
103
|
items.reports,
|
|
105
104
|
]}
|
|
106
|
-
navigationComponent={NavLinkMock}
|
|
107
105
|
>
|
|
108
106
|
<TimeZoneOffset />
|
|
109
107
|
|
|
@@ -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
|
};
|
|
@@ -2,8 +2,8 @@ import { withAnvil, withMemoryRouter } from '../test/data.stories';
|
|
|
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,110 @@
|
|
|
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
|
+
}> = ({ counter, counterClassName, icon, iconActive }) => {
|
|
17
|
+
return (
|
|
18
|
+
<Fragment>
|
|
19
|
+
{!!icon && <Icon svg={icon} className={Styles.navigationIcon} />}
|
|
20
|
+
{!!iconActive && (
|
|
21
|
+
<Icon
|
|
22
|
+
svg={iconActive}
|
|
23
|
+
className={classNames(Styles.navigationIcon, Styles.navigationIconActive)}
|
|
24
|
+
/>
|
|
25
|
+
)}
|
|
26
|
+
|
|
27
|
+
{!!counter && (
|
|
28
|
+
<CounterTag
|
|
29
|
+
data={counter}
|
|
30
|
+
className={classNames(Styles.navigationItemCounter, counterClassName)}
|
|
31
|
+
longClassName={Styles.navigationItemCounterLong}
|
|
32
|
+
/>
|
|
33
|
+
)}
|
|
34
|
+
</Fragment>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** Navigation extra item with link */
|
|
39
|
+
export const HeaderNavigationLink: FC<HeaderNavigationLinkProps> = ({
|
|
40
|
+
id,
|
|
41
|
+
to,
|
|
42
|
+
hint,
|
|
43
|
+
tooltip,
|
|
44
|
+
counter,
|
|
45
|
+
className,
|
|
46
|
+
icon,
|
|
47
|
+
iconActive,
|
|
48
|
+
isActive,
|
|
49
|
+
target,
|
|
50
|
+
...rest
|
|
51
|
+
}) => {
|
|
52
|
+
const NavigationComponent = useContext(NavigationComponentContext);
|
|
53
|
+
|
|
54
|
+
return withTooltip(
|
|
55
|
+
<NavigationComponent
|
|
56
|
+
data-cy={`navigation-link-${id}`}
|
|
57
|
+
data-pendo={`navigation-link-${id}`}
|
|
58
|
+
{...rest}
|
|
59
|
+
key={id}
|
|
60
|
+
to={to}
|
|
61
|
+
title={hint}
|
|
62
|
+
className={classNames(Styles.navigationLink, className, {
|
|
63
|
+
[Styles.navigationItemActive]: isActive === true,
|
|
64
|
+
[Styles.navigationItemIconState]: !!icon && !!iconActive,
|
|
65
|
+
})}
|
|
66
|
+
isActive={typeof isActive === 'function' ? isActive : undefined}
|
|
67
|
+
activeClassName={Styles.navigationItemActive}
|
|
68
|
+
target={target}
|
|
69
|
+
>
|
|
70
|
+
<HeaderNavigationItemContent counter={counter} icon={icon} iconActive={iconActive} />
|
|
71
|
+
</NavigationComponent>,
|
|
72
|
+
tooltip
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/** Navigation extra item with icon button */
|
|
77
|
+
export const HeaderNavigationTrigger: FC<HeaderNavigationTriggerProps> = ({
|
|
78
|
+
id,
|
|
79
|
+
className,
|
|
80
|
+
counter,
|
|
81
|
+
icon,
|
|
82
|
+
iconActive,
|
|
83
|
+
isActive,
|
|
84
|
+
hint,
|
|
85
|
+
tooltip,
|
|
86
|
+
title,
|
|
87
|
+
titleClassName,
|
|
88
|
+
...rest
|
|
89
|
+
}) => {
|
|
90
|
+
return withTooltip(
|
|
91
|
+
<div
|
|
92
|
+
data-cy={`navigation-trigger-${id}`}
|
|
93
|
+
data-pendo={`navigation-trigger-${id}`}
|
|
94
|
+
{...rest}
|
|
95
|
+
title={hint}
|
|
96
|
+
className={classNames(
|
|
97
|
+
Styles.navigationLink,
|
|
98
|
+
{
|
|
99
|
+
[Styles.navigationItemActive]: isActive === true,
|
|
100
|
+
[Styles.navigationItemIconState]: !!icon && !!iconActive,
|
|
101
|
+
},
|
|
102
|
+
'cursor-pointer',
|
|
103
|
+
className
|
|
104
|
+
)}
|
|
105
|
+
>
|
|
106
|
+
<HeaderNavigationItemContent counter={counter} icon={icon} iconActive={iconActive} />
|
|
107
|
+
</div>,
|
|
108
|
+
tooltip
|
|
109
|
+
);
|
|
110
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
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-counter-long {
|
|
107
|
+
right: -8px;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
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 navigationItemOverflow: string;
|
|
13
|
+
export const navigationLink: string;
|
|
14
|
+
|
package/src/components/{header-navigation → left-navigation}/header-navigation-tiny.stories.tsx
RENAMED
|
@@ -8,16 +8,16 @@ import { Input, Stack } from '@servicetitan/design-system';
|
|
|
8
8
|
import { FC, Fragment } from 'react';
|
|
9
9
|
import {
|
|
10
10
|
CallsNavigationTrigger,
|
|
11
|
-
NavLinkMock,
|
|
12
11
|
SearchIcon,
|
|
13
12
|
withAnvil,
|
|
14
13
|
withMemoryRouter,
|
|
15
14
|
} from '../../test/data.stories';
|
|
15
|
+
import * as Styles from '../header-navigation/header-navigation-stories.module.less';
|
|
16
16
|
import { LogoCompanyTitle } from '../logo/logo-company-title';
|
|
17
17
|
import { LogoTitan, LogoTitanTitle } from '../logo/logo-titan-text';
|
|
18
18
|
import { ProfileDropdown } from '../profile-dropdown/profile-dropdown';
|
|
19
|
-
import
|
|
20
|
-
import { HeaderNavigationLink
|
|
19
|
+
import { HeaderNavigationTiny } from './header-navigation-tiny';
|
|
20
|
+
import { HeaderNavigationLink } from './header-navigation-tiny-links';
|
|
21
21
|
|
|
22
22
|
export default {
|
|
23
23
|
title: 'Navigation/HeaderNavigationTiny',
|
|
@@ -34,12 +34,11 @@ export default {
|
|
|
34
34
|
],
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
export const
|
|
37
|
+
export const DefaultTinyNavigation = () => (
|
|
38
38
|
<HeaderNavigationTiny
|
|
39
39
|
className="border-bottom"
|
|
40
40
|
left={<LogoCompanyTitle className="m-l-1" size="150" />}
|
|
41
41
|
leftClassName="d-f align-items-center"
|
|
42
|
-
navigationComponent={NavLinkMock}
|
|
43
42
|
/>
|
|
44
43
|
);
|
|
45
44
|
|
|
@@ -54,7 +53,6 @@ export const WithAllMonolithData = () => (
|
|
|
54
53
|
className="border-bottom"
|
|
55
54
|
left={<LogoCompanyTitle className="m-l-1" size="150" />}
|
|
56
55
|
leftClassName="d-f align-items-center"
|
|
57
|
-
navigationComponent={NavLinkMock}
|
|
58
56
|
right={
|
|
59
57
|
<Fragment>
|
|
60
58
|
<TimeZoneOffset />
|
|
@@ -122,7 +120,6 @@ export const WithAllMonolithDataCommercial = () => (
|
|
|
122
120
|
</Stack>
|
|
123
121
|
}
|
|
124
122
|
leftClassName="d-f align-items-center"
|
|
125
|
-
navigationComponent={NavLinkMock}
|
|
126
123
|
right={
|
|
127
124
|
<Fragment>
|
|
128
125
|
<TimeZoneOffset />
|