@servicetitan/navigation 11.0.0-canary.237.64cfcfe.0 → 11.0.0-canary.237.8fa0e61.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.
Files changed (44) hide show
  1. package/dist/components/header-navigation/header-navigation-stacked.stories.js +1 -1
  2. package/dist/components/header-navigation/header-navigation-stacked.stories.js.map +1 -1
  3. package/dist/components/header-navigation/header-navigation.stories.js +1 -1
  4. package/dist/components/header-navigation/header-navigation.stories.js.map +1 -1
  5. package/dist/components/left-navigation/header-navigation-tiny.stories.js +2 -2
  6. package/dist/components/left-navigation/header-navigation-tiny.stories.js.map +1 -1
  7. package/dist/components/profile-dropdown/profile-dropdown.d.ts +10 -7
  8. package/dist/components/profile-dropdown/profile-dropdown.d.ts.map +1 -1
  9. package/dist/components/profile-dropdown/profile-dropdown.js +2 -2
  10. package/dist/components/profile-dropdown/profile-dropdown.js.map +1 -1
  11. package/dist/components/titan-layout/layout-header.module.less +22 -4
  12. package/dist/components/titan-layout/layout-profile.d.ts.map +1 -1
  13. package/dist/components/titan-layout/layout-profile.js +14 -4
  14. package/dist/components/titan-layout/layout-profile.js.map +1 -1
  15. package/dist/components/titan-layout/layout-profile.stories.d.ts.map +1 -1
  16. package/dist/components/titan-layout/layout-profile.stories.js +1 -1
  17. package/dist/components/titan-layout/layout-profile.stories.js.map +1 -1
  18. package/dist/components/titan-layout/layout-sidebar-links-internal.d.ts.map +1 -1
  19. package/dist/components/titan-layout/layout-sidebar-links-internal.js +2 -2
  20. package/dist/components/titan-layout/layout-sidebar-links-internal.js.map +1 -1
  21. package/dist/components/titan-layout/layout-sidebar.module.less +1 -1
  22. package/dist/components/titan-layout/titan-layout.d.ts +1 -0
  23. package/dist/components/titan-layout/titan-layout.d.ts.map +1 -1
  24. package/dist/components/titan-layout/titan-layout.js +16 -6
  25. package/dist/components/titan-layout/titan-layout.js.map +1 -1
  26. package/dist/components/titan-layout/titan-layout.module.less +34 -15
  27. package/dist/components/titan-layout/titan-layout.stories.d.ts +4 -0
  28. package/dist/components/titan-layout/titan-layout.stories.d.ts.map +1 -1
  29. package/dist/components/titan-layout/titan-layout.stories.js +14 -4
  30. package/dist/components/titan-layout/titan-layout.stories.js.map +1 -1
  31. package/package.json +2 -2
  32. package/src/components/header-navigation/header-navigation-stacked.stories.tsx +1 -1
  33. package/src/components/header-navigation/header-navigation.stories.tsx +1 -1
  34. package/src/components/left-navigation/header-navigation-tiny.stories.tsx +2 -2
  35. package/src/components/profile-dropdown/profile-dropdown.tsx +13 -6
  36. package/src/components/titan-layout/layout-header.module.less +22 -4
  37. package/src/components/titan-layout/layout-profile.stories.tsx +10 -1
  38. package/src/components/titan-layout/layout-profile.tsx +24 -8
  39. package/src/components/titan-layout/layout-sidebar-links-internal.tsx +12 -2
  40. package/src/components/titan-layout/layout-sidebar.module.less +1 -1
  41. package/src/components/titan-layout/titan-layout.module.less +34 -15
  42. package/src/components/titan-layout/titan-layout.module.less.d.ts +1 -1
  43. package/src/components/titan-layout/titan-layout.stories.tsx +111 -5
  44. package/src/components/titan-layout/titan-layout.tsx +45 -11
@@ -1,4 +1,4 @@
1
- import { Announcement, Page as Anvil2Page, Button, Popover } from '@servicetitan/anvil2';
1
+ import { Announcement, Page as Anvil2Page, Button, Popover, TextField } from '@servicetitan/anvil2';
2
2
  import SvgSearch from '@servicetitan/anvil2/assets/icons/material/round/search.svg';
3
3
  import SvgAtlas from '@servicetitan/anvil2/assets/icons/st/atlas_logo.svg';
4
4
  import SvgSettingsActive from '@servicetitan/anvil2/assets/icons/st/gnav_settings_active.svg';
@@ -24,6 +24,10 @@ interface LayoutContentArgs {
24
24
  header: boolean;
25
25
  sideTop: boolean;
26
26
  extraText: boolean;
27
+ search: boolean;
28
+ longContent: boolean;
29
+ wideContent: boolean;
30
+ minWidth: boolean;
27
31
  }
28
32
 
29
33
  export default {
@@ -35,6 +39,10 @@ export default {
35
39
  header: true,
36
40
  sideTop: true,
37
41
  extraText: true,
42
+ search: true,
43
+ longContent: true,
44
+ wideContent: false,
45
+ minWidth: false,
38
46
  } as LayoutContentArgs,
39
47
  };
