@servicetitan/navigation 2.0.0 → 2.2.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 +30 -0
- package/dist/components/header-navigation/header-navigation-content.d.ts.map +1 -0
- package/dist/components/header-navigation/header-navigation-content.js +21 -0
- package/dist/components/header-navigation/header-navigation-content.js.map +1 -0
- package/dist/components/header-navigation/header-navigation-extra.stories.d.ts +1 -1
- 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 +38 -0
- package/dist/components/header-navigation/header-navigation-links.d.ts.map +1 -0
- package/dist/components/header-navigation/header-navigation-links.js +38 -0
- package/dist/components/header-navigation/header-navigation-links.js.map +1 -0
- package/dist/components/header-navigation/header-navigation-stacked.stories.d.ts +11 -0
- package/dist/components/header-navigation/header-navigation-stacked.stories.d.ts.map +1 -0
- package/dist/components/header-navigation/header-navigation-stacked.stories.js +68 -0
- package/dist/components/header-navigation/header-navigation-stacked.stories.js.map +1 -0
- package/dist/components/header-navigation/header-navigation-stories.module.less +6 -0
- package/dist/components/header-navigation/header-navigation.d.ts +32 -55
- package/dist/components/header-navigation/header-navigation.d.ts.map +1 -1
- package/dist/components/header-navigation/header-navigation.js +41 -48
- package/dist/components/header-navigation/header-navigation.js.map +1 -1
- package/dist/components/header-navigation/header-navigation.module.less +171 -95
- package/dist/components/header-navigation/header-navigation.stories.d.ts.map +1 -1
- package/dist/components/header-navigation/header-navigation.stories.js +6 -4
- package/dist/components/header-navigation/header-navigation.stories.js.map +1 -1
- package/dist/components/header-navigation/index.d.ts +3 -0
- package/dist/components/header-navigation/index.d.ts.map +1 -0
- package/dist/components/header-navigation/index.js +3 -0
- package/dist/components/header-navigation/index.js.map +1 -0
- package/dist/components/logo/logo-titan-text.d.ts +21 -5
- package/dist/components/logo/logo-titan-text.d.ts.map +1 -1
- package/dist/components/logo/logo-titan-text.js +9 -3
- package/dist/components/logo/logo-titan-text.js.map +1 -1
- package/dist/components/logo/logo-titan-text.module.less +12 -9
- package/dist/components/logo/logo-titan.d.ts +2 -2
- package/dist/components/logo/logo-titan.d.ts.map +1 -1
- 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 +2 -1
- package/dist/components/logo/logo.stories.d.ts.map +1 -1
- package/dist/components/logo/logo.stories.js +7 -5
- package/dist/components/logo/logo.stories.js.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown-stacked.stories.d.ts +15 -0
- package/dist/components/profile-dropdown/profile-dropdown-stacked.stories.d.ts.map +1 -0
- package/dist/components/profile-dropdown/profile-dropdown-stacked.stories.js +51 -0
- package/dist/components/profile-dropdown/profile-dropdown-stacked.stories.js.map +1 -0
- package/dist/components/profile-dropdown/profile-dropdown.d.ts +1 -0
- 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.module.less +0 -2
- package/dist/components/profile-dropdown/profile-dropdown.stories.js +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.stories.js.map +1 -1
- package/dist/components/profile-dropdown/profile-icon.d.ts +1 -1
- package/dist/components/profile-dropdown/profile-icon.d.ts.map +1 -1
- package/dist/components/profile-dropdown/profile-icon.js +1 -1
- package/dist/components/profile-dropdown/profile-icon.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/utils/with-tooltip.d.ts +3 -0
- package/dist/utils/with-tooltip.d.ts.map +1 -0
- package/dist/utils/with-tooltip.js +4 -0
- package/dist/utils/with-tooltip.js.map +1 -0
- package/package.json +2 -2
- package/src/components/header-navigation/header-navigation-content.tsx +118 -0
- package/src/components/header-navigation/header-navigation-extra.stories.tsx +12 -12
- package/src/components/header-navigation/header-navigation-links.tsx +143 -0
- package/src/components/header-navigation/header-navigation-stacked.stories.tsx +187 -0
- package/src/components/header-navigation/header-navigation-stories.module.less +6 -0
- package/src/components/header-navigation/header-navigation-stories.module.less.d.ts +3 -0
- package/src/components/header-navigation/header-navigation.module.less +171 -95
- package/src/components/header-navigation/header-navigation.module.less.d.ts +14 -9
- package/src/components/header-navigation/header-navigation.stories.tsx +25 -16
- package/src/components/header-navigation/header-navigation.tsx +151 -266
- package/src/components/header-navigation/index.ts +2 -0
- package/src/components/logo/logo-titan-text.module.less +12 -9
- package/src/components/logo/logo-titan-text.tsx +62 -20
- package/src/components/logo/logo-titan.tsx +2 -2
- package/src/components/logo/logo.stories.tsx +13 -4
- package/src/components/profile-dropdown/profile-dropdown-stacked.stories.tsx +178 -0
- package/src/components/profile-dropdown/profile-dropdown.module.less +0 -2
- package/src/components/profile-dropdown/profile-dropdown.stories.tsx +1 -1
- package/src/components/profile-dropdown/profile-dropdown.tsx +5 -3
- package/src/components/profile-dropdown/profile-icon.tsx +2 -1
- package/src/index.ts +2 -1
- package/src/utils/with-tooltip.tsx +11 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
|
|
3
|
-
export interface
|
|
3
|
+
export interface LogoTitanSvgProps {
|
|
4
4
|
height?: number;
|
|
5
5
|
width?: number;
|
|
6
6
|
fill?: string;
|
|
@@ -8,7 +8,7 @@ export interface LogoTitanProps {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
/* tslint:disable: max-line-length */
|
|
11
|
-
export const
|
|
11
|
+
export const LogoTitanSvg: FC<LogoTitanSvgProps> = props => {
|
|
12
12
|
const dimensions = {
|
|
13
13
|
width: props.width ?? 116,
|
|
14
14
|
height: props.height ?? 106,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { Stack, Tag } from '@servicetitan/design-system';
|
|
1
2
|
import { FC, ReactNode } from 'react';
|
|
2
3
|
import { LogoCompanyTitle } from './logo-company-title';
|
|
3
|
-
import {
|
|
4
|
-
import { LogoTitanText } from './logo-titan-text';
|
|
4
|
+
import { LogoTitanSvg } from './logo-titan';
|
|
5
|
+
import { LogoTitan, LogoTitanText, LogoTitanTitle } from './logo-titan-text';
|
|
5
6
|
|
|
6
7
|
export default {
|
|
7
8
|
title: 'Navigation/Logo',
|
|
@@ -9,8 +10,8 @@ export default {
|
|
|
9
10
|
parameters: {},
|
|
10
11
|
};
|
|
11
12
|
|
|
12
|
-
export const logoTitan = () => <
|
|
13
|
-
export const logoTitanBlueMantle = () => <
|
|
13
|
+
export const logoTitan = () => <LogoTitanSvg />;
|
|
14
|
+
export const logoTitanBlueMantle = () => <LogoTitanSvg mantleFill="#2270EE" />;
|
|
14
15
|
export const logoCompanyTitle = () => <LogoCompanyTitle />;
|
|
15
16
|
export const logoTitanText = () => (
|
|
16
17
|
<LogoTitanText
|
|
@@ -42,3 +43,11 @@ export const logoTitanTextWithLink = () => (
|
|
|
42
43
|
logoWrapper={NavLinkMock}
|
|
43
44
|
/>
|
|
44
45
|
);
|
|
46
|
+
|
|
47
|
+
export const logoTitanWithText = () => (
|
|
48
|
+
<Stack className="border bg-neutral-300" alignItems="center">
|
|
49
|
+
<LogoTitan className="border-left m-r-1" mantleFill="#2270EE" />
|
|
50
|
+
<LogoTitanTitle className="m-x-1 p-b-half c-white">Contact Center</LogoTitanTitle>
|
|
51
|
+
<Tag color="info">pro</Tag>
|
|
52
|
+
</Stack>
|
|
53
|
+
);
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { Button } from '@servicetitan/design-system';
|
|
2
|
+
import { FC } from 'react';
|
|
3
|
+
import { NavLinkComponentProps } from '../../utils/navigation';
|
|
4
|
+
import { HeaderNavigationStacked } from '../header-navigation';
|
|
5
|
+
import { ProfileDropdown } from './profile-dropdown';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: 'Navigation/ProfileDropdownStacked',
|
|
9
|
+
component: ProfileDropdown,
|
|
10
|
+
parameters: {},
|
|
11
|
+
};
|
|
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
|
+
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Button } from '@servicetitan/design-system';
|
|
2
2
|
import { FC } from 'react';
|
|
3
3
|
import { NavLinkComponentProps } from '../../utils/navigation';
|
|
4
|
-
import { HeaderNavigation } from '../header-navigation
|
|
4
|
+
import { HeaderNavigation } from '../header-navigation';
|
|
5
5
|
import { ProfileDropdown } from './profile-dropdown';
|
|
6
6
|
|
|
7
7
|
export default {
|
|
@@ -24,6 +24,7 @@ export interface ProfileDropdownTriggerProps {
|
|
|
24
24
|
avatarBadge?: boolean | string;
|
|
25
25
|
badge?: { content?: number | string; className: string };
|
|
26
26
|
hintArrow?: boolean;
|
|
27
|
+
size?: number;
|
|
27
28
|
onClick?(e: MouseEvent): void;
|
|
28
29
|
}
|
|
29
30
|
|
|
@@ -35,6 +36,7 @@ const ProfileDropdownTrigger: FC<ProfileDropdownTriggerProps> = ({
|
|
|
35
36
|
imageSrc,
|
|
36
37
|
info,
|
|
37
38
|
onClick,
|
|
39
|
+
size,
|
|
38
40
|
}) => {
|
|
39
41
|
const [avatarSource, setAvatarSource] = useState(imageSrc ?? '');
|
|
40
42
|
const [avatarSourceError, setAvatarSourceError] = useState(false);
|
|
@@ -69,12 +71,12 @@ const ProfileDropdownTrigger: FC<ProfileDropdownTriggerProps> = ({
|
|
|
69
71
|
{avatarSource && !avatarSourceError ? (
|
|
70
72
|
<img
|
|
71
73
|
src={avatarSource}
|
|
72
|
-
className={Styles.profileImage}
|
|
74
|
+
className={classNames(Styles.profileImage, 'profile-dropdown-image')}
|
|
73
75
|
onError={onAvatarError}
|
|
74
76
|
alt="user dropdown menu"
|
|
75
77
|
/>
|
|
76
78
|
) : (
|
|
77
|
-
<ProfileLogo size={
|
|
79
|
+
<ProfileLogo size={size} />
|
|
78
80
|
)}
|
|
79
81
|
|
|
80
82
|
{!!info && (
|
|
@@ -308,7 +310,7 @@ export const ProfileDropdown: ProfileDropdownType = (({
|
|
|
308
310
|
);
|
|
309
311
|
|
|
310
312
|
return (
|
|
311
|
-
<div className={
|
|
313
|
+
<div className={className} data-cy="profile-dropdown">
|
|
312
314
|
{!!hintPopup && hintShown && HintComponent ? (
|
|
313
315
|
<Popover
|
|
314
316
|
direction={direction ?? 'bl'}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
|
|
3
|
-
export const ProfileLogo: FC<{ size
|
|
3
|
+
export const ProfileLogo: FC<{ size?: number }> = ({ size }) => (
|
|
4
4
|
<svg
|
|
5
|
+
className="profile-dropdown-svg"
|
|
5
6
|
xmlns="http://www.w3.org/2000/svg"
|
|
6
7
|
version="1.1"
|
|
7
8
|
width={size}
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export * from './components/header-navigation
|
|
1
|
+
export * from './components/header-navigation';
|
|
2
2
|
export * from './components/profile-dropdown/profile-dropdown';
|
|
3
3
|
export * from './components/logo/logo-company-title';
|
|
4
4
|
export * from './components/logo/logo-titan';
|
|
5
5
|
export * from './components/logo/logo-titan-text';
|
|
6
6
|
export * from './components/counter-tag';
|
|
7
7
|
export * from './utils/navigation';
|
|
8
|
+
export * from './utils/with-tooltip';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Tooltip } from '@servicetitan/design-system';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
export const withTooltip = (element: ReactNode, tooltip?: string) =>
|
|
5
|
+
tooltip ? (
|
|
6
|
+
<Tooltip el="div" direction="b" text={tooltip}>
|
|
7
|
+
{element}
|
|
8
|
+
</Tooltip>
|
|
9
|
+
) : (
|
|
10
|
+
element
|
|
11
|
+
);
|