@servicetitan/navigation 3.2.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 +12 -12
- 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,157 +1,134 @@
|
|
|
1
1
|
import { Button } from '@servicetitan/design-system';
|
|
2
|
-
import {
|
|
3
|
-
import { NavLinkComponentProps } from '../../utils/navigation';
|
|
2
|
+
import { NavLinkMock, withAnvil, withMemoryRouter } from '../../test/data.stories';
|
|
4
3
|
import { HeaderNavigation } from '../header-navigation';
|
|
5
4
|
import { ProfileDropdown } from './profile-dropdown';
|
|
6
5
|
|
|
6
|
+
const withHeaderNavigation = (Story: any) => (
|
|
7
|
+
<HeaderNavigation navigationComponent={NavLinkMock}>
|
|
8
|
+
<Story />
|
|
9
|
+
</HeaderNavigation>
|
|
10
|
+
);
|
|
11
|
+
|
|
7
12
|
export default {
|
|
8
13
|
title: 'Navigation/ProfileDropdown',
|
|
9
14
|
component: ProfileDropdown,
|
|
10
15
|
parameters: {},
|
|
16
|
+
decorators: [withMemoryRouter, withAnvil, withHeaderNavigation],
|
|
11
17
|
};
|
|
12
18
|
|
|
13
|
-
const
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
</ProfileDropdown.Link>
|
|
32
|
-
<ProfileDropdown.Link id="second" onClick={() => alert('second click')}>
|
|
33
|
-
second link
|
|
34
|
-
</ProfileDropdown.Link>
|
|
35
|
-
<ProfileDropdown.Divider />
|
|
36
|
-
<ProfileDropdown.Section id="content">some content</ProfileDropdown.Section>
|
|
37
|
-
<ProfileDropdown.Divider />
|
|
38
|
-
<ProfileDropdown.Divider />
|
|
39
|
-
<ProfileDropdown.Divider />
|
|
40
|
-
<ProfileDropdown.Link id="third" to="https://google.com">
|
|
41
|
-
third link
|
|
42
|
-
</ProfileDropdown.Link>
|
|
43
|
-
<ProfileDropdown.Divider />
|
|
44
|
-
</ProfileDropdown>
|
|
45
|
-
</HeaderNavigation>
|
|
19
|
+
export const ProfileDropdownDefault = () => (
|
|
20
|
+
<ProfileDropdown>
|
|
21
|
+
<ProfileDropdown.Link id="first" to="https://google.com">
|
|
22
|
+
first link
|
|
23
|
+
</ProfileDropdown.Link>
|
|
24
|
+
<ProfileDropdown.Link id="second" onClick={() => alert('second click')}>
|
|
25
|
+
second link
|
|
26
|
+
</ProfileDropdown.Link>
|
|
27
|
+
<ProfileDropdown.Divider />
|
|
28
|
+
<ProfileDropdown.Section id="content">some content</ProfileDropdown.Section>
|
|
29
|
+
<ProfileDropdown.Divider />
|
|
30
|
+
<ProfileDropdown.Divider />
|
|
31
|
+
<ProfileDropdown.Divider />
|
|
32
|
+
<ProfileDropdown.Link id="third" to="third">
|
|
33
|
+
third link
|
|
34
|
+
</ProfileDropdown.Link>
|
|
35
|
+
<ProfileDropdown.Divider />
|
|
36
|
+
</ProfileDropdown>
|
|
46
37
|
);
|
|
47
38
|
|
|
48
|
-
export const
|
|
49
|
-
<
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
>
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
</ProfileDropdown>
|
|
62
|
-
</HeaderNavigation>
|
|
39
|
+
export const ProfileDropdownWithLogo = () => (
|
|
40
|
+
<ProfileDropdown
|
|
41
|
+
trigger={{
|
|
42
|
+
imageSrc: 'https://upload.wikimedia.org/wikipedia/en/1/11/Milhouse_Van_Houten.png',
|
|
43
|
+
}}
|
|
44
|
+
>
|
|
45
|
+
<ProfileDropdown.Link id="first" to="https://google.com">
|
|
46
|
+
first link
|
|
47
|
+
</ProfileDropdown.Link>
|
|
48
|
+
<ProfileDropdown.Link id="second" onClick={() => alert('second click')}>
|
|
49
|
+
second link
|
|
50
|
+
</ProfileDropdown.Link>
|
|
51
|
+
</ProfileDropdown>
|
|
63
52
|
);
|
|
64
53
|
|
|
65
|
-
export const
|
|
66
|
-
<
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
/>
|
|
72
|
-
</HeaderNavigation>
|
|
54
|
+
export const ProfileDropdownWithErrorLogo = () => (
|
|
55
|
+
<ProfileDropdown
|
|
56
|
+
trigger={{
|
|
57
|
+
imageSrc: 'https://some.incorrect.url/logo.png',
|
|
58
|
+
}}
|
|
59
|
+
/>
|
|
73
60
|
);
|
|
74
61
|
|
|
75
|
-
export const
|
|
76
|
-
<
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
/>
|
|
83
|
-
</HeaderNavigation>
|
|
62
|
+
export const ProfileDropdownWithInfo = () => (
|
|
63
|
+
<ProfileDropdown
|
|
64
|
+
trigger={{
|
|
65
|
+
info: { text: 'first', title: 'tenant user' },
|
|
66
|
+
avatarBadge: true,
|
|
67
|
+
}}
|
|
68
|
+
/>
|
|
84
69
|
);
|
|
85
70
|
|
|
86
|
-
export const
|
|
87
|
-
<
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
/>
|
|
95
|
-
</HeaderNavigation>
|
|
71
|
+
export const ProfileDropdownWithCounter = () => (
|
|
72
|
+
<ProfileDropdown
|
|
73
|
+
trigger={{
|
|
74
|
+
info: { text: 'first', title: 'tenant user' },
|
|
75
|
+
avatarBadge: true,
|
|
76
|
+
badge: { content: 3, className: 'bg-red-500' },
|
|
77
|
+
}}
|
|
78
|
+
/>
|
|
96
79
|
);
|
|
97
80
|
|
|
98
|
-
export const
|
|
99
|
-
<
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
/>
|
|
106
|
-
</HeaderNavigation>
|
|
81
|
+
export const ProfileDropdownWithBothBadges = () => (
|
|
82
|
+
<ProfileDropdown
|
|
83
|
+
trigger={{
|
|
84
|
+
avatarBadge: 'yellow-500',
|
|
85
|
+
badge: { className: 'bg-red-400' },
|
|
86
|
+
}}
|
|
87
|
+
/>
|
|
107
88
|
);
|
|
108
89
|
|
|
109
90
|
// eslint-disable-next-line no-console
|
|
110
91
|
const log = (text: string) => console.log(text);
|
|
111
92
|
|
|
112
|
-
export const
|
|
113
|
-
<
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
>
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
</ProfileDropdown>
|
|
141
|
-
</HeaderNavigation>
|
|
93
|
+
export const ProfileDropdownWithHintPopup = () => (
|
|
94
|
+
<ProfileDropdown
|
|
95
|
+
trigger={{
|
|
96
|
+
avatarBadge: 'yellow-500',
|
|
97
|
+
badge: { className: 'bg-red-400' },
|
|
98
|
+
}}
|
|
99
|
+
hintPopup={{
|
|
100
|
+
className: 'bg-blue-500-i c-white',
|
|
101
|
+
content: ({ openProfile }) => (
|
|
102
|
+
<div>
|
|
103
|
+
hello{' '}
|
|
104
|
+
<Button onClick={openProfile} size="xsmall">
|
|
105
|
+
show me
|
|
106
|
+
</Button>
|
|
107
|
+
</div>
|
|
108
|
+
),
|
|
109
|
+
width: 's',
|
|
110
|
+
onClose: () => log('close profile dropdown hint'),
|
|
111
|
+
}}
|
|
112
|
+
onOpen={() => log('open profile dropdown')}
|
|
113
|
+
onClose={() => log('close profile dropdown')}
|
|
114
|
+
>
|
|
115
|
+
<ProfileDropdown.Link id="first" to="https://google.com">
|
|
116
|
+
first item
|
|
117
|
+
</ProfileDropdown.Link>
|
|
118
|
+
<ProfileDropdown.Divider />
|
|
119
|
+
<ProfileDropdown.Section id="second">second item</ProfileDropdown.Section>
|
|
120
|
+
</ProfileDropdown>
|
|
142
121
|
);
|
|
143
122
|
|
|
144
|
-
export const
|
|
145
|
-
<
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
/>
|
|
156
|
-
</HeaderNavigation>
|
|
123
|
+
export const ProfileDropdownWithHintAndInfoPopup = () => (
|
|
124
|
+
<ProfileDropdown
|
|
125
|
+
trigger={{
|
|
126
|
+
avatarBadge: 'yellow-500',
|
|
127
|
+
badge: { className: 'bg-red-400' },
|
|
128
|
+
info: { title: 'some text', text: 'qq' },
|
|
129
|
+
}}
|
|
130
|
+
hintPopup={{
|
|
131
|
+
content: () => <div>hello</div>,
|
|
132
|
+
}}
|
|
133
|
+
/>
|
|
157
134
|
);
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Icon } from '@servicetitan/anvil2';
|
|
2
|
+
import SvgExpandLess from '@servicetitan/anvil2/assets/icons/material/round/expand_less.svg';
|
|
3
|
+
import SvgExpandMore from '@servicetitan/anvil2/assets/icons/material/round/expand_more.svg';
|
|
4
|
+
import SvgAccountActive from '@servicetitan/anvil2/assets/icons/st/gnav_account_active.svg';
|
|
5
|
+
import SvgAccountInactive from '@servicetitan/anvil2/assets/icons/st/gnav_account_inactive.svg';
|
|
6
|
+
import { BodyText, Popover, PopoverPropsStrict } from '@servicetitan/design-system';
|
|
2
7
|
import classNames from 'classnames';
|
|
3
8
|
import {
|
|
4
9
|
FC,
|
|
@@ -7,12 +12,13 @@ import {
|
|
|
7
12
|
MouseEventHandler,
|
|
8
13
|
ReactNode,
|
|
9
14
|
useCallback,
|
|
15
|
+
useContext,
|
|
10
16
|
useEffect,
|
|
11
17
|
useMemo,
|
|
12
18
|
useState,
|
|
13
19
|
} from 'react';
|
|
14
20
|
|
|
15
|
-
import {
|
|
21
|
+
import { NavigationContext } from '../../utils/navigation-context';
|
|
16
22
|
import { CounterTag, CounterTagPropsType } from '../counter-tag';
|
|
17
23
|
import * as Styles from './profile-dropdown.module.less';
|
|
18
24
|
import { ProfileLogo } from './profile-icon';
|
|
@@ -24,6 +30,7 @@ export interface ProfileDropdownTriggerProps {
|
|
|
24
30
|
avatarBadge?: boolean | string;
|
|
25
31
|
badge?: { content?: number | string; className: string };
|
|
26
32
|
hintArrow?: boolean;
|
|
33
|
+
open: boolean;
|
|
27
34
|
onClick?(e: MouseEvent): void;
|
|
28
35
|
}
|
|
29
36
|
|
|
@@ -35,9 +42,11 @@ const ProfileDropdownTrigger: FC<ProfileDropdownTriggerProps> = ({
|
|
|
35
42
|
imageSrc,
|
|
36
43
|
info,
|
|
37
44
|
onClick,
|
|
45
|
+
open,
|
|
38
46
|
}) => {
|
|
39
47
|
const [avatarSource, setAvatarSource] = useState(imageSrc ?? '');
|
|
40
48
|
const [avatarSourceError, setAvatarSourceError] = useState(false);
|
|
49
|
+
const { isLegacy } = useContext(NavigationContext);
|
|
41
50
|
|
|
42
51
|
useEffect(() => {
|
|
43
52
|
const src = imageSrc ?? '';
|
|
@@ -60,7 +69,10 @@ const ProfileDropdownTrigger: FC<ProfileDropdownTriggerProps> = ({
|
|
|
60
69
|
'd-f align-items-center cursor-pointer position-relative p-x-1 p-y-half',
|
|
61
70
|
'profile-dropdown-trigger',
|
|
62
71
|
Styles.triggerContainer,
|
|
63
|
-
{
|
|
72
|
+
{
|
|
73
|
+
[Styles.triggerContainerHintArrow]: hintArrow,
|
|
74
|
+
[Styles.triggerContainerLegacy]: isLegacy,
|
|
75
|
+
},
|
|
64
76
|
className
|
|
65
77
|
)}
|
|
66
78
|
onClick={onClick}
|
|
@@ -74,13 +86,20 @@ const ProfileDropdownTrigger: FC<ProfileDropdownTriggerProps> = ({
|
|
|
74
86
|
onError={onAvatarError}
|
|
75
87
|
alt="user dropdown menu"
|
|
76
88
|
/>
|
|
77
|
-
) : (
|
|
89
|
+
) : isLegacy ? (
|
|
78
90
|
<ProfileLogo />
|
|
91
|
+
) : (
|
|
92
|
+
<Icon size="large" svg={open ? SvgAccountActive : SvgAccountInactive} />
|
|
79
93
|
)}
|
|
80
94
|
|
|
81
95
|
{!!info && (
|
|
82
96
|
<div className={Styles.info}>
|
|
83
|
-
<BodyText
|
|
97
|
+
<BodyText
|
|
98
|
+
bold
|
|
99
|
+
title={info.title}
|
|
100
|
+
className="t-truncate c-inherit"
|
|
101
|
+
size="xsmall"
|
|
102
|
+
>
|
|
84
103
|
{info.title}
|
|
85
104
|
</BodyText>
|
|
86
105
|
<BodyText
|
|
@@ -93,7 +112,11 @@ const ProfileDropdownTrigger: FC<ProfileDropdownTriggerProps> = ({
|
|
|
93
112
|
</div>
|
|
94
113
|
)}
|
|
95
114
|
|
|
96
|
-
<Icon
|
|
115
|
+
<Icon
|
|
116
|
+
svg={open ? SvgExpandLess : SvgExpandMore}
|
|
117
|
+
className={classNames('d-f align-items-center c-inherit', { 'm-l-half': isLegacy })}
|
|
118
|
+
size="small"
|
|
119
|
+
/>
|
|
97
120
|
|
|
98
121
|
{!!avatarBadge && (
|
|
99
122
|
<div
|
|
@@ -185,7 +208,7 @@ export const ProfileDropdownLink: FC<ProfileDropdownLinkProps> = ({
|
|
|
185
208
|
onClick,
|
|
186
209
|
...rest
|
|
187
210
|
}: ProfileDropdownLinkProps) => {
|
|
188
|
-
const NavigationComponent =
|
|
211
|
+
const { NavigationComponent } = useContext(NavigationContext);
|
|
189
212
|
|
|
190
213
|
const clickHandler = (e: MouseEvent<any>) => {
|
|
191
214
|
e.preventDefault();
|
|
@@ -241,7 +264,7 @@ export interface ProfileDropdownPropsStrict {
|
|
|
241
264
|
children?: ReactNode;
|
|
242
265
|
className?: string;
|
|
243
266
|
direction?: PopoverPropsStrict['direction'];
|
|
244
|
-
trigger?: Omit<ProfileDropdownTriggerProps, 'onClick' | 'hintArrow'>;
|
|
267
|
+
trigger?: Omit<ProfileDropdownTriggerProps, 'onClick' | 'open' | 'hintArrow'>;
|
|
245
268
|
hintPopup?: {
|
|
246
269
|
className?: string;
|
|
247
270
|
content: FC<{ openProfile(): void }>;
|
|
@@ -305,6 +328,7 @@ export const ProfileDropdown: ProfileDropdownType = (({
|
|
|
305
328
|
{...trigger}
|
|
306
329
|
onClick={children ? onTriggerClick : undefined}
|
|
307
330
|
hintArrow={hintShown}
|
|
331
|
+
open={open}
|
|
308
332
|
/>
|
|
309
333
|
);
|
|
310
334
|
|
|
@@ -84,6 +84,16 @@
|
|
|
84
84
|
color: @text-color-active;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
&.navigation-item-icon-state.navigation-item-active {
|
|
88
|
+
.navigation-icon:not(.navigation-icon-active) {
|
|
89
|
+
display: none;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.navigation-icon.navigation-icon-active {
|
|
93
|
+
display: block;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
87
97
|
&:hover:not(.navigation-item-active) {
|
|
88
98
|
background-color: @bg-color-hover;
|
|
89
99
|
}
|
|
@@ -104,7 +114,16 @@
|
|
|
104
114
|
.navigation-icon {
|
|
105
115
|
height: 24px;
|
|
106
116
|
width: 24px;
|
|
107
|
-
|
|
117
|
+
color: inherit;
|
|
118
|
+
|
|
119
|
+
& > svg {
|
|
120
|
+
height: 24px;
|
|
121
|
+
width: 24px;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
&.navigation-icon-active {
|
|
125
|
+
display: none;
|
|
126
|
+
}
|
|
108
127
|
}
|
|
109
128
|
|
|
110
129
|
.options-item {
|
|
@@ -130,9 +149,14 @@
|
|
|
130
149
|
.options-icon {
|
|
131
150
|
height: 24px;
|
|
132
151
|
width: 24px;
|
|
133
|
-
font-size: 24px;
|
|
134
152
|
padding-left: @spacing-1;
|
|
135
153
|
padding-right: @spacing-1;
|
|
154
|
+
|
|
155
|
+
& > span > svg {
|
|
156
|
+
height: 24px;
|
|
157
|
+
width: 24px;
|
|
158
|
+
color: @text-color;
|
|
159
|
+
}
|
|
136
160
|
}
|
|
137
161
|
|
|
138
162
|
.options-item-text {
|
|
@@ -143,24 +167,6 @@
|
|
|
143
167
|
}
|
|
144
168
|
}
|
|
145
169
|
|
|
146
|
-
.options-popover-item-clickable {
|
|
147
|
-
cursor: pointer;
|
|
148
|
-
|
|
149
|
-
&:hover {
|
|
150
|
-
background-color: @color-neutral-60;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
.options-popover-item-active {
|
|
155
|
-
background-color: @color-blue-100;
|
|
156
|
-
color: @color-blue-500;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
.options-popover-item-inactive,
|
|
160
|
-
.options-popover-item-active {
|
|
161
|
-
border-radius: @border-radius-1;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
170
|
.divider {
|
|
165
171
|
border-top: 1px solid @border-color;
|
|
166
172
|
margin-left: 12px;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
export const __esModule: true;
|
|
2
2
|
export const divider: string;
|
|
3
3
|
export const navigationIcon: string;
|
|
4
|
+
export const navigationIconActive: string;
|
|
4
5
|
export const navigationItem: string;
|
|
5
6
|
export const navigationItemActive: string;
|
|
6
7
|
export const navigationItemCounter: string;
|
|
8
|
+
export const navigationItemIconState: string;
|
|
7
9
|
export const navigationItemText: string;
|
|
8
10
|
export const optionsIcon: string;
|
|
9
11
|
export const optionsItem: string;
|
|
10
12
|
export const optionsItemText: string;
|
|
11
|
-
export const optionsPopoverItemActive: string;
|
|
12
|
-
export const optionsPopoverItemClickable: string;
|
|
13
|
-
export const optionsPopoverItemInactive: string;
|
|
14
13
|
export const sideNav: string;
|
|
15
14
|
export const sideNavBottom: string;
|
|
16
15
|
export const sideNavContent: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ComponentType,
|
|
2
|
-
import {
|
|
1
|
+
import { ComponentType, useState } from 'react';
|
|
2
|
+
import { NavLinkMock, items, withAnvil, withMemoryRouter } from '../../test/data.stories';
|
|
3
3
|
import { SideNavigation } from './';
|
|
4
4
|
|
|
5
5
|
const layout = (Story: ComponentType) => {
|
|
@@ -13,59 +13,10 @@ const layout = (Story: ComponentType) => {
|
|
|
13
13
|
export default {
|
|
14
14
|
title: 'Navigation/SideNavigation',
|
|
15
15
|
component: SideNavigation,
|
|
16
|
-
decorators: [layout],
|
|
16
|
+
decorators: [layout, withMemoryRouter, withAnvil],
|
|
17
17
|
parameters: {},
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
const getItem = (
|
|
21
|
-
id: string,
|
|
22
|
-
data: Partial<HeaderNavigationItemData>
|
|
23
|
-
): HeaderNavigationItemData => ({
|
|
24
|
-
id,
|
|
25
|
-
to: '/',
|
|
26
|
-
title: id[0].toUpperCase() + id.substring(1),
|
|
27
|
-
hint: id,
|
|
28
|
-
...(data ?? {}),
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
const InventoryIcon = () => (
|
|
32
|
-
<svg width="20" xmlns="http://www.w3.org/2000/svg" viewBox="-293 385 24 24" fill="currentColor">
|
|
33
|
-
<polyline points="-288,400.9 -282,404.3 -282,397.6 -288,394.2 -288,400.9 " />
|
|
34
|
-
<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" />
|
|
35
|
-
</svg>
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
const items = {
|
|
39
|
-
calendar: getItem('calendar', { iconName: 'event' }),
|
|
40
|
-
calls: getItem('calls', { iconName: 'local_phone', isActive: true, counter: 12 }),
|
|
41
|
-
dashboard: getItem('dashboard', { iconName: 'odometer' }),
|
|
42
|
-
dispatch: getItem('dispatch', { iconName: 'location_disabled', counter: 1 }),
|
|
43
|
-
fleet: getItem('fleet', { iconName: 'fleet-pro', title: 'Fleet Pro' }),
|
|
44
|
-
followUps: getItem('followUps', { iconName: 'flag', title: 'Follow Ups' }),
|
|
45
|
-
inventory: getItem('inventory', { iconName: 'toys' }),
|
|
46
|
-
purchasing: getItem('purchasing', { iconComponent: InventoryIcon }),
|
|
47
|
-
accounting: getItem('accounting', { iconName: 'assignment' }),
|
|
48
|
-
marketing: getItem('marketing', { iconName: 'bullhorn' }),
|
|
49
|
-
priceBook: getItem('priceBook', { iconName: 'book' }),
|
|
50
|
-
pointOfSale: getItem('pointOfSale', { iconName: 'cash-register' }),
|
|
51
|
-
projects: getItem('projects', { iconName: 'folder_special' }),
|
|
52
|
-
reports: getItem('reports', { iconName: 'poll' }),
|
|
53
|
-
tasks: getItem('tasks', { iconName: 'format_list_bulleted' }),
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const NavLinkMock: FC<NavLinkComponentProps> = props => (
|
|
57
|
-
<a
|
|
58
|
-
href={props.to}
|
|
59
|
-
target={props.target}
|
|
60
|
-
onClick={e => {
|
|
61
|
-
e.preventDefault();
|
|
62
|
-
}}
|
|
63
|
-
className={props.className}
|
|
64
|
-
>
|
|
65
|
-
{props.children}
|
|
66
|
-
</a>
|
|
67
|
-
);
|
|
68
|
-
|
|
69
20
|
export const DefaultSideNavigation = () => {
|
|
70
21
|
const [expanded, setExpanded] = useState(false);
|
|
71
22
|
return (
|