@servicetitan/navigation 13.0.0-canary.256.5761ed1.0 → 13.0.0-canary.256.5bb5b0a.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/titan-layout/interface.d.ts +1 -1
- package/dist/components/titan-layout/interface.d.ts.map +1 -1
- package/dist/components/titan-layout/interface.js.map +1 -1
- package/dist/components/titan-layout/layout-header-dark.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-header-dark.js +3 -1
- package/dist/components/titan-layout/layout-header-dark.js.map +1 -1
- package/dist/components/titan-layout/layout-header.d.ts +2 -0
- package/dist/components/titan-layout/layout-header.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-header.js +18 -14
- package/dist/components/titan-layout/layout-header.js.map +1 -1
- package/dist/components/titan-layout/layout-sidebar-links-internal.d.ts +4 -10
- package/dist/components/titan-layout/layout-sidebar-links-internal.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-sidebar-links-internal.js +53 -53
- package/dist/components/titan-layout/layout-sidebar-links-internal.js.map +1 -1
- package/dist/components/titan-layout/layout-sidebar-links.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-sidebar-links.js +2 -4
- package/dist/components/titan-layout/layout-sidebar-links.js.map +1 -1
- package/dist/components/titan-layout/layout-sidebar.d.ts +1 -1
- package/dist/components/titan-layout/layout-sidebar.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-sidebar.js +43 -89
- package/dist/components/titan-layout/layout-sidebar.js.map +1 -1
- package/dist/components/titan-layout/layout-sidebar.module.less +74 -22
- package/dist/components/titan-layout/titan-layout-default.stories.d.ts.map +1 -1
- package/dist/components/titan-layout/titan-layout.d.ts.map +1 -1
- package/dist/components/titan-layout/titan-layout.js +25 -8
- package/dist/components/titan-layout/titan-layout.js.map +1 -1
- package/package.json +4 -4
- package/src/components/titan-layout/interface.ts +1 -1
- package/src/components/titan-layout/layout-header-dark.tsx +4 -1
- package/src/components/titan-layout/layout-header.tsx +22 -12
- package/src/components/titan-layout/layout-sidebar-links-internal.tsx +42 -54
- package/src/components/titan-layout/layout-sidebar-links.tsx +0 -2
- package/src/components/titan-layout/layout-sidebar.module.less +74 -22
- package/src/components/titan-layout/layout-sidebar.tsx +5 -50
- package/src/components/titan-layout/titan-layout-default.stories.tsx +9 -4
- package/src/components/titan-layout/titan-layout.tsx +29 -8
|
@@ -32,7 +32,7 @@ export interface LayoutSidebarProps {
|
|
|
32
32
|
bottom?: ReactElement;
|
|
33
33
|
mainItems?: NavigationItemData[];
|
|
34
34
|
barExpanded: boolean;
|
|
35
|
-
|
|
35
|
+
submenusExpanded: string[] | undefined;
|
|
36
36
|
drawerOpened: boolean;
|
|
37
37
|
mobile: boolean;
|
|
38
38
|
navigationComponent: FC<NavLinkComponentProps>;
|
|
@@ -45,7 +45,7 @@ export const LayoutSidebar: FC<LayoutSidebarProps> = ({
|
|
|
45
45
|
className,
|
|
46
46
|
mobile,
|
|
47
47
|
barExpanded,
|
|
48
|
-
|
|
48
|
+
submenusExpanded,
|
|
49
49
|
drawerOpened,
|
|
50
50
|
onBarExpandChange,
|
|
51
51
|
onSubmenuExpandChange,
|
|
@@ -97,7 +97,9 @@ export const LayoutSidebar: FC<LayoutSidebarProps> = ({
|
|
|
97
97
|
key={item.id}
|
|
98
98
|
item={item}
|
|
99
99
|
barExpanded={mobile ? drawerOpened : barExpanded}
|
|
100
|
-
submenuExpanded={
|
|
100
|
+
submenuExpanded={
|
|
101
|
+
!!item.id && !!submenusExpanded?.includes(item.id)
|
|
102
|
+
}
|
|
101
103
|
onSubmenuExpand={onSubmenuExpandChange}
|
|
102
104
|
navigationComponent={navigationComponent}
|
|
103
105
|
/>
|
|
@@ -115,7 +117,6 @@ export const LayoutSidebar: FC<LayoutSidebarProps> = ({
|
|
|
115
117
|
item.submenu,
|
|
116
118
|
getCounterTag(item.counter, item.tag)
|
|
117
119
|
)}
|
|
118
|
-
submenuExpanded={undefined}
|
|
119
120
|
navigationComponent={navigationComponent}
|
|
120
121
|
/>
|
|
121
122
|
)
|
|
@@ -124,57 +125,12 @@ export const LayoutSidebar: FC<LayoutSidebarProps> = ({
|
|
|
124
125
|
|
|
125
126
|
{!!bottom && <SidebarBottom>{bottom}</SidebarBottom>}
|
|
126
127
|
</ThemeProvider>
|
|
127
|
-
|
|
128
|
-
{!mobile && (
|
|
129
|
-
<div className={Styles.navFooter}>
|
|
130
|
-
<div className={Styles.divider} />
|
|
131
|
-
<div className={Styles.toggleWrapper}>
|
|
132
|
-
<SideNavigationOptionsToggle
|
|
133
|
-
appearance={barExpanded ? 'collapse-button' : 'expand'}
|
|
134
|
-
onExpandedChange={() => onBarExpandChange(!barExpanded)}
|
|
135
|
-
/>
|
|
136
|
-
</div>
|
|
137
|
-
</div>
|
|
138
|
-
)}
|
|
139
128
|
</div>
|
|
140
129
|
</LayoutPlacementContext.Provider>
|
|
141
130
|
);
|
|
142
131
|
};
|
|
143
132
|
LayoutSidebar.displayName = 'LayoutSidebar';
|
|
144
133
|
|
|
145
|
-
/** Side Navigation options toggle */
|
|
146
|
-
const SideNavigationOptionsToggle: FC<{
|
|
147
|
-
appearance: 'expand' | 'collapse' | 'collapse-button';
|
|
148
|
-
onExpandedChange?(expanded: boolean): void;
|
|
149
|
-
}> = ({ appearance, onExpandedChange }) =>
|
|
150
|
-
withTooltip(
|
|
151
|
-
<div
|
|
152
|
-
data-cy="navigation-left-options"
|
|
153
|
-
data-pendo="navigation-left-options"
|
|
154
|
-
className={classNames(Styles.toggle)}
|
|
155
|
-
onClick={() => onExpandedChange?.(appearance === 'expand')}
|
|
156
|
-
>
|
|
157
|
-
<div className={Styles.toggleContent}>
|
|
158
|
-
<div className={Styles.toggleIconWrapper}>
|
|
159
|
-
<Icon
|
|
160
|
-
className={Styles.toggleIcon}
|
|
161
|
-
svg={appearance === 'expand' ? SvgExpand : SvgCollapse}
|
|
162
|
-
/>
|
|
163
|
-
</div>
|
|
164
|
-
|
|
165
|
-
{appearance === 'collapse-button' && (
|
|
166
|
-
<span className={Styles.toggleText}>Collapse Menu</span>
|
|
167
|
-
)}
|
|
168
|
-
</div>
|
|
169
|
-
</div>,
|
|
170
|
-
appearance === 'expand'
|
|
171
|
-
? 'Expand Menu'
|
|
172
|
-
: appearance === 'collapse'
|
|
173
|
-
? 'Collapse Menu'
|
|
174
|
-
: undefined,
|
|
175
|
-
{ placement: 'right' }
|
|
176
|
-
);
|
|
177
|
-
|
|
178
134
|
/** Side Navigation menu item */
|
|
179
135
|
const SideNavigationGroupItem: FC<{
|
|
180
136
|
item: NavigationItemData;
|
|
@@ -236,7 +192,6 @@ const SideNavigationGroupItem: FC<{
|
|
|
236
192
|
iconActive={item.iconActive}
|
|
237
193
|
className={item.className}
|
|
238
194
|
tag={tag}
|
|
239
|
-
submenuExpanded={undefined}
|
|
240
195
|
navigationComponent={navigationComponent}
|
|
241
196
|
/>
|
|
242
197
|
</div>
|
|
@@ -6,7 +6,7 @@ import SvgSettings from '@servicetitan/anvil2/assets/icons/st/gnav_settings_inac
|
|
|
6
6
|
import SvgRocketActive from '@servicetitan/anvil2/assets/icons/st/gnav_titan_advisor_active.svg';
|
|
7
7
|
import SvgRocket from '@servicetitan/anvil2/assets/icons/st/gnav_titan_advisor_inactive.svg';
|
|
8
8
|
import { Page as Anvil1Page } from '@servicetitan/design-system';
|
|
9
|
-
import { Fragment, useState } from 'react';
|
|
9
|
+
import { Fragment, useEffect, useState } from 'react';
|
|
10
10
|
import {
|
|
11
11
|
CallsNavigationTrigger,
|
|
12
12
|
LocationInfo,
|
|
@@ -51,8 +51,8 @@ const mainNavItems = [
|
|
|
51
51
|
navItems.dispatch,
|
|
52
52
|
|
|
53
53
|
navItems.fleet,
|
|
54
|
-
navItems.
|
|
55
|
-
navItems.
|
|
54
|
+
navItems.followUpsWithSubmenu,
|
|
55
|
+
navItems.purchasingWithSubmenu,
|
|
56
56
|
|
|
57
57
|
navItems.marketing,
|
|
58
58
|
navItems.priceBook,
|
|
@@ -224,10 +224,15 @@ const useLayoutProps = (args: LayoutContentArgs): TitanLayoutProps => {
|
|
|
224
224
|
};
|
|
225
225
|
|
|
226
226
|
const Content = (args: LayoutContentArgs) => {
|
|
227
|
+
const [info, setInfo] = useState('');
|
|
228
|
+
useEffect(() => {
|
|
229
|
+
setInfo(new Date().toLocaleTimeString());
|
|
230
|
+
}, []);
|
|
227
231
|
return (
|
|
228
232
|
<Fragment>
|
|
229
233
|
<LocationInfo className="m-b-3" />
|
|
230
|
-
<div className="m-b-3">rendered - {
|
|
234
|
+
<div className="m-b-3">component rendered - {info}</div>
|
|
235
|
+
<div className="m-b-3">rerendered - {new Date().toLocaleTimeString()}</div>
|
|
231
236
|
{args.wideContent && (
|
|
232
237
|
<div style={{ width: '1200px' }}>
|
|
233
238
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
|
|
@@ -149,10 +149,18 @@ function TitanLayoutComponent({
|
|
|
149
149
|
}
|
|
150
150
|
}, [view.isAnvil1]);
|
|
151
151
|
|
|
152
|
-
const onBurgerClick = useCallback(
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
152
|
+
const onBurgerClick = useCallback(
|
|
153
|
+
(e: MouseEvent<never>) => {
|
|
154
|
+
if (isMobile) {
|
|
155
|
+
setMobileDrawerOpened(true);
|
|
156
|
+
} else {
|
|
157
|
+
onStateChange?.({ navCollapsed: !state?.navCollapsed });
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
e.stopPropagation();
|
|
161
|
+
},
|
|
162
|
+
[isMobile, state?.navCollapsed, onStateChange]
|
|
163
|
+
);
|
|
156
164
|
|
|
157
165
|
const onBarExpandChange = useCallback(
|
|
158
166
|
(expanded: boolean) => {
|
|
@@ -168,7 +176,10 @@ function TitanLayoutComponent({
|
|
|
168
176
|
(id: string, expanded: boolean) => {
|
|
169
177
|
onStateChange?.({
|
|
170
178
|
navCollapsed: state?.navCollapsed ?? false,
|
|
171
|
-
|
|
179
|
+
submenusExpanded: [
|
|
180
|
+
...(state?.submenusExpanded ?? []).filter(i => i !== id),
|
|
181
|
+
...(expanded ? [id] : []),
|
|
182
|
+
],
|
|
172
183
|
});
|
|
173
184
|
},
|
|
174
185
|
[state, onStateChange]
|
|
@@ -272,7 +283,17 @@ function TitanLayoutComponent({
|
|
|
272
283
|
</Fragment>
|
|
273
284
|
}
|
|
274
285
|
isMobile={isMobile}
|
|
275
|
-
hasNotifications={
|
|
286
|
+
hasNotifications={
|
|
287
|
+
isMobile && (hasNotifications || hasMenuNotifications)
|
|
288
|
+
}
|
|
289
|
+
hasBurger={hasSideBar}
|
|
290
|
+
burgerTooltip={
|
|
291
|
+
isMobile
|
|
292
|
+
? undefined
|
|
293
|
+
: state?.navCollapsed
|
|
294
|
+
? 'Expand'
|
|
295
|
+
: 'Collapse'
|
|
296
|
+
}
|
|
276
297
|
onBurgerClick={onBurgerClick}
|
|
277
298
|
/>
|
|
278
299
|
) : (
|
|
@@ -291,6 +312,7 @@ function TitanLayoutComponent({
|
|
|
291
312
|
isMobile={isMobile}
|
|
292
313
|
hasNotifications={hasNotifications || hasMenuNotifications}
|
|
293
314
|
onBurgerClick={onBurgerClick}
|
|
315
|
+
hasBurger={isMobile}
|
|
294
316
|
navigationMainItems={navigationMainItems}
|
|
295
317
|
navigationOverflowItems={navigationOverflowItems}
|
|
296
318
|
/>
|
|
@@ -303,7 +325,7 @@ function TitanLayoutComponent({
|
|
|
303
325
|
mobile={breakpoint.isMobile}
|
|
304
326
|
barExpanded={!state?.navCollapsed}
|
|
305
327
|
onBarExpandChange={onBarExpandChange}
|
|
306
|
-
|
|
328
|
+
submenusExpanded={state?.submenusExpanded}
|
|
307
329
|
onSubmenuExpandChange={onSubmenuExpandChange}
|
|
308
330
|
drawerOpened={mobileDrawerOpened}
|
|
309
331
|
onDrawerOpenChange={setMobileDrawerOpened}
|
|
@@ -324,7 +346,6 @@ function TitanLayoutComponent({
|
|
|
324
346
|
iconActive={undefined}
|
|
325
347
|
tag={undefined}
|
|
326
348
|
className={undefined}
|
|
327
|
-
submenuExpanded={undefined}
|
|
328
349
|
/>
|
|
329
350
|
)}
|
|
330
351
|
</Fragment>
|