40
48
 
@@ -174,6 +182,8 @@ const ContentHeader = () => {
174
182
  </Fragment>
175
183
  );
176
184
  };
185
+ const SearchBar = () => <TextField size="small" placeholder="Search" className="w-100-i" />;
186
+
177
187
  const useLayoutProps = (args: LayoutContentArgs): TitanLayoutProps => {
178
188
  const [state, setState] = useState<TitanLayoutState | undefined>(undefined);
179
189
 
@@ -185,7 +195,7 @@ const useLayoutProps = (args: LayoutContentArgs): TitanLayoutProps => {
185
195
  navigationMainItems: mainNavItems,
186
196
 
187
197
  profile,
188
-
198
+ top: args.search ? <SearchBar /> : undefined,
189
199
  header: args.header ? <ContentHeader /> : undefined,
190
200
 
191
201
  extraLinks,
@@ -193,14 +203,110 @@ const useLayoutProps = (args: LayoutContentArgs): TitanLayoutProps => {
193
203
  extraText: args.extraText ? 'EST (-8 hrs)' : undefined,
194
204
 
195
205
  sideTop: args.sideTop ? sidebarTop() : undefined,
206
+
207
+ minContentWidth: args.minWidth ? 900 : undefined,
196
208
  };
197
209
  };
198
210
 
211
+ const Content = (args: LayoutContentArgs) => {
212
+ return (
213
+ <Fragment>
214
+ <LocationInfo />
215
+ {args.wideContent && (
216
+ <div style={{ width: '1200px' }}>
217
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
218
+ incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
219
+ nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
220
+ Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
221
+ fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
222
+ culpa qui officia deserunt mollit anim id est laborum.
223
+ </div>
224
+ )}
225
+
226
+ {args.longContent && (
227
+ <div>
228
+ <p>Lorem</p>
229
+ <p>ipsum</p>
230
+ <p>dolor</p>
231
+ <p>sit</p>
232
+ <p>amet,</p>
233
+ <p>consectetur</p>
234
+ <p>adipiscing</p>
235
+ <p>elit,</p>
236
+ <p>sed</p>
237
+ <p>do</p>
238
+ <p>eiusmod</p>
239
+ <p>tempor</p>
240
+ <p>incididunt</p>
241
+ <p>ut</p>
242
+ <p>labore</p>
243
+ <p>et</p>
244
+ <p>dolore</p>
245
+ <p>magna</p>
246
+ <p>aliqua.</p>
247
+ <p>Ut</p>
248
+ <p>enim</p>
249
+ <p>ad</p>
250
+ <p>minim</p>
251
+ <p>veniam,</p>
252
+ <p>quis</p>
253
+ <p>nostrud</p>
254
+ <p>exercitation</p>
255
+ <p>ullamco</p>
256
+ <p>laboris</p>
257
+ <p>nisi</p>
258
+ <p>ut</p>
259
+ <p>aliquip</p>
260
+ <p>ex</p>
261
+ <p>ea</p>
262
+ <p>commodo</p>
263
+ <p>consequat.</p>
264
+ <p>Duis</p>
265
+ <p>aute</p>
266
+ <p>irure</p>
267
+ <p>dolor</p>
268
+ <p>in</p>
269
+ <p>reprehenderit</p>
270
+ <p>in</p>
271
+ <p>voluptate</p>
272
+ <p>velit</p>
273
+ <p>esse</p>
274
+ <p>cillum</p>
275
+ <p>dolore</p>
276
+ <p>eu</p>
277
+ <p>fugiat</p>
278
+ <p>nulla</p>
279
+ <p>pariatur.</p>
280
+ <p>Excepteur</p>
281
+ <p>sint</p>
282
+ <p>occaecat</p>
283
+ <p>cupidatat</p>
284
+ <p>non</p>
285
+ <p>proident,</p>
286
+ <p>sunt</p>
287
+ <p>in</p>
288
+ <p>culpa</p>
289
+ <p>qui</p>
290
+ <p>officia</p>
291
+ <p>deserunt</p>
292
+ <p>mollit</p>
293
+ <p>anim</p>
294
+ <p>id</p>
295
+ <p>est</p>
296
+ <p>laborum.</p>
297
+ </div>
298
+ )}
299
+ </Fragment>
300
+ );
301
+ };
302
+
199
303
  export const TitanLayoutLegacy = (args: LayoutContentArgs) => (
200
304
  <TitanLayout {...useLayoutProps(args)} appearance="legacy">
201
305
  <TitanLayout.Logo title />
202
306
  <TitanLayout.Content>
203
- <LocationInfo />
307
+ <div className="p-3">
308
+ <Content {...args} />
309
+ </div>
204
310
  </TitanLayout.Content>
205
311
  </TitanLayout>
206
312
  );
@@ -210,7 +316,7 @@ export const TitanLayoutAnvil1 = (args: LayoutContentArgs) => (
210
316
  <TitanLayout.Logo title />
211
317
  <TitanLayout.Content>
212
318
  <Anvil1Page>
213
- <LocationInfo />
319
+ <Content {...args} />
214
320
  </Anvil1Page>
215
321
  </TitanLayout.Content>
216
322
  </TitanLayout>
@@ -222,7 +328,7 @@ export const TitanLayoutAnvil2 = (args: LayoutContentArgs) => (
222
328
  <TitanLayout.Content>
223
329
  <Anvil2Page>
224
330
  <Anvil2Page.Content>
225
- <LocationInfo />
331
+ <Content {...args} />
226
332
  </Anvil2Page.Content>
227
333
  </Anvil2Page>
228
334
  </TitanLayout.Content>
@@ -57,6 +57,7 @@ export type TitanLayoutProps = Omit<ComponentPropsWithoutRef<'div'>, 'children'
57
57
  extraLinks?: ReactElement;
58
58
  extraLinksTop?: ReactElement;
59
59
  extraText?: string;
60
+ minContentWidth?: number;
60
61
  };
61
62
 
62
63
  const defaultSidebarContext: TitanLayoutSidebarContextType = {
@@ -125,6 +126,7 @@ const TitanLayoutComponent: FC<TitanLayoutProps> = ({
125
126
  extraLinks,
126
127
  extraLinksTop,
127
128
  extraText,
129
+ minContentWidth,
128
130
  sideTop,
129
131
  }) => {
130
132
  const breakpoint = useTitanBreakpoint();
@@ -157,6 +159,13 @@ const TitanLayoutComponent: FC<TitanLayoutProps> = ({
157
159
  return () => document.removeEventListener('click', listener);
158
160
  }, [isMobile]);
159
161
 
162
+ useEffect(() => {
163
+ if (variant.isAnvil1) {
164
+ document.body.classList.add('of-hidden-i');
165
+ return () => document.body.classList.remove('of-hidden');
166
+ }
167
+ }, [variant.isAnvil1]);
168
+
160
169
  const onBurgerClick = useCallback((e: MouseEvent) => {
161
170
  setMobileDrawerOpened(true);
162
171
  e.stopPropagation();
@@ -249,7 +258,12 @@ const TitanLayoutComponent: FC<TitanLayoutProps> = ({
249
258
  }
250
259
  />
251
260
 
252
- <LayoutContent header={header} anvil2={variant.isAnvil2}>
261
+ <LayoutContent
262
+ header={header}
263
+ anvil2={variant.isAnvil2}
264
+ anvil1={variant.isAnvil1}
265
+ minWidth={minContentWidth}
266
+ >
253
267
  {content}
254
268
  </LayoutContent>
255
269
  </div>
@@ -287,7 +301,7 @@ const TitanLayoutHeaderObserved: FC<{
287
301
  };
288
302
  }, [heightChange]);
289
303
  return (
290
- <div ref={ref} className={Styles.header}>
304
+ <div ref={ref} className={Styles.contentHeader} data-cy="layout-content-header">
291
305
  {children}
292
306
  </div>
293
307
  );
@@ -298,28 +312,48 @@ export interface TitanLayoutContentProps {
298
312
  }
299
313
  const TitanLayoutContent: FC<TitanLayoutContentProps> = ({ children }) => children;
300
314
 
301
- const LayoutContent: FC<{ children: ReactNode; header?: ReactNode; anvil2: boolean }> = ({
302
- anvil2,
303
- children,
304
- header,
305
- }) => {
315
+ const LayoutContent: FC<{
316
+ children: ReactNode;
317
+ header?: ReactNode;
318
+ anvil1: boolean;
319
+ anvil2: boolean;
320
+ minWidth: number | undefined;
321
+ }> = ({ anvil1, anvil2, children, header, minWidth }) => {
306
322
  const [anvil2Styles, setAnvil2Styles] = useState<object>({});
307
323
  const updateIndicatorsHeight = useCallback((offset: number) => {
308
324
  setAnvil2Styles({ '--offset': `calc(var(--nav-offset-top) + ${offset}px)` });
309
325
  }, []);
310
326
 
327
+ const contentStyles = useMemo(
328
+ () => ({
329
+ ...(minWidth ? { minWidth: `${minWidth}px` } : {}),
330
+ ...(anvil2 ? anvil2Styles : {}),
331
+ }),
332
+ [anvil2, minWidth, anvil2Styles]
333
+ );
334
+
311
335
  return (
312
- <div className={Styles.content} style={anvil2Styles}>
336
+ <Fragment>
313
337
  {!!header &&
314
338
  (anvil2 ? (
315
339
  <TitanLayoutHeaderObserved heightChange={updateIndicatorsHeight}>
316
340
  {header}
317
341
  </TitanLayoutHeaderObserved>
318
342
  ) : (
319
- header
343
+ <div className={Styles.contentHeader} data-cy="layout-content-header">
344
+ {header}
345
+ </div>
320
346
  ))}
321
- {children}
322
- </div>
347
+ <div className={Styles.content} style={contentStyles} data-cy="layout-content">
348
+ {anvil1 ? (
349
+ <div className="position-relative d-f flex-grow-1 flex-basis-0 of-hidden">
350
+ {children}
351
+ </div>
352
+ ) : (
353
+ children
354
+ )}
355
+ </div>
356
+ </Fragment>
323
357
  );
324
358
  };
325
359