@servicetitan/navigation 10.7.0 → 11.0.0-canary.237.4d902dc.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-extra.stories.d.ts.map +1 -1
- package/dist/components/header-navigation/header-navigation-extra.stories.js +5 -5
- package/dist/components/header-navigation/header-navigation-extra.stories.js.map +1 -1
- package/dist/components/header-navigation/header-navigation-links.d.ts.map +1 -1
- package/dist/components/header-navigation/header-navigation-links.js +2 -2
- 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 +1 -1
- package/dist/components/header-navigation/header-navigation-stacked.stories.js.map +1 -1
- package/dist/components/header-navigation/header-navigation.stories.d.ts.map +1 -1
- package/dist/components/header-navigation/header-navigation.stories.js +2 -2
- package/dist/components/header-navigation/header-navigation.stories.js.map +1 -1
- package/dist/components/header-navigation/with-tooltip.d.ts +1 -1
- package/dist/components/header-navigation/with-tooltip.d.ts.map +1 -1
- package/dist/components/left-navigation/header-navigation-tiny.stories.d.ts.map +1 -1
- package/dist/components/left-navigation/header-navigation-tiny.stories.js +2 -2
- package/dist/components/left-navigation/header-navigation-tiny.stories.js.map +1 -1
- package/dist/components/links.d.ts.map +1 -1
- package/dist/components/links.js +7 -7
- package/dist/components/links.js.map +1 -1
- package/dist/components/logo/logo-company-title.d.ts +1 -0
- package/dist/components/logo/logo-company-title.d.ts.map +1 -1
- package/dist/components/logo/logo-company-title.js +2 -2
- package/dist/components/logo/logo-company-title.js.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.d.ts +6 -3
- package/dist/components/profile-dropdown/profile-dropdown.d.ts.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.js +7 -8
- package/dist/components/profile-dropdown/profile-dropdown.js.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.module.less +4 -0
- 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/components/titan-layout/index.d.ts +6 -0
- package/dist/components/titan-layout/index.d.ts.map +1 -0
- package/dist/components/titan-layout/index.js +6 -0
- package/dist/components/titan-layout/index.js.map +1 -0
- package/dist/components/titan-layout/interface-internal.d.ts +6 -0
- package/dist/components/titan-layout/interface-internal.d.ts.map +1 -0
- package/dist/components/titan-layout/interface-internal.js +2 -0
- package/dist/components/titan-layout/interface-internal.js.map +1 -0
- package/dist/components/titan-layout/interface.d.ts +21 -0
- package/dist/components/titan-layout/interface.d.ts.map +1 -0
- package/dist/components/titan-layout/interface.js +2 -0
- package/dist/components/titan-layout/interface.js.map +1 -0
- package/dist/components/titan-layout/layout-context.d.ts +20 -0
- package/dist/components/titan-layout/layout-context.d.ts.map +1 -0
- package/dist/components/titan-layout/layout-context.js +12 -0
- package/dist/components/titan-layout/layout-context.js.map +1 -0
- package/dist/components/titan-layout/layout-header-links.d.ts +7 -0
- package/dist/components/titan-layout/layout-header-links.d.ts.map +1 -0
- package/dist/components/titan-layout/layout-header-links.js +32 -0
- package/dist/components/titan-layout/layout-header-links.js.map +1 -0
- package/dist/components/titan-layout/layout-header.d.ts +20 -0
- package/dist/components/titan-layout/layout-header.d.ts.map +1 -0
- package/dist/components/titan-layout/layout-header.js +11 -0
- package/dist/components/titan-layout/layout-header.js.map +1 -0
- package/dist/components/titan-layout/layout-header.module.less +153 -0
- package/dist/components/titan-layout/layout-logo.d.ts +12 -0
- package/dist/components/titan-layout/layout-logo.d.ts.map +1 -0
- package/dist/components/titan-layout/layout-logo.js +15 -0
- package/dist/components/titan-layout/layout-logo.js.map +1 -0
- package/dist/components/titan-layout/layout-logo.stories.d.ts +13 -0
- package/dist/components/titan-layout/layout-logo.stories.d.ts.map +1 -0
- package/dist/components/titan-layout/layout-logo.stories.js +17 -0
- package/dist/components/titan-layout/layout-logo.stories.js.map +1 -0
- package/dist/components/titan-layout/layout-profile.d.ts +9 -0
- package/dist/components/titan-layout/layout-profile.d.ts.map +1 -0
- package/dist/components/titan-layout/layout-profile.js +44 -0
- package/dist/components/titan-layout/layout-profile.js.map +1 -0
- package/dist/components/titan-layout/layout-profile.stories.d.ts +13 -0
- package/dist/components/titan-layout/layout-profile.stories.d.ts.map +1 -0
- package/dist/components/titan-layout/layout-profile.stories.js +13 -0
- package/dist/components/titan-layout/layout-profile.stories.js.map +1 -0
- package/dist/components/titan-layout/layout-sidebar-links-internal.d.ts +46 -0
- package/dist/components/titan-layout/layout-sidebar-links-internal.d.ts.map +1 -0
- package/dist/components/titan-layout/layout-sidebar-links-internal.js +61 -0
- package/dist/components/titan-layout/layout-sidebar-links-internal.js.map +1 -0
- package/dist/components/titan-layout/layout-sidebar-links.d.ts +6 -0
- package/dist/components/titan-layout/layout-sidebar-links.d.ts.map +1 -0
- package/dist/components/titan-layout/layout-sidebar-links.js +21 -0
- package/dist/components/titan-layout/layout-sidebar-links.js.map +1 -0
- package/dist/components/titan-layout/layout-sidebar.d.ts +18 -0
- package/dist/components/titan-layout/layout-sidebar.d.ts.map +1 -0
- package/dist/components/titan-layout/layout-sidebar.js +65 -0
- package/dist/components/titan-layout/layout-sidebar.js.map +1 -0
- package/dist/components/titan-layout/layout-sidebar.module.less +528 -0
- package/dist/components/titan-layout/titan-layout.d.ts +36 -0
- package/dist/components/titan-layout/titan-layout.d.ts.map +1 -0
- package/dist/components/titan-layout/titan-layout.js +109 -0
- package/dist/components/titan-layout/titan-layout.js.map +1 -0
- package/dist/components/titan-layout/titan-layout.module.less +53 -0
- package/dist/components/titan-layout/titan-layout.stories.d.ts +18 -0
- package/dist/components/titan-layout/titan-layout.stories.d.ts.map +1 -0
- package/dist/components/titan-layout/titan-layout.stories.js +62 -0
- package/dist/components/titan-layout/titan-layout.stories.js.map +1 -0
- package/dist/components/titan-layout/with-tooltip.d.ts +4 -0
- package/dist/components/titan-layout/with-tooltip.d.ts.map +1 -0
- package/dist/components/titan-layout/with-tooltip.js +4 -0
- package/dist/components/titan-layout/with-tooltip.js.map +1 -0
- 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.d.ts.map +1 -1
- package/dist/test/data.js +3 -3
- package/dist/test/data.js.map +1 -1
- package/dist/utils/navigation-legacy.d.ts +3 -1
- package/dist/utils/navigation-legacy.d.ts.map +1 -1
- package/dist/utils/use-breakpoint.d.ts +7 -0
- package/dist/utils/use-breakpoint.d.ts.map +1 -0
- package/dist/utils/use-breakpoint.js +13 -0
- package/dist/utils/use-breakpoint.js.map +1 -0
- package/package.json +5 -6
- package/src/components/header-navigation/header-navigation-extra.stories.tsx +7 -0
- package/src/components/header-navigation/header-navigation-links.tsx +2 -0
- package/src/components/header-navigation/header-navigation-stacked.stories.tsx +4 -0
- package/src/components/header-navigation/header-navigation.stories.tsx +5 -0
- package/src/components/left-navigation/header-navigation-tiny.stories.tsx +6 -0
- package/src/components/left-navigation/side-navigation-links.tsx +1 -1
- package/src/components/links.tsx +33 -13
- package/src/components/logo/logo-company-title.tsx +8 -6
- package/src/components/profile-dropdown/profile-dropdown.module.less +4 -0
- package/src/components/profile-dropdown/profile-dropdown.stories.tsx +4 -4
- package/src/components/profile-dropdown/profile-dropdown.tsx +43 -46
- package/src/components/titan-layout/index.ts +5 -0
- package/src/components/titan-layout/interface-internal.ts +6 -0
- package/src/components/titan-layout/interface.ts +26 -0
- package/src/components/titan-layout/layout-context.tsx +30 -0
- package/src/components/titan-layout/layout-header-links.tsx +144 -0
- package/src/components/titan-layout/layout-header.module.less +153 -0
- package/src/components/titan-layout/layout-header.module.less.d.ts +16 -0
- package/src/components/titan-layout/layout-header.tsx +86 -0
- package/src/components/titan-layout/layout-logo.stories.tsx +31 -0
- package/src/components/titan-layout/layout-logo.tsx +57 -0
- package/src/components/titan-layout/layout-profile.stories.tsx +37 -0
- package/src/components/titan-layout/layout-profile.tsx +116 -0
- package/src/components/titan-layout/layout-sidebar-links-internal.tsx +265 -0
- package/src/components/titan-layout/layout-sidebar-links.tsx +56 -0
- package/src/components/titan-layout/layout-sidebar.module.less +528 -0
- package/src/components/titan-layout/layout-sidebar.module.less.d.ts +50 -0
- package/src/components/titan-layout/layout-sidebar.tsx +298 -0
- package/src/components/titan-layout/titan-layout.module.less +53 -0
- package/src/components/titan-layout/titan-layout.module.less.d.ts +11 -0
- package/src/components/titan-layout/titan-layout.stories.tsx +194 -0
- package/src/components/titan-layout/titan-layout.tsx +270 -0
- package/src/components/titan-layout/with-tooltip.tsx +16 -0
- package/src/index.ts +2 -1
- package/src/test/data.tsx +3 -2
- package/src/utils/navigation-legacy.ts +3 -1
- package/src/utils/use-breakpoint.ts +19 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import {
|
|
3
|
+
CSSProperties,
|
|
4
|
+
Children,
|
|
5
|
+
ComponentPropsWithoutRef,
|
|
6
|
+
FC,
|
|
7
|
+
Fragment,
|
|
8
|
+
ReactElement,
|
|
9
|
+
ReactNode,
|
|
10
|
+
isValidElement,
|
|
11
|
+
useCallback,
|
|
12
|
+
useEffect,
|
|
13
|
+
useMemo,
|
|
14
|
+
useState,
|
|
15
|
+
} from 'react';
|
|
16
|
+
import { NavigationItemData } from '../../utils/navigation';
|
|
17
|
+
import { DefaultNavLinkComponent, NavLinkComponentProps } from '../../utils/navigation-context';
|
|
18
|
+
import { useTitanBreakpoint } from '../../utils/use-breakpoint';
|
|
19
|
+
import { TitanLayoutState } from './interface';
|
|
20
|
+
import {
|
|
21
|
+
LayoutContext,
|
|
22
|
+
LayoutPlacementContext,
|
|
23
|
+
TitanLayoutContextType,
|
|
24
|
+
TitanLayoutSidebarContextType,
|
|
25
|
+
} from './layout-context';
|
|
26
|
+
import { LayoutHeader } from './layout-header';
|
|
27
|
+
import { TitanLayoutLogo, TitanLayoutLogoProps } from './layout-logo';
|
|
28
|
+
import { LayoutSidebar } from './layout-sidebar';
|
|
29
|
+
import { TitanLayoutSidebarLink, TitanLayoutSidebarTrigger } from './layout-sidebar-links';
|
|
30
|
+
import { InternalSideNavigationTrigger } from './layout-sidebar-links-internal';
|
|
31
|
+
import * as Styles from './titan-layout.module.less';
|
|
32
|
+
|
|
33
|
+
type TitanLayoutChild = ReactElement<TitanLayoutContentProps> | ReactElement<TitanLayoutLogoProps>;
|
|
34
|
+
|
|
35
|
+
export type TitanLayoutProps = Omit<ComponentPropsWithoutRef<'div'>, 'children' | 'style'> & {
|
|
36
|
+
empty?: boolean;
|
|
37
|
+
|
|
38
|
+
appearance?: 'legacy' | 'anvil1' | 'anvil2';
|
|
39
|
+
|
|
40
|
+
/** component used for navigation */
|
|
41
|
+
navigationComponent?: FC<NavLinkComponentProps>;
|
|
42
|
+
|
|
43
|
+
/** data for main navigation links */
|
|
44
|
+
navigationMainItems?: NavigationItemData[];
|
|
45
|
+
|
|
46
|
+
/** layout's content */
|
|
47
|
+
children?: TitanLayoutChild | TitanLayoutChild[];
|
|
48
|
+
|
|
49
|
+
state?: TitanLayoutState;
|
|
50
|
+
onStateChange?: (state: TitanLayoutState) => void;
|
|
51
|
+
|
|
52
|
+
header?: ReactElement;
|
|
53
|
+
profile?: ReactElement;
|
|
54
|
+
extraLinks?: ReactElement;
|
|
55
|
+
extraLinksTop?: ReactElement;
|
|
56
|
+
extraText?: string;
|
|
57
|
+
sidebarTop?: ReactElement[];
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const defaultSidebarContext: TitanLayoutSidebarContextType = {
|
|
61
|
+
styles: {
|
|
62
|
+
popoverContent: {
|
|
63
|
+
'--background-color-strong': '#24323C',
|
|
64
|
+
'color': 'var(--color-white)',
|
|
65
|
+
} as CSSProperties,
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const useVariant = (appearance: TitanLayoutProps['appearance']) =>
|
|
70
|
+
useMemo(() => {
|
|
71
|
+
const isLegacy = appearance === 'legacy';
|
|
72
|
+
const isAnvil1 = appearance === 'anvil1';
|
|
73
|
+
const isAnvil2 = appearance === 'anvil2';
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
isLegacy,
|
|
77
|
+
isAnvil1,
|
|
78
|
+
isAnvil2,
|
|
79
|
+
isSequent: isLegacy || isAnvil1,
|
|
80
|
+
};
|
|
81
|
+
}, [appearance]);
|
|
82
|
+
|
|
83
|
+
const useLayoutChildren = (children: TitanLayoutProps['children']) =>
|
|
84
|
+
useMemo(
|
|
85
|
+
() =>
|
|
86
|
+
Children.toArray(children).reduce(
|
|
87
|
+
(out, item) => {
|
|
88
|
+
if (
|
|
89
|
+
item &&
|
|
90
|
+
isValidElement(item) &&
|
|
91
|
+
item.type &&
|
|
92
|
+
typeof item.type !== 'string'
|
|
93
|
+
) {
|
|
94
|
+
if (item.type.name === TitanLayoutContent.name) {
|
|
95
|
+
out.content = item as any;
|
|
96
|
+
} else if (item.type.name === TitanLayoutLogo.name) {
|
|
97
|
+
out.logo = item as any;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return out;
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
logo: <TitanLayoutLogo />,
|
|
104
|
+
} as {
|
|
105
|
+
content?: ReactElement<TitanLayoutContentProps>;
|
|
106
|
+
logo: ReactElement<TitanLayoutLogoProps>;
|
|
107
|
+
}
|
|
108
|
+
),
|
|
109
|
+
[children]
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const TitanLayoutComponent: FC<TitanLayoutProps> = ({
|
|
113
|
+
appearance = 'anvil2',
|
|
114
|
+
id,
|
|
115
|
+
children,
|
|
116
|
+
navigationComponent,
|
|
117
|
+
header,
|
|
118
|
+
profile,
|
|
119
|
+
state,
|
|
120
|
+
onStateChange,
|
|
121
|
+
navigationMainItems,
|
|
122
|
+
extraLinks,
|
|
123
|
+
extraLinksTop,
|
|
124
|
+
extraText,
|
|
125
|
+
sidebarTop,
|
|
126
|
+
}) => {
|
|
127
|
+
const breakpoint = useTitanBreakpoint();
|
|
128
|
+
const isMobile = breakpoint.isMobile;
|
|
129
|
+
const context: TitanLayoutContextType = useMemo(
|
|
130
|
+
() => ({
|
|
131
|
+
NavigationComponent: navigationComponent ?? DefaultNavLinkComponent,
|
|
132
|
+
breakpoint,
|
|
133
|
+
isTitanLayout: true,
|
|
134
|
+
sidebar: defaultSidebarContext,
|
|
135
|
+
}),
|
|
136
|
+
[navigationComponent, breakpoint]
|
|
137
|
+
);
|
|
138
|
+
const variant = useVariant(appearance);
|
|
139
|
+
const [mobileDrawerOpened, setMobileDrawerOpened] = useState(false);
|
|
140
|
+
const { content, logo } = useLayoutChildren(children);
|
|
141
|
+
|
|
142
|
+
useEffect(() => {
|
|
143
|
+
if (!isMobile) {
|
|
144
|
+
setMobileDrawerOpened(false);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const listener = () => {
|
|
149
|
+
setMobileDrawerOpened(false);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
document.addEventListener('click', listener);
|
|
153
|
+
|
|
154
|
+
return () => document.removeEventListener('click', listener);
|
|
155
|
+
}, [isMobile]);
|
|
156
|
+
|
|
157
|
+
const onBurgerClick = useCallback((e: MouseEvent) => {
|
|
158
|
+
setMobileDrawerOpened(true);
|
|
159
|
+
e.stopPropagation();
|
|
160
|
+
}, []);
|
|
161
|
+
|
|
162
|
+
const onBarExpandChange = useCallback(
|
|
163
|
+
(expanded: boolean) => {
|
|
164
|
+
if (isMobile) {
|
|
165
|
+
setMobileDrawerOpened(false);
|
|
166
|
+
} else {
|
|
167
|
+
onStateChange?.({ navCollapsed: !expanded });
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
[onStateChange, isMobile]
|
|
171
|
+
);
|
|
172
|
+
const onSubmenuExpandChange = useCallback(
|
|
173
|
+
(id: string, expanded: boolean) => {
|
|
174
|
+
onStateChange?.({
|
|
175
|
+
navCollapsed: state?.navCollapsed ?? false,
|
|
176
|
+
submenuExpanded: expanded ? id : undefined,
|
|
177
|
+
});
|
|
178
|
+
},
|
|
179
|
+
[state, onStateChange]
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
const [layoutStyles] = useState<object>({});
|
|
183
|
+
|
|
184
|
+
const layoutClass = variant.isLegacy
|
|
185
|
+
? Styles.layoutLegacy
|
|
186
|
+
: variant.isAnvil1
|
|
187
|
+
? Styles.layoutAnvil1
|
|
188
|
+
: Styles.layoutAnvil2;
|
|
189
|
+
|
|
190
|
+
return (
|
|
191
|
+
<LayoutContext.Provider value={context}>
|
|
192
|
+
<LayoutPlacementContext.Provider value="unset">
|
|
193
|
+
<div
|
|
194
|
+
id={id}
|
|
195
|
+
className={classNames(
|
|
196
|
+
Styles.layout,
|
|
197
|
+
isMobile
|
|
198
|
+
? Styles.layoutMobile
|
|
199
|
+
: state?.navCollapsed
|
|
200
|
+
? Styles.layoutNavSlim
|
|
201
|
+
: Styles.layoutNavWide,
|
|
202
|
+
layoutClass
|
|
203
|
+
)}
|
|
204
|
+
style={layoutStyles}
|
|
205
|
+
>
|
|
206
|
+
{variant.isSequent && <div className={Styles.topPlaceholder} />}
|
|
207
|
+
<LayoutHeader
|
|
208
|
+
className={Styles.top}
|
|
209
|
+
logo={logo}
|
|
210
|
+
profile={isMobile ? undefined : profile}
|
|
211
|
+
center={header}
|
|
212
|
+
rightText={isMobile ? undefined : extraText}
|
|
213
|
+
right={
|
|
214
|
+
<Fragment>
|
|
215
|
+
{extraLinksTop}
|
|
216
|
+
{!isMobile && extraLinks}
|
|
217
|
+
</Fragment>
|
|
218
|
+
}
|
|
219
|
+
onBurgerClick={onBurgerClick}
|
|
220
|
+
/>
|
|
221
|
+
|
|
222
|
+
<LayoutSidebar
|
|
223
|
+
flex={!variant.isSequent}
|
|
224
|
+
mobile={breakpoint.isMobile}
|
|
225
|
+
barExpanded={isMobile ? mobileDrawerOpened : !state?.navCollapsed}
|
|
226
|
+
submenuExpanded={state?.submenuExpanded}
|
|
227
|
+
onBarExpandChange={onBarExpandChange}
|
|
228
|
+
onSubmenuExpandChange={onSubmenuExpandChange}
|
|
229
|
+
top={sidebarTop}
|
|
230
|
+
mainItems={navigationMainItems}
|
|
231
|
+
navigationComponent={context.NavigationComponent}
|
|
232
|
+
bottom={
|
|
233
|
+
isMobile ? (
|
|
234
|
+
<Fragment>
|
|
235
|
+
{profile}
|
|
236
|
+
{extraLinks}
|
|
237
|
+
{!!extraText && (
|
|
238
|
+
<InternalSideNavigationTrigger
|
|
239
|
+
id="__extra_text"
|
|
240
|
+
title={extraText}
|
|
241
|
+
submenuExpanded={undefined}
|
|
242
|
+
dataPrefix="navigation-extra-text"
|
|
243
|
+
tag={undefined}
|
|
244
|
+
icon={undefined}
|
|
245
|
+
iconActive={undefined}
|
|
246
|
+
/>
|
|
247
|
+
)}
|
|
248
|
+
</Fragment>
|
|
249
|
+
) : undefined
|
|
250
|
+
}
|
|
251
|
+
/>
|
|
252
|
+
|
|
253
|
+
{content}
|
|
254
|
+
</div>
|
|
255
|
+
</LayoutPlacementContext.Provider>
|
|
256
|
+
</LayoutContext.Provider>
|
|
257
|
+
);
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
export interface TitanLayoutContentProps {
|
|
261
|
+
children: ReactNode;
|
|
262
|
+
}
|
|
263
|
+
const TitanLayoutContent: FC<TitanLayoutContentProps> = ({ children }) => children;
|
|
264
|
+
|
|
265
|
+
export const TitanLayout = Object.assign(TitanLayoutComponent, {
|
|
266
|
+
Content: TitanLayoutContent,
|
|
267
|
+
Logo: TitanLayoutLogo,
|
|
268
|
+
SidebarLink: TitanLayoutSidebarLink,
|
|
269
|
+
SidebarTrigger: TitanLayoutSidebarTrigger,
|
|
270
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Tooltip, TooltipProps } from '@servicetitan/anvil2';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
|
+
|
|
4
|
+
export const withTooltip = (
|
|
5
|
+
element: ReactElement,
|
|
6
|
+
tooltip: string | undefined,
|
|
7
|
+
placement: TooltipProps['placement'] = 'bottom'
|
|
8
|
+
) =>
|
|
9
|
+
tooltip ? (
|
|
10
|
+
<Tooltip placement={placement}>
|
|
11
|
+
<Tooltip.Content>{tooltip}</Tooltip.Content>
|
|
12
|
+
<Tooltip.Trigger>{element}</Tooltip.Trigger>
|
|
13
|
+
</Tooltip>
|
|
14
|
+
) : (
|
|
15
|
+
element
|
|
16
|
+
);
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export * from './components/header-navigation';
|
|
2
|
-
export * from './components/profile-dropdown/profile-dropdown';
|
|
3
2
|
export * from './components/logo/logo-company-title';
|
|
4
3
|
export * from './components/logo/logo-titan';
|
|
5
4
|
export * from './components/logo/logo-titan-text';
|
|
6
5
|
export * from './components/counter-tag';
|
|
7
6
|
export * from './components/left-navigation';
|
|
7
|
+
export * from './components/titan-layout';
|
|
8
8
|
export * from './components/links';
|
|
9
9
|
export * from './utils/navigation';
|
|
10
10
|
export {
|
|
@@ -17,3 +17,4 @@ export {
|
|
|
17
17
|
NavigationActiveLinkMatcher,
|
|
18
18
|
} from './utils/navigation-context';
|
|
19
19
|
export * from './utils/navigation-legacy';
|
|
20
|
+
export * from './utils/use-breakpoint';
|
package/src/test/data.tsx
CHANGED
|
@@ -154,7 +154,7 @@ const getItem = (
|
|
|
154
154
|
hint: id,
|
|
155
155
|
icon: undefined,
|
|
156
156
|
iconActive: undefined,
|
|
157
|
-
...
|
|
157
|
+
...data,
|
|
158
158
|
submenu: data.submenu
|
|
159
159
|
? {
|
|
160
160
|
...data.submenu,
|
|
@@ -176,7 +176,7 @@ const getSubItem = (
|
|
|
176
176
|
id,
|
|
177
177
|
to: id,
|
|
178
178
|
title: id[0].toUpperCase() + id.substring(1),
|
|
179
|
-
...
|
|
179
|
+
...data,
|
|
180
180
|
});
|
|
181
181
|
|
|
182
182
|
const getGroup = (
|
|
@@ -339,6 +339,7 @@ export const CallsNavigationTrigger = () => {
|
|
|
339
339
|
id="dialpad"
|
|
340
340
|
iconName="phone"
|
|
341
341
|
counter={2}
|
|
342
|
+
title="Calls"
|
|
342
343
|
icon={SvgPhone}
|
|
343
344
|
iconActive={SvgPhoneActive}
|
|
344
345
|
onClick={() => setOpen(!open)}
|
|
@@ -54,6 +54,8 @@ export interface HeaderNavigationItemLinkProps {
|
|
|
54
54
|
export interface HeaderNavigationTriggerPropsStrict {
|
|
55
55
|
/** unique identifier */
|
|
56
56
|
id: string;
|
|
57
|
+
/** item title (used for mobile) */
|
|
58
|
+
title: string;
|
|
57
59
|
/** tooltip text */
|
|
58
60
|
tooltip?: string;
|
|
59
61
|
/** item description */
|
|
@@ -80,7 +82,7 @@ export interface HeaderNavigationTriggerPropsStrict {
|
|
|
80
82
|
/** svg icon (anvil2) of inactive item */
|
|
81
83
|
icon: IconProps['svg'] | undefined;
|
|
82
84
|
/** svg icon (anvil2) of active item */
|
|
83
|
-
iconActive
|
|
85
|
+
iconActive?: IconProps['svg'];
|
|
84
86
|
}
|
|
85
87
|
|
|
86
88
|
export interface HeaderNavigationTriggerProps extends HeaderNavigationTriggerPropsStrict {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BreakpointReturnProps, useBreakpoint } from '@servicetitan/anvil2';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
|
|
4
|
+
export interface TitanBreakpoint {
|
|
5
|
+
name: BreakpointReturnProps['name'];
|
|
6
|
+
isMobile: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const useTitanBreakpoint = (): TitanBreakpoint => {
|
|
10
|
+
const breakpoint = useBreakpoint();
|
|
11
|
+
|
|
12
|
+
return useMemo(
|
|
13
|
+
() => ({
|
|
14
|
+
name: breakpoint?.name ?? 'xl',
|
|
15
|
+
isMobile: breakpoint ? breakpoint.innerWidth <= 768 : false,
|
|
16
|
+
}),
|
|
17
|
+
[breakpoint]
|
|
18
|
+
);
|
|
19
|
+
};
|