@servicetitan/navigation 3.3.0 → 4.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/header-navigation/header-navigation-content.d.ts +7 -0
- package/dist/components/header-navigation/header-navigation-content.d.ts.map +1 -1
- package/dist/components/header-navigation/header-navigation-content.js +8 -7
- package/dist/components/header-navigation/header-navigation-content.js.map +1 -1
- package/dist/components/header-navigation/header-navigation-extra.stories.d.ts +3 -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 -20
- package/dist/components/header-navigation/header-navigation-extra.stories.js.map +1 -1
- package/dist/components/header-navigation/header-navigation-links.d.ts +5 -3
- package/dist/components/header-navigation/header-navigation-links.d.ts.map +1 -1
- package/dist/components/header-navigation/header-navigation-links.js +12 -6
- package/dist/components/header-navigation/header-navigation-links.js.map +1 -1
- package/dist/components/header-navigation/header-navigation-stacked.stories.d.ts +1 -0
- package/dist/components/header-navigation/header-navigation-stacked.stories.d.ts.map +1 -1
- package/dist/components/header-navigation/header-navigation-stacked.stories.js +4 -23
- package/dist/components/header-navigation/header-navigation-stacked.stories.js.map +1 -1
- package/dist/components/header-navigation/header-navigation-tiny.stories.d.ts.map +1 -1
- package/dist/components/header-navigation/header-navigation-tiny.stories.js +11 -7
- package/dist/components/header-navigation/header-navigation-tiny.stories.js.map +1 -1
- package/dist/components/header-navigation/header-navigation.d.ts.map +1 -1
- package/dist/components/header-navigation/header-navigation.js +17 -5
- package/dist/components/header-navigation/header-navigation.js.map +1 -1
- package/dist/components/header-navigation/header-navigation.module.less +25 -0
- package/dist/components/header-navigation/header-navigation.stories.d.ts +1 -0
- package/dist/components/header-navigation/header-navigation.stories.d.ts.map +1 -1
- package/dist/components/header-navigation/header-navigation.stories.js +5 -24
- package/dist/components/header-navigation/header-navigation.stories.js.map +1 -1
- package/dist/components/layout.stories.d.ts +1 -0
- package/dist/components/layout.stories.d.ts.map +1 -1
- package/dist/components/layout.stories.js +2 -0
- package/dist/components/layout.stories.js.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown-stacked.stories.d.ts +2 -8
- package/dist/components/profile-dropdown/profile-dropdown-stacked.stories.d.ts.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown-stacked.stories.js +5 -43
- package/dist/components/profile-dropdown/profile-dropdown-stacked.stories.js.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown-tiny.stories.d.ts +9 -0
- package/dist/components/profile-dropdown/profile-dropdown-tiny.stories.d.ts.map +1 -0
- package/dist/components/profile-dropdown/profile-dropdown-tiny.stories.js +13 -0
- package/dist/components/profile-dropdown/profile-dropdown-tiny.stories.js.map +1 -0
- package/dist/components/profile-dropdown/profile-dropdown.d.ts +2 -1
- package/dist/components/profile-dropdown/profile-dropdown.d.ts.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.js +16 -7
- package/dist/components/profile-dropdown/profile-dropdown.js.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.module.less +7 -1
- package/dist/components/profile-dropdown/profile-dropdown.stories.d.ts +9 -8
- package/dist/components/profile-dropdown/profile-dropdown.stories.d.ts.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.stories.js +39 -39
- package/dist/components/profile-dropdown/profile-dropdown.stories.js.map +1 -1
- package/dist/components/side-navigation/side-navigation.d.ts +1 -12
- package/dist/components/side-navigation/side-navigation.d.ts.map +1 -1
- package/dist/components/side-navigation/side-navigation.js +10 -24
- package/dist/components/side-navigation/side-navigation.js.map +1 -1
- package/dist/components/side-navigation/side-navigation.module.less +26 -20
- package/dist/components/side-navigation/side-navigation.stories.d.ts +3 -3
- package/dist/components/side-navigation/side-navigation.stories.d.ts.map +1 -1
- package/dist/components/side-navigation/side-navigation.stories.js +2 -23
- package/dist/components/side-navigation/side-navigation.stories.js.map +1 -1
- package/dist/test/data-stories.module.less +6 -0
- package/dist/test/data.stories.d.ts +26 -0
- package/dist/test/data.stories.d.ts.map +1 -0
- package/dist/test/data.stories.js +150 -0
- package/dist/test/data.stories.js.map +1 -0
- package/dist/utils/navigation-context.d.ts +5 -2
- package/dist/utils/navigation-context.d.ts.map +1 -1
- package/dist/utils/navigation-context.js +20 -5
- package/dist/utils/navigation-context.js.map +1 -1
- package/dist/utils/navigation.d.ts +5 -0
- package/dist/utils/navigation.d.ts.map +1 -1
- package/package.json +11 -11
- package/src/components/header-navigation/header-navigation-content.tsx +39 -11
- package/src/components/header-navigation/header-navigation-extra.stories.tsx +24 -21
- package/src/components/header-navigation/header-navigation-links.tsx +36 -8
- package/src/components/header-navigation/header-navigation-stacked.stories.tsx +16 -66
- package/src/components/header-navigation/header-navigation-tiny.stories.tsx +37 -41
- package/src/components/header-navigation/header-navigation.module.less +25 -0
- package/src/components/header-navigation/header-navigation.module.less.d.ts +2 -0
- package/src/components/header-navigation/header-navigation.stories.tsx +18 -67
- package/src/components/header-navigation/header-navigation.tsx +45 -8
- package/src/components/layout.stories.tsx +2 -0
- package/src/components/profile-dropdown/profile-dropdown-stacked.stories.tsx +7 -170
- package/src/components/profile-dropdown/profile-dropdown-tiny.stories.tsx +15 -0
- package/src/components/profile-dropdown/profile-dropdown.module.less +7 -1
- package/src/components/profile-dropdown/profile-dropdown.module.less.d.ts +1 -0
- package/src/components/profile-dropdown/profile-dropdown.stories.tsx +106 -129
- package/src/components/profile-dropdown/profile-dropdown.tsx +32 -8
- package/src/components/side-navigation/side-navigation.module.less +26 -20
- package/src/components/side-navigation/side-navigation.module.less.d.ts +2 -3
- package/src/components/side-navigation/side-navigation.stories.tsx +3 -52
- package/src/components/side-navigation/side-navigation.tsx +71 -124
- package/src/test/data-stories.module.less +6 -0
- package/src/test/data-stories.module.less.d.ts +3 -0
- package/src/test/data.stories.tsx +220 -0
- package/src/utils/navigation-context.tsx +15 -10
- package/src/utils/navigation.ts +7 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Popover } from '@servicetitan/design-system';
|
|
2
2
|
import { FC, useState } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { NavLinkMock, 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';
|
|
@@ -11,72 +11,9 @@ export default {
|
|
|
11
11
|
title: 'Navigation/HeaderNavigation',
|
|
12
12
|
component: HeaderNavigation,
|
|
13
13
|
parameters: {},
|
|
14
|
+
decorators: [withMemoryRouter],
|
|
14
15
|
};
|
|
15
|
-
|
|
16
|
-
const getItem = (
|
|
17
|
-
id: string,
|
|
18
|
-
data: Partial<HeaderNavigationItemData>
|
|
19
|
-
): HeaderNavigationItemData => ({
|
|
20
|
-
id,
|
|
21
|
-
to: '/',
|
|
22
|
-
title: id[0].toUpperCase() + id.substring(1),
|
|
23
|
-
hint: id,
|
|
24
|
-
...(data ?? {}),
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
const InventoryIcon = () => (
|
|
28
|
-
<svg width="20" xmlns="http://www.w3.org/2000/svg" viewBox="-293 385 24 24" fill="currentColor">
|
|
29
|
-
<polyline points="-288,400.9 -282,404.3 -282,397.6 -288,394.2 -288,400.9 " />
|
|
30
|
-
<path d="M-272,401.5c0,0.4-0.2,0.7-0.5,0.9l-7.9,4.4c-0.2,0.1-0.4,0.2-0.6,0.2s-0.4-0.1-0.6-0.2l-7.9-4.4c-0.3-0.2-0.5-0.5-0.5-0.9v-9c0-0.4,0.2-0.7,0.5-0.9l7.9-4.4c0.2-0.1,0.4-0.2,0.6-0.2s0.4,0.1,0.6,0.2l7.9,4.4c0.3,0.2,0.5,0.5,0.5,0.9V401.5 M-287,392.5 l6,3.4l5.9-3.3l-5.9-3.4L-287,392.5 M-274,400.9v-6.7l-6,3.4v6.7L-274,400.9z" />
|
|
31
|
-
</svg>
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
const SearchIcon = () => (
|
|
35
|
-
<svg
|
|
36
|
-
width="1em"
|
|
37
|
-
height="1em"
|
|
38
|
-
viewBox="0 0 24 24"
|
|
39
|
-
fill="none"
|
|
40
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
41
|
-
>
|
|
42
|
-
<g transform="translate(0,4)">
|
|
43
|
-
<path
|
|
44
|
-
d="M0 15.7992V13.9992H12V15.7992H0ZM0 9.49922V7.69922H6V9.49922H0ZM0 3.19922V1.39922H6V3.19922H0ZM22.74 15.7992L17.94 10.9992C17.42 11.3992 16.86 11.6992 16.26 11.8992C15.66 12.0992 15.04 12.1992 14.4 12.1992C12.74 12.1992 11.325 11.6142 10.155 10.4442C8.985 9.27422 8.4 7.85922 8.4 6.19922C8.4 4.53922 8.985 3.12422 10.155 1.95422C11.325 0.784219 12.74 0.199219 14.4 0.199219C16.06 0.199219 17.475 0.784219 18.645 1.95422C19.815 3.12422 20.4 4.53922 20.4 6.19922C20.4 6.83922 20.3 7.45922 20.1 8.05922C19.9 8.65922 19.6 9.21922 19.2 9.73922L24 14.5392L22.74 15.7992ZM14.393 10.3992C15.5577 10.3992 16.55 9.99157 17.37 9.17627C18.19 8.36099 18.6 7.37099 18.6 6.20627C18.6 5.04157 18.1923 4.04922 17.377 3.22922C16.5618 2.40922 15.5718 1.99922 14.407 1.99922C13.2423 1.99922 12.25 2.40687 11.43 3.22217C10.61 4.03745 10.2 5.02745 10.2 6.19217C10.2 7.35687 10.6077 8.34922 11.423 9.16922C12.2382 9.98922 13.2282 10.3992 14.393 10.3992Z"
|
|
45
|
-
fill="white"
|
|
46
|
-
/>
|
|
47
|
-
</g>
|
|
48
|
-
</svg>
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
const items = {
|
|
52
|
-
calendar: getItem('calendar', { iconName: 'event' }),
|
|
53
|
-
calls: getItem('calls', { iconName: 'local_phone', isActive: true, counter: 12 }),
|
|
54
|
-
dashboard: getItem('dashboard', { iconName: 'odometer', isActive: true }),
|
|
55
|
-
dispatch: getItem('dispatch', { iconName: 'location_disabled', counter: 1 }),
|
|
56
|
-
fleet: getItem('fleet', { iconName: 'fleet-pro', title: 'Fleet Pro' }),
|
|
57
|
-
followUps: getItem('followUps', { iconName: 'flag', title: 'Follow Ups' }),
|
|
58
|
-
inventory: getItem('inventory', { iconName: 'toys' }),
|
|
59
|
-
purchasing: getItem('purchasing', { iconComponent: InventoryIcon }),
|
|
60
|
-
accounting: getItem('accounting', { iconName: 'assignment' }),
|
|
61
|
-
marketing: getItem('marketing', { iconName: 'bullhorn' }),
|
|
62
|
-
priceBook: getItem('priceBook', { iconName: 'book' }),
|
|
63
|
-
pointOfSale: getItem('pointOfSale', { iconName: 'cash-register' }),
|
|
64
|
-
projects: getItem('projects', { iconName: 'folder_special' }),
|
|
65
|
-
reports: getItem('reports', { iconName: 'poll' }),
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const NavLinkMock: FC<NavLinkComponentProps> = props => (
|
|
69
|
-
<a
|
|
70
|
-
href={props.to}
|
|
71
|
-
target={props.target}
|
|
72
|
-
onClick={e => {
|
|
73
|
-
e.preventDefault();
|
|
74
|
-
}}
|
|
75
|
-
className={props.className}
|
|
76
|
-
>
|
|
77
|
-
{props.children}
|
|
78
|
-
</a>
|
|
79
|
-
);
|
|
16
|
+
const SvgIcon = undefined as any;
|
|
80
17
|
|
|
81
18
|
export const defaultNavigation = () => (
|
|
82
19
|
<HeaderNavigation
|
|
@@ -130,6 +67,8 @@ const HelpCenterButton = () => {
|
|
|
130
67
|
id="help"
|
|
131
68
|
iconName="help_outline"
|
|
132
69
|
onClick={() => setOpen(true)}
|
|
70
|
+
icon={SvgIcon}
|
|
71
|
+
iconActive={SvgIcon}
|
|
133
72
|
/>
|
|
134
73
|
}
|
|
135
74
|
portal
|
|
@@ -168,7 +107,13 @@ export const withAllMonolithData = () => (
|
|
|
168
107
|
>
|
|
169
108
|
<TimeZoneOffset />
|
|
170
109
|
|
|
171
|
-
<HeaderNavigationTrigger
|
|
110
|
+
<HeaderNavigationTrigger
|
|
111
|
+
id="dialpad"
|
|
112
|
+
iconName="phone"
|
|
113
|
+
counter={2}
|
|
114
|
+
icon={SvgIcon}
|
|
115
|
+
iconActive={SvgIcon}
|
|
116
|
+
/>
|
|
172
117
|
|
|
173
118
|
<HeaderNavigationLink
|
|
174
119
|
id="search"
|
|
@@ -176,6 +121,8 @@ export const withAllMonolithData = () => (
|
|
|
176
121
|
target="_blank"
|
|
177
122
|
iconComponent={SearchIcon}
|
|
178
123
|
hint="Search: for all the questions"
|
|
124
|
+
icon={SvgIcon}
|
|
125
|
+
iconActive={SvgIcon}
|
|
179
126
|
/>
|
|
180
127
|
|
|
181
128
|
<HelpCenterButton />
|
|
@@ -183,6 +130,8 @@ export const withAllMonolithData = () => (
|
|
|
183
130
|
id="titanAdvisor"
|
|
184
131
|
iconName="rocket"
|
|
185
132
|
iconClassName={Styles.rocketIcon}
|
|
133
|
+
icon={SvgIcon}
|
|
134
|
+
iconActive={SvgIcon}
|
|
186
135
|
/>
|
|
187
136
|
|
|
188
137
|
<HeaderNavigationLink
|
|
@@ -193,6 +142,8 @@ export const withAllMonolithData = () => (
|
|
|
193
142
|
aria-label="search"
|
|
194
143
|
hint="Settings"
|
|
195
144
|
isActive
|
|
145
|
+
icon={SvgIcon}
|
|
146
|
+
iconActive={SvgIcon}
|
|
196
147
|
/>
|
|
197
148
|
|
|
198
149
|
<ProfileDropdown>
|
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
import { Icon, Popover, PopoverPropsStrict } from '@servicetitan/design-system';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
FC,
|
|
5
|
+
ReactElement,
|
|
6
|
+
ReactNode,
|
|
7
|
+
useCallback,
|
|
8
|
+
useEffect,
|
|
9
|
+
useMemo,
|
|
10
|
+
useRef,
|
|
11
|
+
useState,
|
|
12
|
+
} from 'react';
|
|
4
13
|
import { HeaderNavigationItemData, NavLinkComponentProps } from '../../utils/navigation';
|
|
5
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
DefaultNavLinkComponent,
|
|
16
|
+
NavigationContext,
|
|
17
|
+
NavigationContextType,
|
|
18
|
+
} from '../../utils/navigation-context';
|
|
6
19
|
import { HeaderNavigationItem } from './header-navigation-content';
|
|
7
20
|
import * as Styles from './header-navigation.module.less';
|
|
8
21
|
|
|
@@ -139,8 +152,16 @@ export const HeaderNavigation: FC<HeaderNavigationProps> = ({
|
|
|
139
152
|
updateIsMinimized();
|
|
140
153
|
});
|
|
141
154
|
|
|
155
|
+
const context: NavigationContextType = useMemo(
|
|
156
|
+
() => ({
|
|
157
|
+
NavigationComponent: navigationComponent,
|
|
158
|
+
isLegacy: true,
|
|
159
|
+
}),
|
|
160
|
+
[navigationComponent]
|
|
161
|
+
);
|
|
162
|
+
|
|
142
163
|
return (
|
|
143
|
-
<
|
|
164
|
+
<NavigationContext.Provider value={context}>
|
|
144
165
|
<div
|
|
145
166
|
className={classNames(Styles.header, className, {
|
|
146
167
|
[Styles.calculating]: minimized === MinimizedState.Calculating,
|
|
@@ -186,7 +207,7 @@ export const HeaderNavigation: FC<HeaderNavigationProps> = ({
|
|
|
186
207
|
{children}
|
|
187
208
|
</div>
|
|
188
209
|
</div>
|
|
189
|
-
</
|
|
210
|
+
</NavigationContext.Provider>
|
|
190
211
|
);
|
|
191
212
|
};
|
|
192
213
|
|
|
@@ -268,8 +289,16 @@ export const HeaderNavigationStacked: FC<HeaderNavigationStackedProps> = ({
|
|
|
268
289
|
updateIsMinimized();
|
|
269
290
|
});
|
|
270
291
|
|
|
292
|
+
const context: NavigationContextType = useMemo(
|
|
293
|
+
() => ({
|
|
294
|
+
NavigationComponent: navigationComponent,
|
|
295
|
+
isLegacy: true,
|
|
296
|
+
}),
|
|
297
|
+
[navigationComponent]
|
|
298
|
+
);
|
|
299
|
+
|
|
271
300
|
return (
|
|
272
|
-
<
|
|
301
|
+
<NavigationContext.Provider value={context}>
|
|
273
302
|
<div
|
|
274
303
|
className={classNames(
|
|
275
304
|
Styles.headerStacked,
|
|
@@ -328,7 +357,7 @@ export const HeaderNavigationStacked: FC<HeaderNavigationStackedProps> = ({
|
|
|
328
357
|
</div>
|
|
329
358
|
</div>
|
|
330
359
|
</div>
|
|
331
|
-
</
|
|
360
|
+
</NavigationContext.Provider>
|
|
332
361
|
);
|
|
333
362
|
};
|
|
334
363
|
|
|
@@ -367,8 +396,16 @@ export const HeaderNavigationTiny: FC<HeaderNavigationTinyProps> = ({
|
|
|
367
396
|
minWidth = 800,
|
|
368
397
|
navigationComponent = DefaultNavLinkComponent,
|
|
369
398
|
}) => {
|
|
399
|
+
const context: NavigationContextType = useMemo(
|
|
400
|
+
() => ({
|
|
401
|
+
NavigationComponent: navigationComponent,
|
|
402
|
+
isLegacy: false,
|
|
403
|
+
}),
|
|
404
|
+
[navigationComponent]
|
|
405
|
+
);
|
|
406
|
+
|
|
370
407
|
return (
|
|
371
|
-
<
|
|
408
|
+
<NavigationContext.Provider value={context}>
|
|
372
409
|
<div
|
|
373
410
|
className={classNames(Styles.headerTiny, className)}
|
|
374
411
|
style={{ minWidth: `${minWidth}px` }}
|
|
@@ -398,6 +435,6 @@ export const HeaderNavigationTiny: FC<HeaderNavigationTinyProps> = ({
|
|
|
398
435
|
{right}
|
|
399
436
|
</div>
|
|
400
437
|
</div>
|
|
401
|
-
</
|
|
438
|
+
</NavigationContext.Provider>
|
|
402
439
|
);
|
|
403
440
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { withAnvil, withMemoryRouter } from '../test/data.stories';
|
|
1
2
|
import {
|
|
2
3
|
WithAllMonolithData,
|
|
3
4
|
WithAllMonolithDataCommercial,
|
|
@@ -7,6 +8,7 @@ import { DefaultSideNavigation } from './side-navigation/side-navigation.stories
|
|
|
7
8
|
export default {
|
|
8
9
|
title: 'Navigation/Layout',
|
|
9
10
|
parameters: {},
|
|
11
|
+
decorators: [withMemoryRouter, withAnvil],
|
|
10
12
|
};
|
|
11
13
|
|
|
12
14
|
export const LeftNavLayout = () => {
|
|
@@ -1,178 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { FC } from 'react';
|
|
3
|
-
import { NavLinkComponentProps } from '../../utils/navigation';
|
|
1
|
+
import { NavLinkMock, withAnvil, withMemoryRouter } from '../../test/data.stories';
|
|
4
2
|
import { HeaderNavigationStacked } from '../header-navigation';
|
|
3
|
+
export * from './profile-dropdown.stories';
|
|
5
4
|
import { ProfileDropdown } from './profile-dropdown';
|
|
6
5
|
|
|
6
|
+
const withHeaderNavigationStacked = (Story: any) => (
|
|
7
|
+
<HeaderNavigationStacked navigationComponent={NavLinkMock} right={<Story />} />
|
|
8
|
+
);
|
|
9
|
+
|
|
7
10
|
export default {
|
|
8
11
|
title: 'Navigation/ProfileDropdownStacked',
|
|
9
12
|
component: ProfileDropdown,
|
|
10
13
|
parameters: {},
|
|
14
|
+
decorators: [withMemoryRouter, withAnvil, withHeaderNavigationStacked],
|
|
11
15
|
};
|
|
12
|
-
|
|
13
|
-
const NavLinkMock: FC<NavLinkComponentProps> = props => (
|
|
14
|
-
<a
|
|
15
|
-
href={props.to}
|
|
16
|
-
target={props.target}
|
|
17
|
-
onClick={e => {
|
|
18
|
-
e.preventDefault();
|
|
19
|
-
}}
|
|
20
|
-
className={props.className}
|
|
21
|
-
>
|
|
22
|
-
{props.children}
|
|
23
|
-
</a>
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
export const profileDropdownDefault = () => (
|
|
27
|
-
<HeaderNavigationStacked
|
|
28
|
-
navigationComponent={NavLinkMock}
|
|
29
|
-
right={
|
|
30
|
-
<ProfileDropdown>
|
|
31
|
-
<ProfileDropdown.Link id="first" to="https://google.com">
|
|
32
|
-
first link
|
|
33
|
-
</ProfileDropdown.Link>
|
|
34
|
-
<ProfileDropdown.Link id="second" onClick={() => alert('second click')}>
|
|
35
|
-
second link
|
|
36
|
-
</ProfileDropdown.Link>
|
|
37
|
-
<ProfileDropdown.Divider />
|
|
38
|
-
<ProfileDropdown.Section id="content">some content</ProfileDropdown.Section>
|
|
39
|
-
<ProfileDropdown.Divider />
|
|
40
|
-
<ProfileDropdown.Divider />
|
|
41
|
-
<ProfileDropdown.Divider />
|
|
42
|
-
<ProfileDropdown.Link id="third" to="https://google.com">
|
|
43
|
-
third link
|
|
44
|
-
</ProfileDropdown.Link>
|
|
45
|
-
<ProfileDropdown.Divider />
|
|
46
|
-
</ProfileDropdown>
|
|
47
|
-
}
|
|
48
|
-
/>
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
export const profileDropdownWithLogo = () => (
|
|
52
|
-
<HeaderNavigationStacked
|
|
53
|
-
navigationComponent={NavLinkMock}
|
|
54
|
-
right={
|
|
55
|
-
<ProfileDropdown
|
|
56
|
-
trigger={{
|
|
57
|
-
imageSrc:
|
|
58
|
-
'https://upload.wikimedia.org/wikipedia/en/1/11/Milhouse_Van_Houten.png',
|
|
59
|
-
}}
|
|
60
|
-
>
|
|
61
|
-
<ProfileDropdown.Link id="first" to="https://google.com">
|
|
62
|
-
first link
|
|
63
|
-
</ProfileDropdown.Link>
|
|
64
|
-
<ProfileDropdown.Link id="second" onClick={() => alert('second click')}>
|
|
65
|
-
second link
|
|
66
|
-
</ProfileDropdown.Link>
|
|
67
|
-
</ProfileDropdown>
|
|
68
|
-
}
|
|
69
|
-
/>
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
export const profileDropdownWithErrorLogo = () => (
|
|
73
|
-
<HeaderNavigationStacked
|
|
74
|
-
right={
|
|
75
|
-
<ProfileDropdown
|
|
76
|
-
trigger={{
|
|
77
|
-
imageSrc: 'https://some.incorrect.url/logo.png',
|
|
78
|
-
}}
|
|
79
|
-
/>
|
|
80
|
-
}
|
|
81
|
-
/>
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
export const profileDropdownWithInfo = () => (
|
|
85
|
-
<HeaderNavigationStacked
|
|
86
|
-
right={
|
|
87
|
-
<ProfileDropdown
|
|
88
|
-
trigger={{
|
|
89
|
-
info: { text: 'first', title: 'tenant user' },
|
|
90
|
-
avatarBadge: true,
|
|
91
|
-
}}
|
|
92
|
-
/>
|
|
93
|
-
}
|
|
94
|
-
/>
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
export const profileDropdownWithCounter = () => (
|
|
98
|
-
<HeaderNavigationStacked
|
|
99
|
-
right={
|
|
100
|
-
<ProfileDropdown
|
|
101
|
-
trigger={{
|
|
102
|
-
info: { text: 'first', title: 'tenant user' },
|
|
103
|
-
avatarBadge: true,
|
|
104
|
-
badge: { content: 3, className: 'bg-red-500' },
|
|
105
|
-
}}
|
|
106
|
-
/>
|
|
107
|
-
}
|
|
108
|
-
/>
|
|
109
|
-
);
|
|
110
|
-
|
|
111
|
-
export const profileDropdownWithBothBadges = () => (
|
|
112
|
-
<HeaderNavigationStacked
|
|
113
|
-
right={
|
|
114
|
-
<ProfileDropdown
|
|
115
|
-
trigger={{
|
|
116
|
-
avatarBadge: 'yellow-500',
|
|
117
|
-
badge: { className: 'bg-red-400' },
|
|
118
|
-
}}
|
|
119
|
-
/>
|
|
120
|
-
}
|
|
121
|
-
/>
|
|
122
|
-
);
|
|
123
|
-
|
|
124
|
-
// eslint-disable-next-line no-console
|
|
125
|
-
const log = (text: string) => console.log(text);
|
|
126
|
-
|
|
127
|
-
export const profileDropdownWithHintPopup = () => (
|
|
128
|
-
<HeaderNavigationStacked
|
|
129
|
-
navigationComponent={NavLinkMock}
|
|
130
|
-
right={
|
|
131
|
-
<ProfileDropdown
|
|
132
|
-
trigger={{
|
|
133
|
-
avatarBadge: 'yellow-500',
|
|
134
|
-
badge: { className: 'bg-red-400' },
|
|
135
|
-
}}
|
|
136
|
-
hintPopup={{
|
|
137
|
-
className: 'bg-blue-500-i c-white',
|
|
138
|
-
content: ({ openProfile }) => (
|
|
139
|
-
<div>
|
|
140
|
-
hello{' '}
|
|
141
|
-
<Button onClick={openProfile} size="xsmall">
|
|
142
|
-
show me
|
|
143
|
-
</Button>
|
|
144
|
-
</div>
|
|
145
|
-
),
|
|
146
|
-
width: 's',
|
|
147
|
-
onClose: () => log('close profile dropdown hint'),
|
|
148
|
-
}}
|
|
149
|
-
onOpen={() => log('open profile dropdown')}
|
|
150
|
-
onClose={() => log('close profile dropdown')}
|
|
151
|
-
>
|
|
152
|
-
<ProfileDropdown.Link id="first" to="https://google.com">
|
|
153
|
-
first item
|
|
154
|
-
</ProfileDropdown.Link>
|
|
155
|
-
<ProfileDropdown.Divider />
|
|
156
|
-
<ProfileDropdown.Section id="second">second item</ProfileDropdown.Section>
|
|
157
|
-
</ProfileDropdown>
|
|
158
|
-
}
|
|
159
|
-
/>
|
|
160
|
-
);
|
|
161
|
-
|
|
162
|
-
export const profileDropdownWithHintAndInfoPopup = () => (
|
|
163
|
-
<HeaderNavigationStacked
|
|
164
|
-
navigationComponent={NavLinkMock}
|
|
165
|
-
right={
|
|
166
|
-
<ProfileDropdown
|
|
167
|
-
trigger={{
|
|
168
|
-
avatarBadge: 'yellow-500',
|
|
169
|
-
badge: { className: 'bg-red-400' },
|
|
170
|
-
info: { title: 'some text', text: 'qq' },
|
|
171
|
-
}}
|
|
172
|
-
hintPopup={{
|
|
173
|
-
content: () => <div>hello</div>,
|
|
174
|
-
}}
|
|
175
|
-
/>
|
|
176
|
-
}
|
|
177
|
-
/>
|
|
178
|
-
);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { NavLinkMock, withAnvil, withMemoryRouter } from '../../test/data.stories';
|
|
2
|
+
import { HeaderNavigationTiny } from '../header-navigation';
|
|
3
|
+
export * from './profile-dropdown.stories';
|
|
4
|
+
import { ProfileDropdown } from './profile-dropdown';
|
|
5
|
+
|
|
6
|
+
const withHeaderNavigationTiny = (Story: any) => (
|
|
7
|
+
<HeaderNavigationTiny className="border" navigationComponent={NavLinkMock} right={<Story />} />
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
title: 'Navigation/ProfileDropdownTiny',
|
|
12
|
+
component: ProfileDropdown,
|
|
13
|
+
parameters: {},
|
|
14
|
+
decorators: [withMemoryRouter, withAnvil, withHeaderNavigationTiny],
|
|
15
|
+
};
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
.avatar-badge {
|
|
18
18
|
position: absolute;
|
|
19
19
|
top: 8px;
|
|
20
|
-
left:
|
|
20
|
+
left: 4px;
|
|
21
21
|
height: 12px;
|
|
22
22
|
width: 12px;
|
|
23
23
|
border-radius: @border-radius-circular;
|
|
@@ -50,6 +50,12 @@
|
|
|
50
50
|
border-radius: 8px;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
&.trigger-container-legacy {
|
|
54
|
+
.avatar-badge {
|
|
55
|
+
left: 0;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
53
59
|
&.trigger-container-hint-arrow:first-child:before {
|
|
54
60
|
display: none;
|
|
55
61
|
content: '';
|