@servicetitan/navigation 11.0.0-canary.237.f2d512b.0 → 11.0.0-canary.237.f834dab.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/badge-tag.d.ts +1 -1
- package/dist/components/badge-tag.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.js +1 -1
- package/dist/components/header-navigation/header-navigation.stories.js.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/logo/logo-titan-text.d.ts +1 -1
- package/dist/components/logo/logo-titan-text.d.ts.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.d.ts +12 -7
- package/dist/components/profile-dropdown/profile-dropdown.d.ts.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.js +5 -4
- package/dist/components/profile-dropdown/profile-dropdown.js.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.module.less +3 -0
- package/dist/components/titan-layout/layout-context.js +1 -1
- package/dist/components/titan-layout/layout-context.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 +3 -4
- package/dist/components/titan-layout/layout-header.js.map +1 -1
- package/dist/components/titan-layout/layout-header.module.less +60 -21
- package/dist/components/titan-layout/layout-logo.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-logo.js +2 -1
- package/dist/components/titan-layout/layout-logo.js.map +1 -1
- package/dist/components/titan-layout/layout-profile.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-profile.js +37 -9
- package/dist/components/titan-layout/layout-profile.js.map +1 -1
- package/dist/components/titan-layout/layout-profile.stories.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-profile.stories.js +1 -1
- package/dist/components/titan-layout/layout-profile.stories.js.map +1 -1
- package/dist/components/titan-layout/layout-sidebar-links-internal.d.ts +2 -2
- package/dist/components/titan-layout/layout-sidebar-links-internal.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-sidebar-links-internal.js +4 -4
- 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 +12 -5
- package/dist/components/titan-layout/layout-sidebar-links.js.map +1 -1
- package/dist/components/titan-layout/layout-sidebar.d.ts +2 -0
- package/dist/components/titan-layout/layout-sidebar.d.ts.map +1 -1
- package/dist/components/titan-layout/layout-sidebar.js +6 -4
- package/dist/components/titan-layout/layout-sidebar.js.map +1 -1
- package/dist/components/titan-layout/layout-sidebar.module.less +29 -6
- package/dist/components/titan-layout/notifications-context.d.ts +13 -0
- package/dist/components/titan-layout/notifications-context.d.ts.map +1 -0
- package/dist/components/titan-layout/notifications-context.js +23 -0
- package/dist/components/titan-layout/notifications-context.js.map +1 -0
- package/dist/components/titan-layout/titan-layout.d.ts +10 -6
- package/dist/components/titan-layout/titan-layout.d.ts.map +1 -1
- package/dist/components/titan-layout/titan-layout.js +104 -21
- package/dist/components/titan-layout/titan-layout.js.map +1 -1
- package/dist/components/titan-layout/titan-layout.module.less +50 -20
- package/dist/components/titan-layout/titan-layout.stories.d.ts +15 -11
- package/dist/components/titan-layout/titan-layout.stories.d.ts.map +1 -1
- package/dist/components/titan-layout/titan-layout.stories.js +35 -14
- package/dist/components/titan-layout/titan-layout.stories.js.map +1 -1
- package/dist/test/data.d.ts +4 -1
- package/dist/test/data.d.ts.map +1 -1
- package/dist/test/data.js +2 -3
- package/dist/test/data.js.map +1 -1
- package/dist/utils/use-breakpoint.d.ts +1 -0
- package/dist/utils/use-breakpoint.d.ts.map +1 -1
- package/dist/utils/use-breakpoint.js +3 -2
- package/dist/utils/use-breakpoint.js.map +1 -1
- package/package.json +2 -2
- package/src/components/badge-tag.tsx +1 -1
- package/src/components/header-navigation/header-navigation-stacked.stories.tsx +1 -1
- package/src/components/header-navigation/header-navigation.stories.tsx +1 -1
- package/src/components/left-navigation/header-navigation-tiny.stories.tsx +2 -2
- package/src/components/logo/logo-titan-text.tsx +1 -1
- package/src/components/profile-dropdown/profile-dropdown.module.less +3 -0
- package/src/components/profile-dropdown/profile-dropdown.tsx +23 -6
- package/src/components/titan-layout/layout-context.tsx +1 -1
- package/src/components/titan-layout/layout-header.module.less +60 -21
- package/src/components/titan-layout/layout-header.module.less.d.ts +2 -0
- package/src/components/titan-layout/layout-header.tsx +12 -5
- package/src/components/titan-layout/layout-logo.tsx +13 -6
- package/src/components/titan-layout/layout-profile.stories.tsx +10 -1
- package/src/components/titan-layout/layout-profile.tsx +88 -26
- package/src/components/titan-layout/layout-sidebar-links-internal.tsx +18 -5
- package/src/components/titan-layout/layout-sidebar-links.tsx +21 -5
- package/src/components/titan-layout/layout-sidebar.module.less +29 -6
- package/src/components/titan-layout/layout-sidebar.module.less.d.ts +1 -0
- package/src/components/titan-layout/layout-sidebar.tsx +14 -5
- package/src/components/titan-layout/notifications-context.tsx +44 -0
- package/src/components/titan-layout/titan-layout.module.less +50 -20
- package/src/components/titan-layout/titan-layout.module.less.d.ts +3 -0
- package/src/components/titan-layout/titan-layout.stories.tsx +167 -19
- package/src/components/titan-layout/titan-layout.tsx +265 -76
- package/src/test/data.tsx +2 -3
- package/src/utils/use-breakpoint.ts +3 -1
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
InternalSideNavigationLink,
|
|
7
7
|
InternalSideNavigationTrigger,
|
|
8
8
|
} from './layout-sidebar-links-internal';
|
|
9
|
+
import { useNotificationsContext } from './notifications-context';
|
|
9
10
|
|
|
10
11
|
const WrappedLink: FC<{
|
|
11
12
|
children: ReactElement<any>;
|
|
@@ -17,7 +18,14 @@ const WrappedLink: FC<{
|
|
|
17
18
|
|
|
18
19
|
/** Side Navigation menu link */
|
|
19
20
|
export function TitanLayoutSidebarLink({ wrapper, ...props }: TitanLayoutSidebarLinkProps) {
|
|
20
|
-
const {
|
|
21
|
+
const {
|
|
22
|
+
NavigationComponent,
|
|
23
|
+
breakpoint: { isMobile },
|
|
24
|
+
} = useTitanLayoutContext();
|
|
25
|
+
const { onNotificationsUpdate } = useNotificationsContext();
|
|
26
|
+
const tag = getCounterTag(props.counter, props.tag);
|
|
27
|
+
|
|
28
|
+
onNotificationsUpdate(props.id, !!tag);
|
|
21
29
|
|
|
22
30
|
const element = (
|
|
23
31
|
<InternalSideNavigationLink
|
|
@@ -25,11 +33,11 @@ export function TitanLayoutSidebarLink({ wrapper, ...props }: TitanLayoutSidebar
|
|
|
25
33
|
navigationComponent={NavigationComponent}
|
|
26
34
|
submenuExpanded={undefined}
|
|
27
35
|
dataPrefix="navigation-link"
|
|
28
|
-
tag={
|
|
36
|
+
tag={tag}
|
|
29
37
|
/>
|
|
30
38
|
);
|
|
31
39
|
|
|
32
|
-
return wrapper ? <WrappedLink wrapper={wrapper}>{element}</WrappedLink> : element;
|
|
40
|
+
return wrapper && !isMobile ? <WrappedLink wrapper={wrapper}>{element}</WrappedLink> : element;
|
|
33
41
|
}
|
|
34
42
|
|
|
35
43
|
/** Side Navigation menu trigger */
|
|
@@ -42,15 +50,23 @@ export function TitanLayoutSidebarTrigger({
|
|
|
42
50
|
const {
|
|
43
51
|
breakpoint: { isMobile },
|
|
44
52
|
} = useTitanLayoutContext();
|
|
53
|
+
const { onNotificationsUpdate } = useNotificationsContext();
|
|
54
|
+
const tag = getCounterTag(props.counter, props.tag);
|
|
55
|
+
|
|
56
|
+
onNotificationsUpdate(props.id, !!tag);
|
|
45
57
|
|
|
46
58
|
const element = (
|
|
47
59
|
<InternalSideNavigationTrigger
|
|
48
60
|
{...props}
|
|
49
61
|
submenuExpanded={undefined}
|
|
50
62
|
dataPrefix="navigation-trigger"
|
|
51
|
-
tag={
|
|
63
|
+
tag={tag}
|
|
52
64
|
onClick={isMobile && !!onMobileClick ? onMobileClick : onClick}
|
|
53
65
|
/>
|
|
54
66
|
);
|
|
55
|
-
return wrapper && !isMobile
|
|
67
|
+
return wrapper && (!isMobile || !onMobileClick) ? (
|
|
68
|
+
<WrappedLink wrapper={wrapper}>{element}</WrappedLink>
|
|
69
|
+
) : (
|
|
70
|
+
element
|
|
71
|
+
);
|
|
56
72
|
}
|
|
@@ -17,15 +17,20 @@
|
|
|
17
17
|
|
|
18
18
|
// mobile version
|
|
19
19
|
.nav-drawer {
|
|
20
|
-
display: none;
|
|
20
|
+
// display: none;
|
|
21
21
|
position: fixed;
|
|
22
22
|
max-width: 400px;
|
|
23
23
|
width: 0;
|
|
24
|
+
height: 100vh;
|
|
24
25
|
top: 0;
|
|
25
|
-
|
|
26
|
-
left: 0;
|
|
26
|
+
left: -100vh;
|
|
27
27
|
z-index: 991;
|
|
28
28
|
|
|
29
|
+
-webkit-transition: width 200ms ease-in-out;
|
|
30
|
+
-moz-transition: width 200ms ease-in-out;
|
|
31
|
+
-o-transition: width 200ms ease-in-out;
|
|
32
|
+
transition: width 200ms ease-in-out;
|
|
33
|
+
|
|
29
34
|
.nav-main {
|
|
30
35
|
padding-left: @spacing-2;
|
|
31
36
|
padding-right: @spacing-2;
|
|
@@ -39,6 +44,7 @@
|
|
|
39
44
|
padding-top: @spacing-2;
|
|
40
45
|
padding-left: @spacing-2;
|
|
41
46
|
padding-right: @spacing-2;
|
|
47
|
+
cursor: pointer;
|
|
42
48
|
}
|
|
43
49
|
}
|
|
44
50
|
|
|
@@ -61,10 +67,21 @@
|
|
|
61
67
|
}
|
|
62
68
|
}
|
|
63
69
|
|
|
70
|
+
.nav-drawer-backdrop {
|
|
71
|
+
position: fixed;
|
|
72
|
+
height: 100vh;
|
|
73
|
+
width: 100vw;
|
|
74
|
+
top: 0;
|
|
75
|
+
left: 0;
|
|
76
|
+
z-index: 991;
|
|
77
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
78
|
+
}
|
|
79
|
+
|
|
64
80
|
// mobile version opened
|
|
65
81
|
.nav-drawer-opened {
|
|
66
82
|
display: flex;
|
|
67
83
|
width: 90vw;
|
|
84
|
+
left: 0;
|
|
68
85
|
}
|
|
69
86
|
|
|
70
87
|
@media only screen and (min-width: 361px) {
|
|
@@ -141,7 +158,11 @@
|
|
|
141
158
|
// desktop version expanded
|
|
142
159
|
.nav-wide {
|
|
143
160
|
width: var(--nav-offset-left);
|
|
144
|
-
|
|
161
|
+
|
|
162
|
+
.nav-item {
|
|
163
|
+
margin-left: @spacing-1;
|
|
164
|
+
margin-right: @spacing-1;
|
|
165
|
+
}
|
|
145
166
|
|
|
146
167
|
.toggle {
|
|
147
168
|
.toggle-content {
|
|
@@ -162,14 +183,16 @@
|
|
|
162
183
|
margin-top: @spacing-1;
|
|
163
184
|
margin-bottom: @spacing-1;
|
|
164
185
|
}
|
|
186
|
+
|
|
187
|
+
.nav-main {
|
|
188
|
+
padding-top: @spacing-1;
|
|
189
|
+
}
|
|
165
190
|
}
|
|
166
191
|
|
|
167
192
|
.nav-drawer,
|
|
168
193
|
.nav-wide {
|
|
169
194
|
.nav-item {
|
|
170
195
|
flex-direction: row;
|
|
171
|
-
margin-left: @spacing-1;
|
|
172
|
-
margin-right: @spacing-1;
|
|
173
196
|
|
|
174
197
|
.nav-item-icon-wrapper {
|
|
175
198
|
flex: 1;
|
|
@@ -5,6 +5,7 @@ export const navBottom: string;
|
|
|
5
5
|
export const navClose: string;
|
|
6
6
|
export const navCloseWrapper: string;
|
|
7
7
|
export const navDrawer: string;
|
|
8
|
+
export const navDrawerBackdrop: string;
|
|
8
9
|
export const navDrawerOpened: string;
|
|
9
10
|
export const navFooter: string;
|
|
10
11
|
export const navGroupItem: string;
|
|
@@ -33,9 +33,11 @@ export interface LayoutSidebarProps {
|
|
|
33
33
|
mainItems?: NavigationItemData[];
|
|
34
34
|
barExpanded: boolean;
|
|
35
35
|
submenuExpanded: string | undefined;
|
|
36
|
+
drawerOpened: boolean;
|
|
36
37
|
mobile: boolean;
|
|
37
38
|
navigationComponent: FC<NavLinkComponentProps>;
|
|
38
39
|
onBarExpandChange(expanded: boolean): void;
|
|
40
|
+
onDrawerOpenChange(expanded: boolean): void;
|
|
39
41
|
onSubmenuExpandChange(id: string, expanded: boolean): void;
|
|
40
42
|
}
|
|
41
43
|
|
|
@@ -44,29 +46,36 @@ export const LayoutSidebar: FC<LayoutSidebarProps> = ({
|
|
|
44
46
|
mobile,
|
|
45
47
|
barExpanded,
|
|
46
48
|
submenuExpanded,
|
|
49
|
+
drawerOpened,
|
|
47
50
|
onBarExpandChange,
|
|
48
51
|
onSubmenuExpandChange,
|
|
52
|
+
onDrawerOpenChange,
|
|
49
53
|
mainItems,
|
|
50
54
|
top,
|
|
51
55
|
bottom,
|
|
52
56
|
navigationComponent,
|
|
53
57
|
}) => {
|
|
54
|
-
const
|
|
55
|
-
|
|
58
|
+
const closeDrawer = () => {
|
|
59
|
+
if (mobile) {
|
|
60
|
+
onDrawerOpenChange?.(false);
|
|
61
|
+
}
|
|
56
62
|
};
|
|
57
63
|
|
|
58
64
|
return (
|
|
59
65
|
<LayoutPlacementContext.Provider value="side">
|
|
66
|
+
{mobile && drawerOpened && (
|
|
67
|
+
<div className={Styles.navDrawerBackdrop} onClick={closeDrawer} />
|
|
68
|
+
)}
|
|
60
69
|
<div
|
|
61
70
|
className={classNames(
|
|
62
71
|
Styles.nav,
|
|
63
72
|
mobile && Styles.navDrawer,
|
|
64
|
-
mobile &&
|
|
73
|
+
mobile && drawerOpened && Styles.navDrawerOpened,
|
|
65
74
|
!mobile && (barExpanded ? Styles.navWide : Styles.navSlim),
|
|
66
75
|
className
|
|
67
76
|
)}
|
|
68
77
|
data-cy="side-navigation"
|
|
69
|
-
onClick={
|
|
78
|
+
onClick={closeDrawer}
|
|
70
79
|
>
|
|
71
80
|
<ThemeProvider mode="dark" className={Styles.navMain}>
|
|
72
81
|
{mobile && (
|
|
@@ -86,7 +95,7 @@ export const LayoutSidebar: FC<LayoutSidebarProps> = ({
|
|
|
86
95
|
item.submenu ? (
|
|
87
96
|
<SideNavigationGroupItem
|
|
88
97
|
key={item.id}
|
|
89
|
-
barExpanded={barExpanded}
|
|
98
|
+
barExpanded={mobile ? drawerOpened : barExpanded}
|
|
90
99
|
submenuExpanded={!!item.id && submenuExpanded === item.id}
|
|
91
100
|
onSubmenuExpand={onSubmenuExpandChange}
|
|
92
101
|
navigationComponent={navigationComponent}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FC,
|
|
3
|
+
PropsWithChildren,
|
|
4
|
+
createContext,
|
|
5
|
+
useCallback,
|
|
6
|
+
useContext,
|
|
7
|
+
useRef,
|
|
8
|
+
useState,
|
|
9
|
+
} from 'react';
|
|
10
|
+
|
|
11
|
+
interface NotificationsContextType {
|
|
12
|
+
onNotificationsUpdate: (id: string, hasNotifications: boolean) => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const NotificationsContext = createContext<NotificationsContextType>({
|
|
16
|
+
onNotificationsUpdate: () => {},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export const useNotificationsContext = () => useContext(NotificationsContext);
|
|
20
|
+
|
|
21
|
+
export const useNotificationsState = () => {
|
|
22
|
+
const [hasNotifications, setHasNotifications] = useState(false);
|
|
23
|
+
const items = useRef(new Set<string>());
|
|
24
|
+
const onNotificationsUpdate = useCallback((id: string, hasNotifications: boolean) => {
|
|
25
|
+
if (hasNotifications && !items.current.has(id)) {
|
|
26
|
+
items.current.add(id);
|
|
27
|
+
setHasNotifications(!!items.current.size);
|
|
28
|
+
} else if (!hasNotifications && items.current.has(id)) {
|
|
29
|
+
items.current.delete(id);
|
|
30
|
+
setHasNotifications(!!items.current.size);
|
|
31
|
+
}
|
|
32
|
+
}, []);
|
|
33
|
+
|
|
34
|
+
const NotificationsContextProvider: FC<PropsWithChildren> = useCallback(
|
|
35
|
+
({ children }) => (
|
|
36
|
+
<NotificationsContext.Provider value={{ onNotificationsUpdate }}>
|
|
37
|
+
{children}
|
|
38
|
+
</NotificationsContext.Provider>
|
|
39
|
+
),
|
|
40
|
+
[onNotificationsUpdate]
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
return { NotificationsContextProvider, hasNotifications };
|
|
44
|
+
};
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
margin-top: var(--nav-offset-top);
|
|
14
14
|
|
|
15
15
|
display: flex;
|
|
16
|
-
flex-direction:
|
|
16
|
+
flex-direction: column;
|
|
17
17
|
|
|
18
18
|
.side {
|
|
19
19
|
flex-basis: var(--nav-offset-left);
|
|
@@ -30,47 +30,77 @@
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
.layout-legacy,
|
|
34
33
|
.layout-anvil2 {
|
|
34
|
+
.content-header {
|
|
35
|
+
position: sticky;
|
|
36
|
+
top: var(--nav-offset-top);
|
|
37
|
+
z-index: 989;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.layout-desktop {
|
|
35
42
|
padding-left: var(--nav-offset-left);
|
|
36
43
|
|
|
37
|
-
.
|
|
38
|
-
|
|
44
|
+
.side {
|
|
45
|
+
position: fixed;
|
|
46
|
+
top: var(--nav-offset-top);
|
|
47
|
+
bottom: 0;
|
|
48
|
+
left: 0;
|
|
49
|
+
right: 0;
|
|
50
|
+
z-index: @z-index-global-nav;
|
|
39
51
|
}
|
|
52
|
+
}
|
|
40
53
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
bottom: 0;
|
|
46
|
-
left: 0;
|
|
47
|
-
right: 0;
|
|
48
|
-
z-index: @z-index-global-nav;
|
|
49
|
-
}
|
|
54
|
+
.layout-legacy,
|
|
55
|
+
.layout-anvil2 {
|
|
56
|
+
.top-placeholder {
|
|
57
|
+
height: var(--nav-offset-top);
|
|
50
58
|
}
|
|
51
59
|
}
|
|
52
60
|
|
|
53
61
|
.layout {
|
|
54
|
-
--nav-offset-top:
|
|
62
|
+
--nav-offset-top: 0px;
|
|
63
|
+
--nav-offset-left: 0px;
|
|
64
|
+
|
|
65
|
+
&.layout-desktop.layout-top {
|
|
66
|
+
--nav-offset-top: 48px;
|
|
67
|
+
}
|
|
55
68
|
|
|
56
|
-
&.layout-mobile {
|
|
57
|
-
--nav-offset-top:
|
|
58
|
-
--nav-offset-left: 0;
|
|
69
|
+
&.layout-mobile.layout-top {
|
|
70
|
+
--nav-offset-top: 72px;
|
|
59
71
|
}
|
|
60
72
|
|
|
61
|
-
&.layout-nav-slim {
|
|
73
|
+
&.layout-desktop.layout-nav-slim {
|
|
62
74
|
--nav-offset-left: 64px;
|
|
63
75
|
}
|
|
64
76
|
|
|
65
|
-
&.layout-nav-wide {
|
|
77
|
+
&.layout-desktop.layout-nav-wide {
|
|
66
78
|
--nav-offset-left: 212px;
|
|
67
79
|
}
|
|
68
80
|
|
|
69
81
|
.top {
|
|
70
82
|
position: fixed;
|
|
83
|
+
width: 100vw;
|
|
71
84
|
top: 0;
|
|
72
85
|
left: 0;
|
|
73
|
-
right: 0;
|
|
74
86
|
z-index: 991;
|
|
75
87
|
}
|
|
88
|
+
|
|
89
|
+
.content-header {
|
|
90
|
+
position: sticky;
|
|
91
|
+
left: 0;
|
|
92
|
+
right: 0;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
@media print {
|
|
97
|
+
.layout {
|
|
98
|
+
--nav-offset-left: 0px !important;
|
|
99
|
+
--nav-offset-right: 0px !important;
|
|
100
|
+
|
|
101
|
+
.side,
|
|
102
|
+
.top {
|
|
103
|
+
display: none !important;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
76
106
|
}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
export const __esModule: true;
|
|
2
2
|
export const content: string;
|
|
3
|
+
export const contentHeader: string;
|
|
3
4
|
export const layout: string;
|
|
4
5
|
export const layoutAnvil1: string;
|
|
5
6
|
export const layoutAnvil2: string;
|
|
7
|
+
export const layoutDesktop: string;
|
|
6
8
|
export const layoutLegacy: string;
|
|
7
9
|
export const layoutMobile: string;
|
|
8
10
|
export const layoutNavSlim: string;
|
|
9
11
|
export const layoutNavWide: string;
|
|
12
|
+
export const layoutTop: string;
|
|
10
13
|
export const side: string;
|
|
11
14
|
export const top: string;
|
|
12
15
|
export const topPlaceholder: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Page as Anvil2Page, 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';
|
|
@@ -20,11 +20,32 @@ import { SideNavigationLinkWrapperProps } from '../left-navigation';
|
|
|
20
20
|
import { HeaderNavigationLink, HeaderNavigationTrigger } from '../links';
|
|
21
21
|
import { ProfileDropdown, TitanLayout, TitanLayoutProps, TitanLayoutState } from './';
|
|
22
22
|
|
|
23
|
+
interface LayoutContentArgs {
|
|
24
|
+
header: boolean;
|
|
25
|
+
sideTop: boolean;
|
|
26
|
+
extraText: boolean;
|
|
27
|
+
search: boolean;
|
|
28
|
+
longContent: boolean;
|
|
29
|
+
wideContent: boolean;
|
|
30
|
+
minWidth: boolean;
|
|
31
|
+
emptyNav: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
23
34
|
export default {
|
|
24
35
|
title: 'Navigation/TitanLayout',
|
|
25
|
-
component: TitanLayout,
|
|
26
36
|
decorators: [withDefaultRedirects, withMemoryRouter, withAnvil],
|
|
27
37
|
parameters: {},
|
|
38
|
+
argTypes: {},
|
|
39
|
+
args: {
|
|
40
|
+
header: true,
|
|
41
|
+
sideTop: true,
|
|
42
|
+
extraText: true,
|
|
43
|
+
search: true,
|
|
44
|
+
longContent: true,
|
|
45
|
+
wideContent: false,
|
|
46
|
+
minWidth: false,
|
|
47
|
+
emptyNav: false,
|
|
48
|
+
} as LayoutContentArgs,
|
|
28
49
|
};
|
|
29
50
|
|
|
30
51
|
const mainNavItems = [
|
|
@@ -51,6 +72,7 @@ const profile = (
|
|
|
51
72
|
to="https://google.com"
|
|
52
73
|
tooltip="Google it"
|
|
53
74
|
target="_blank"
|
|
75
|
+
tag={{ value: true }}
|
|
54
76
|
>
|
|
55
77
|
first link
|
|
56
78
|
</ProfileDropdown.Link>
|
|
@@ -58,6 +80,7 @@ const profile = (
|
|
|
58
80
|
id="second"
|
|
59
81
|
onClick={() => alert('second click')}
|
|
60
82
|
tooltip="Second hint"
|
|
83
|
+
counter
|
|
61
84
|
>
|
|
62
85
|
second link
|
|
63
86
|
</ProfileDropdown.Section>
|
|
@@ -131,9 +154,9 @@ const SideLinkPopoverWrapper: FC<SideNavigationLinkWrapperProps> = ({ children,
|
|
|
131
154
|
};
|
|
132
155
|
|
|
133
156
|
const sidebarTop = () => [
|
|
134
|
-
<TitanLayout.
|
|
135
|
-
<TitanLayout.
|
|
136
|
-
<TitanLayout.
|
|
157
|
+
<TitanLayout.Link key="tasks" {...items.tasks} />,
|
|
158
|
+
<TitanLayout.Link key="calls" {...items.calls} />,
|
|
159
|
+
<TitanLayout.Trigger
|
|
137
160
|
key="marketing"
|
|
138
161
|
{...items.marketing}
|
|
139
162
|
isActive={false}
|
|
@@ -142,51 +165,176 @@ const sidebarTop = () => [
|
|
|
142
165
|
counter={50}
|
|
143
166
|
/>,
|
|
144
167
|
];
|
|
145
|
-
const
|
|
168
|
+
const ContentHeader = () => {
|
|
169
|
+
const [longInfo, setLongInfo] = useState(false);
|
|
170
|
+
|
|
171
|
+
return (
|
|
172
|
+
<Fragment>
|
|
173
|
+
<Announcement title="Some info" status="info" />
|
|
174
|
+
<Announcement title="Some warning" status="warning" />
|
|
175
|
+
<div
|
|
176
|
+
className="d-f justify-content-center align-items-center bg-purple-100-i"
|
|
177
|
+
style={{ height: longInfo ? '120px' : '48px' }}
|
|
178
|
+
>
|
|
179
|
+
<div className="d-f align-items-center gap-1">
|
|
180
|
+
custom content{' '}
|
|
181
|
+
<Button onClick={() => setLongInfo(!longInfo)} size="small" aria-label="test">
|
|
182
|
+
{longInfo ? '↑' : '↓'}
|
|
183
|
+
</Button>
|
|
184
|
+
</div>
|
|
185
|
+
</div>
|
|
186
|
+
</Fragment>
|
|
187
|
+
);
|
|
188
|
+
};
|
|
189
|
+
const SearchBar = () => (
|
|
190
|
+
<TextField size="small" placeholder="Search" className="w-100-i m-x-half-i" />
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
const useLayoutProps = (args: LayoutContentArgs): TitanLayoutProps => {
|
|
146
194
|
const [state, setState] = useState<TitanLayoutState | undefined>(undefined);
|
|
147
195
|
|
|
148
196
|
return {
|
|
149
197
|
state,
|
|
150
198
|
onStateChange: setState,
|
|
151
199
|
|
|
152
|
-
|
|
200
|
+
navigationComponent: NavLinkMock,
|
|
201
|
+
navigationMainItems: args.emptyNav ? [] : mainNavItems,
|
|
202
|
+
|
|
153
203
|
profile,
|
|
204
|
+
top: args.search ? <SearchBar /> : undefined,
|
|
205
|
+
header: args.header ? <ContentHeader /> : undefined,
|
|
206
|
+
|
|
154
207
|
extraLinks,
|
|
155
208
|
extraLinksTop,
|
|
209
|
+
extraText: args.extraText ? 'EST (-8 hrs)' : undefined,
|
|
156
210
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
211
|
+
sideTop: args.sideTop && !args.emptyNav ? sidebarTop() : undefined,
|
|
212
|
+
|
|
213
|
+
minContentWidth: args.minWidth ? 900 : undefined,
|
|
160
214
|
};
|
|
161
215
|
};
|
|
162
216
|
|
|
163
|
-
|
|
164
|
-
|
|
217
|
+
const Content = (args: LayoutContentArgs) => {
|
|
218
|
+
return (
|
|
219
|
+
<Fragment>
|
|
220
|
+
<LocationInfo className="m-b-3" />
|
|
221
|
+
{args.wideContent && (
|
|
222
|
+
<div style={{ width: '1200px' }}>
|
|
223
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
|
|
224
|
+
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
|
|
225
|
+
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
|
226
|
+
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
|
|
227
|
+
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
|
|
228
|
+
culpa qui officia deserunt mollit anim id est laborum.
|
|
229
|
+
</div>
|
|
230
|
+
)}
|
|
231
|
+
|
|
232
|
+
{args.longContent && (
|
|
233
|
+
<div>
|
|
234
|
+
<p>Lorem</p>
|
|
235
|
+
<p>ipsum</p>
|
|
236
|
+
<p>dolor</p>
|
|
237
|
+
<p>sit</p>
|
|
238
|
+
<p>amet,</p>
|
|
239
|
+
<p>consectetur</p>
|
|
240
|
+
<p>adipiscing</p>
|
|
241
|
+
<p>elit,</p>
|
|
242
|
+
<p>sed</p>
|
|
243
|
+
<p>do</p>
|
|
244
|
+
<p>eiusmod</p>
|
|
245
|
+
<p>tempor</p>
|
|
246
|
+
<p>incididunt</p>
|
|
247
|
+
<p>ut</p>
|
|
248
|
+
<p>labore</p>
|
|
249
|
+
<p>et</p>
|
|
250
|
+
<p>dolore</p>
|
|
251
|
+
<p>magna</p>
|
|
252
|
+
<p>aliqua.</p>
|
|
253
|
+
<p>Ut</p>
|
|
254
|
+
<p>enim</p>
|
|
255
|
+
<p>ad</p>
|
|
256
|
+
<p>minim</p>
|
|
257
|
+
<p>veniam,</p>
|
|
258
|
+
<p>quis</p>
|
|
259
|
+
<p>nostrud</p>
|
|
260
|
+
<p>exercitation</p>
|
|
261
|
+
<p>ullamco</p>
|
|
262
|
+
<p>laboris</p>
|
|
263
|
+
<p>nisi</p>
|
|
264
|
+
<p>ut</p>
|
|
265
|
+
<p>aliquip</p>
|
|
266
|
+
<p>ex</p>
|
|
267
|
+
<p>ea</p>
|
|
268
|
+
<p>commodo</p>
|
|
269
|
+
<p>consequat.</p>
|
|
270
|
+
<p>Duis</p>
|
|
271
|
+
<p>aute</p>
|
|
272
|
+
<p>irure</p>
|
|
273
|
+
<p>dolor</p>
|
|
274
|
+
<p>in</p>
|
|
275
|
+
<p>reprehenderit</p>
|
|
276
|
+
<p>in</p>
|
|
277
|
+
<p>voluptate</p>
|
|
278
|
+
<p>velit</p>
|
|
279
|
+
<p>esse</p>
|
|
280
|
+
<p>cillum</p>
|
|
281
|
+
<p>dolore</p>
|
|
282
|
+
<p>eu</p>
|
|
283
|
+
<p>fugiat</p>
|
|
284
|
+
<p>nulla</p>
|
|
285
|
+
<p>pariatur.</p>
|
|
286
|
+
<p>Excepteur</p>
|
|
287
|
+
<p>sint</p>
|
|
288
|
+
<p>occaecat</p>
|
|
289
|
+
<p>cupidatat</p>
|
|
290
|
+
<p>non</p>
|
|
291
|
+
<p>proident,</p>
|
|
292
|
+
<p>sunt</p>
|
|
293
|
+
<p>in</p>
|
|
294
|
+
<p>culpa</p>
|
|
295
|
+
<p>qui</p>
|
|
296
|
+
<p>officia</p>
|
|
297
|
+
<p>deserunt</p>
|
|
298
|
+
<p>mollit</p>
|
|
299
|
+
<p>anim</p>
|
|
300
|
+
<p>id</p>
|
|
301
|
+
<p>est</p>
|
|
302
|
+
<p>laborum.</p>
|
|
303
|
+
</div>
|
|
304
|
+
)}
|
|
305
|
+
</Fragment>
|
|
306
|
+
);
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
export const TitanLayoutLegacy = (args: LayoutContentArgs) => (
|
|
310
|
+
<TitanLayout {...useLayoutProps(args)} appearance="legacy">
|
|
165
311
|
<TitanLayout.Logo title />
|
|
166
312
|
<TitanLayout.Content>
|
|
167
|
-
<
|
|
313
|
+
<div className="p-3">
|
|
314
|
+
<Content {...args} />
|
|
315
|
+
</div>
|
|
168
316
|
</TitanLayout.Content>
|
|
169
317
|
</TitanLayout>
|
|
170
318
|
);
|
|
171
319
|
|
|
172
|
-
export const TitanLayoutAnvil1 = () => (
|
|
173
|
-
<TitanLayout {...useLayoutProps()} appearance="anvil1">
|
|
320
|
+
export const TitanLayoutAnvil1 = (args: LayoutContentArgs) => (
|
|
321
|
+
<TitanLayout {...useLayoutProps(args)} appearance="anvil1">
|
|
174
322
|
<TitanLayout.Logo title />
|
|
175
323
|
<TitanLayout.Content>
|
|
176
324
|
<Anvil1Page>
|
|
177
|
-
<
|
|
325
|
+
<Content {...args} />
|
|
178
326
|
</Anvil1Page>
|
|
179
327
|
</TitanLayout.Content>
|
|
180
328
|
</TitanLayout>
|
|
181
329
|
);
|
|
182
330
|
|
|
183
|
-
export const TitanLayoutAnvil2 = () => (
|
|
184
|
-
<TitanLayout {...useLayoutProps()} appearance="anvil2">
|
|
331
|
+
export const TitanLayoutAnvil2 = (args: LayoutContentArgs) => (
|
|
332
|
+
<TitanLayout {...useLayoutProps(args)} appearance="anvil2">
|
|
185
333
|
<TitanLayout.Logo title />
|
|
186
334
|
<TitanLayout.Content>
|
|
187
335
|
<Anvil2Page>
|
|
188
336
|
<Anvil2Page.Content>
|
|
189
|
-
<
|
|
337
|
+
<Content {...args} />
|
|
190
338
|
</Anvil2Page.Content>
|
|
191
339
|
</Anvil2Page>
|
|
192
340
|
</TitanLayout.Content>
|