@servicetitan/navigation 10.6.1 → 11.0.0-canary.237.0505ce7.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-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/left-navigation/interface.d.ts +1 -1
- package/dist/components/left-navigation/interface.d.ts.map +1 -1
- package/dist/components/left-navigation/side-navigation-links-internal.d.ts +3 -1
- package/dist/components/left-navigation/side-navigation-links-internal.d.ts.map +1 -1
- package/dist/components/left-navigation/side-navigation-links-internal.js +3 -3
- package/dist/components/left-navigation/side-navigation-links-internal.js.map +1 -1
- package/dist/components/left-navigation/side-navigation.d.ts.map +1 -1
- package/dist/components/left-navigation/side-navigation.js +8 -7
- package/dist/components/left-navigation/side-navigation.js.map +1 -1
- package/dist/components/left-navigation/side-navigation.module.less +21 -19
- 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/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 +17 -9
- package/dist/components/profile-dropdown/profile-dropdown.d.ts.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.js +11 -9
- package/dist/components/profile-dropdown/profile-dropdown.js.map +1 -1
- package/dist/components/profile-dropdown/profile-dropdown.module.less +24 -6
- 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 +22 -0
- package/dist/components/titan-layout/layout-header.d.ts.map +1 -0
- package/dist/components/titan-layout/layout-header.js +10 -0
- package/dist/components/titan-layout/layout-header.js.map +1 -0
- package/dist/components/titan-layout/layout-header.module.less +193 -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 +16 -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 +72 -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 +28 -0
- package/dist/components/titan-layout/layout-sidebar-links.js.map +1 -0
- package/dist/components/titan-layout/layout-sidebar.d.ts +19 -0
- package/dist/components/titan-layout/layout-sidebar.d.ts.map +1 -0
- package/dist/components/titan-layout/layout-sidebar.js +67 -0
- package/dist/components/titan-layout/layout-sidebar.js.map +1 -0
- package/dist/components/titan-layout/layout-sidebar.module.less +536 -0
- 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 +40 -0
- package/dist/components/titan-layout/titan-layout.d.ts.map +1 -0
- package/dist/components/titan-layout/titan-layout.js +192 -0
- package/dist/components/titan-layout/titan-layout.js.map +1 -0
- package/dist/components/titan-layout/titan-layout.module.less +106 -0
- package/dist/components/titan-layout/titan-layout.stories.d.ts +22 -0
- package/dist/components/titan-layout/titan-layout.stories.d.ts.map +1 -0
- package/dist/components/titan-layout/titan-layout.stories.js +83 -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 +4 -1
- package/dist/test/data.d.ts.map +1 -1
- package/dist/test/data.js +5 -6
- 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 +8 -0
- package/dist/utils/use-breakpoint.d.ts.map +1 -0
- package/dist/utils/use-breakpoint.js +14 -0
- package/dist/utils/use-breakpoint.js.map +1 -0
- package/package.json +5 -6
- package/src/components/badge-tag.tsx +1 -1
- 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 +5 -1
- package/src/components/header-navigation/header-navigation.stories.tsx +6 -1
- package/src/components/left-navigation/header-navigation-tiny.stories.tsx +8 -2
- package/src/components/left-navigation/interface.ts +2 -2
- package/src/components/left-navigation/side-navigation-links-internal.tsx +21 -6
- package/src/components/left-navigation/side-navigation-links.tsx +1 -1
- package/src/components/left-navigation/side-navigation.module.less +21 -19
- package/src/components/left-navigation/side-navigation.module.less.d.ts +2 -1
- package/src/components/left-navigation/side-navigation.tsx +15 -8
- package/src/components/links.tsx +33 -13
- package/src/components/logo/logo-company-title.tsx +8 -6
- package/src/components/logo/logo-titan-text.tsx +1 -1
- package/src/components/profile-dropdown/profile-dropdown.module.less +24 -6
- package/src/components/profile-dropdown/profile-dropdown.module.less.d.ts +2 -0
- package/src/components/profile-dropdown/profile-dropdown.stories.tsx +4 -4
- package/src/components/profile-dropdown/profile-dropdown.tsx +87 -55
- 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 +193 -0
- package/src/components/titan-layout/layout-header.module.less.d.ts +18 -0
- package/src/components/titan-layout/layout-header.tsx +97 -0
- package/src/components/titan-layout/layout-logo.stories.tsx +31 -0
- package/src/components/titan-layout/layout-logo.tsx +64 -0
- package/src/components/titan-layout/layout-profile.stories.tsx +46 -0
- package/src/components/titan-layout/layout-profile.tsx +178 -0
- package/src/components/titan-layout/layout-sidebar-links-internal.tsx +278 -0
- package/src/components/titan-layout/layout-sidebar-links.tsx +72 -0
- package/src/components/titan-layout/layout-sidebar.module.less +536 -0
- package/src/components/titan-layout/layout-sidebar.module.less.d.ts +49 -0
- package/src/components/titan-layout/layout-sidebar.tsx +304 -0
- package/src/components/titan-layout/notifications-context.tsx +44 -0
- package/src/components/titan-layout/titan-layout.module.less +106 -0
- package/src/components/titan-layout/titan-layout.module.less.d.ts +16 -0
- package/src/components/titan-layout/titan-layout.stories.tsx +342 -0
- package/src/components/titan-layout/titan-layout.tsx +461 -0
- package/src/components/titan-layout/with-tooltip.tsx +16 -0
- package/src/index.ts +2 -1
- package/src/test/data.tsx +5 -5
- package/src/utils/navigation-legacy.ts +3 -1
- package/src/utils/use-breakpoint.ts +21 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/* stylelint-disable no-descending-specificity */
|
|
2
|
+
@import (reference) '@servicetitan/tokens/core/tokens.less';
|
|
3
|
+
|
|
4
|
+
@size-links-tiny: 24px;
|
|
5
|
+
|
|
6
|
+
.header {
|
|
7
|
+
--nav-top-content-height: 32px;
|
|
8
|
+
display: flex;
|
|
9
|
+
justify-content: space-between;
|
|
10
|
+
|
|
11
|
+
background-color: @color-white;
|
|
12
|
+
color: @color-black;
|
|
13
|
+
box-sizing: border-box;
|
|
14
|
+
outline: 1px solid @color-neutral-60;
|
|
15
|
+
|
|
16
|
+
& > * {
|
|
17
|
+
overflow-y: hidden;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.he-top-left {
|
|
21
|
+
display: flex;
|
|
22
|
+
align-items: center;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.he-top-center {
|
|
26
|
+
overflow: hidden;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.he-top-right {
|
|
30
|
+
& > * {
|
|
31
|
+
color: @color-black;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.he-top-right-text {
|
|
35
|
+
font-size: @typescale-2;
|
|
36
|
+
font-weight: @font-weight-bold;
|
|
37
|
+
font-family: @base-font-family;
|
|
38
|
+
margin-right: @spacing-1;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
:global(.profile-dropdown-image) {
|
|
43
|
+
height: 24px;
|
|
44
|
+
width: 24px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
:global(.profile-dropdown-trigger) {
|
|
48
|
+
height: 32px;
|
|
49
|
+
font-size: @size-links-tiny;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.navigation-link {
|
|
53
|
+
border-radius: 12px;
|
|
54
|
+
font-size: @size-links-tiny;
|
|
55
|
+
color: inherit;
|
|
56
|
+
|
|
57
|
+
&.navigation-item-active:not(.navigation-item-overflow) {
|
|
58
|
+
background-color: @color-blue-100 !important;
|
|
59
|
+
color: @color-blue-500 !important;
|
|
60
|
+
}
|
|
61
|
+
&:hover:not(.navigation-item-active):not(.navigation-item-overflow) {
|
|
62
|
+
background-color: rgba(0, 0, 0, 0.12) !important;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
&.navigation-item-icon-state.navigation-item-active {
|
|
66
|
+
.navigation-icon:not(.navigation-icon-active) {
|
|
67
|
+
display: none;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.navigation-icon.navigation-icon-active[data-anv][data-anv] {
|
|
71
|
+
display: block;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.navigation-icon[data-anv][data-anv] {
|
|
77
|
+
display: inline-block;
|
|
78
|
+
color: inherit;
|
|
79
|
+
height: 24px;
|
|
80
|
+
width: 24px;
|
|
81
|
+
|
|
82
|
+
> svg {
|
|
83
|
+
height: @size-links-tiny;
|
|
84
|
+
width: @size-links-tiny;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
&.navigation-icon-active {
|
|
88
|
+
display: none;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.header-mobile {
|
|
94
|
+
padding: @spacing-2 @spacing-0;
|
|
95
|
+
height: var(--nav-offset-top);
|
|
96
|
+
|
|
97
|
+
--nav-top-content-height: 40px;
|
|
98
|
+
|
|
99
|
+
.navigation-link {
|
|
100
|
+
padding: 10px;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.he-top-center {
|
|
104
|
+
max-width: unset;
|
|
105
|
+
flex: 1;
|
|
106
|
+
margin-left: @spacing-3;
|
|
107
|
+
margin-right: @spacing-3;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.he-top-left {
|
|
111
|
+
margin-left: @spacing-half;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.he-top-right {
|
|
115
|
+
margin-right: @spacing-half;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// desktop
|
|
120
|
+
.header-desktop {
|
|
121
|
+
height: var(--nav-offset-top);
|
|
122
|
+
.navigation-link {
|
|
123
|
+
margin: 6px 2px;
|
|
124
|
+
padding: 6px 6px;
|
|
125
|
+
|
|
126
|
+
.navigation-item-counter {
|
|
127
|
+
min-width: 12px !important;
|
|
128
|
+
height: 12px !important;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.he-top-left {
|
|
133
|
+
padding-left: @spacing-1;
|
|
134
|
+
}
|
|
135
|
+
.he-top-center {
|
|
136
|
+
flex: 1;
|
|
137
|
+
margin-left: @spacing-2;
|
|
138
|
+
margin-right: @spacing-2;
|
|
139
|
+
max-width: 400px;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// desktop wide
|
|
144
|
+
@media only screen and (min-width: 1200px) {
|
|
145
|
+
.header-desktop {
|
|
146
|
+
display: grid;
|
|
147
|
+
grid-template-columns: repeat(3, 1fr);
|
|
148
|
+
grid-template-rows: 48px;
|
|
149
|
+
|
|
150
|
+
.he-top-left,
|
|
151
|
+
.he-top-center,
|
|
152
|
+
.he-top-right {
|
|
153
|
+
grid-column: span 1;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.he-top-center {
|
|
157
|
+
max-width: unset;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.navigation-link {
|
|
163
|
+
// styles specific to extra nav links
|
|
164
|
+
color: @color-black;
|
|
165
|
+
position: relative;
|
|
166
|
+
display: flex;
|
|
167
|
+
align-items: center;
|
|
168
|
+
flex-wrap: nowrap;
|
|
169
|
+
text-wrap: nowrap;
|
|
170
|
+
|
|
171
|
+
.navigation-item-counter {
|
|
172
|
+
color: @color-white;
|
|
173
|
+
font-weight: @font-weight-semibold;
|
|
174
|
+
font-size: 8px !important;
|
|
175
|
+
min-width: 16px !important;
|
|
176
|
+
height: 16px !important;
|
|
177
|
+
position: absolute;
|
|
178
|
+
top: 4px;
|
|
179
|
+
right: -2px;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.navigation-item-label {
|
|
183
|
+
color: inherit;
|
|
184
|
+
font-size: @typescale-1;
|
|
185
|
+
font-family: @base-font-family;
|
|
186
|
+
font-weight: @font-weight-semibold;
|
|
187
|
+
margin-left: @spacing-half;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
&.navigation-item-counter-long {
|
|
191
|
+
right: -8px;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const __esModule: true;
|
|
2
|
+
export const heTopCenter: string;
|
|
3
|
+
export const heTopLeft: string;
|
|
4
|
+
export const heTopRight: string;
|
|
5
|
+
export const heTopRightText: string;
|
|
6
|
+
export const header: string;
|
|
7
|
+
export const headerDesktop: string;
|
|
8
|
+
export const headerMobile: string;
|
|
9
|
+
export const navigationIcon: string;
|
|
10
|
+
export const navigationIconActive: string;
|
|
11
|
+
export const navigationItemActive: string;
|
|
12
|
+
export const navigationItemCounter: string;
|
|
13
|
+
export const navigationItemCounterLong: string;
|
|
14
|
+
export const navigationItemIconState: string;
|
|
15
|
+
export const navigationItemLabel: string;
|
|
16
|
+
export const navigationItemOverflow: string;
|
|
17
|
+
export const navigationLink: string;
|
|
18
|
+
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import SvgBurgerMenu from '@servicetitan/anvil2/assets/icons/material/round/menu.svg';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { ComponentPropsWithoutRef, FC, ReactElement, ReactNode } from 'react';
|
|
4
|
+
import { LayoutPlacementContext } from './layout-context';
|
|
5
|
+
import { LayoutHeaderNavigationTrigger } from './layout-header-links';
|
|
6
|
+
import * as Styles from './layout-header.module.less';
|
|
7
|
+
import { TitanLayoutLogoProps } from './layout-logo';
|
|
8
|
+
|
|
9
|
+
export interface TitanLayoutHeaderLogoProps {
|
|
10
|
+
title?: true | string;
|
|
11
|
+
mantleFill?: string;
|
|
12
|
+
to?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type LayoutHeaderProps = Omit<ComponentPropsWithoutRef<'div'>, 'children'> & {
|
|
16
|
+
right?: ReactNode;
|
|
17
|
+
rightText?: string;
|
|
18
|
+
rightClassName?: string;
|
|
19
|
+
|
|
20
|
+
id?: string;
|
|
21
|
+
|
|
22
|
+
center?: ReactElement;
|
|
23
|
+
centerClassName?: string;
|
|
24
|
+
|
|
25
|
+
logo: ReactElement<TitanLayoutLogoProps>;
|
|
26
|
+
profile?: ReactElement;
|
|
27
|
+
|
|
28
|
+
isMobile: boolean;
|
|
29
|
+
hasNotifications: boolean;
|
|
30
|
+
onBurgerClick?: (e: MouseEvent) => void;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const LayoutHeader: FC<LayoutHeaderProps> = ({
|
|
34
|
+
className,
|
|
35
|
+
right,
|
|
36
|
+
rightText,
|
|
37
|
+
rightClassName,
|
|
38
|
+
center,
|
|
39
|
+
centerClassName,
|
|
40
|
+
isMobile,
|
|
41
|
+
hasNotifications,
|
|
42
|
+
logo,
|
|
43
|
+
profile,
|
|
44
|
+
onBurgerClick,
|
|
45
|
+
...rest
|
|
46
|
+
}) => {
|
|
47
|
+
return (
|
|
48
|
+
<LayoutPlacementContext.Provider value="top">
|
|
49
|
+
<div
|
|
50
|
+
className={classNames(
|
|
51
|
+
Styles.header,
|
|
52
|
+
isMobile ? Styles.headerMobile : Styles.headerDesktop,
|
|
53
|
+
className
|
|
54
|
+
)}
|
|
55
|
+
{...rest}
|
|
56
|
+
data-cy="header-navigation"
|
|
57
|
+
>
|
|
58
|
+
<div className={classNames(Styles.heTopLeft)} data-cy="navigation-left">
|
|
59
|
+
{isMobile && (
|
|
60
|
+
<LayoutHeaderNavigationTrigger
|
|
61
|
+
id="burger"
|
|
62
|
+
title=""
|
|
63
|
+
icon={SvgBurgerMenu}
|
|
64
|
+
iconActive={SvgBurgerMenu}
|
|
65
|
+
className="m-r-1"
|
|
66
|
+
onClick={onBurgerClick}
|
|
67
|
+
tag={{ value: hasNotifications }}
|
|
68
|
+
/>
|
|
69
|
+
)}
|
|
70
|
+
{logo}
|
|
71
|
+
</div>
|
|
72
|
+
<div
|
|
73
|
+
className={classNames(
|
|
74
|
+
Styles.heTopCenter,
|
|
75
|
+
'd-f align-items-center justify-content-center',
|
|
76
|
+
centerClassName
|
|
77
|
+
)}
|
|
78
|
+
data-cy="navigation-center"
|
|
79
|
+
>
|
|
80
|
+
{center}
|
|
81
|
+
</div>
|
|
82
|
+
<div
|
|
83
|
+
className={classNames(
|
|
84
|
+
'd-f flex-row justify-content-end align-items-center',
|
|
85
|
+
Styles.heTopRight,
|
|
86
|
+
rightClassName
|
|
87
|
+
)}
|
|
88
|
+
data-cy="navigation-right"
|
|
89
|
+
>
|
|
90
|
+
{!!rightText && <div className={Styles.heTopRightText}>{rightText}</div>}
|
|
91
|
+
{right}
|
|
92
|
+
{profile}
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
</LayoutPlacementContext.Provider>
|
|
96
|
+
);
|
|
97
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Chip } from '@servicetitan/anvil2';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
|
+
import { withAnvil, withDefaultRedirects, withMemoryRouter } from '../../test/data';
|
|
4
|
+
import { TitanLayoutLogo, TitanLayoutLogoProps } from './layout-logo';
|
|
5
|
+
import { TitanLayout } from './titan-layout';
|
|
6
|
+
|
|
7
|
+
const withTitanLayout = (element: ReactElement<TitanLayoutLogoProps>) => () => (
|
|
8
|
+
<TitanLayout navigationMainItems={[]}>
|
|
9
|
+
{element}
|
|
10
|
+
<TitanLayout.Content>logo</TitanLayout.Content>
|
|
11
|
+
</TitanLayout>
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
export default {
|
|
15
|
+
title: 'Navigation/TitanLayoutLogo',
|
|
16
|
+
component: TitanLayoutLogo,
|
|
17
|
+
decorators: [withDefaultRedirects, withMemoryRouter, withAnvil],
|
|
18
|
+
parameters: {},
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const LogoDefault = withTitanLayout(<TitanLayoutLogo />);
|
|
22
|
+
|
|
23
|
+
export const LogoCompanyTitle = withTitanLayout(<TitanLayoutLogo title />);
|
|
24
|
+
|
|
25
|
+
export const LogoCommercial = withTitanLayout(
|
|
26
|
+
<TitanLayoutLogo title="Commercial" mantleFill="#2270EE" />
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
export const LogoWithPostfix = withTitanLayout(
|
|
30
|
+
<TitanLayoutLogo title postfix={<Chip className="m-l-2-i" label="demo" />} />
|
|
31
|
+
);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import { FC, Fragment, ReactNode } from 'react';
|
|
3
|
+
import { LogoCompanyTitle } from '../logo/logo-company-title';
|
|
4
|
+
import { LogoTitan, LogoTitanTitle, WrapperProps } from '../logo/logo-titan-text';
|
|
5
|
+
import { useTitanLayoutContext } from './layout-context';
|
|
6
|
+
|
|
7
|
+
export interface TitanLayoutLogoProps {
|
|
8
|
+
/** container class name */
|
|
9
|
+
className?: string;
|
|
10
|
+
|
|
11
|
+
title?: string | boolean;
|
|
12
|
+
|
|
13
|
+
postfix?: ReactNode;
|
|
14
|
+
|
|
15
|
+
logoWrapper?: WrapperProps;
|
|
16
|
+
|
|
17
|
+
mantleFill?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const EmptyWrapper: FC<any> = ({ children }) => children;
|
|
21
|
+
|
|
22
|
+
export const TitanLayoutLogo: FC<TitanLayoutLogoProps> = ({
|
|
23
|
+
className,
|
|
24
|
+
mantleFill,
|
|
25
|
+
postfix,
|
|
26
|
+
title,
|
|
27
|
+
logoWrapper = EmptyWrapper,
|
|
28
|
+
}) => {
|
|
29
|
+
const {
|
|
30
|
+
breakpoint: { isMobile },
|
|
31
|
+
} = useTitanLayoutContext();
|
|
32
|
+
|
|
33
|
+
const Wrapper = logoWrapper;
|
|
34
|
+
const logoSize = isMobile ? 44 : 56;
|
|
35
|
+
const logoCompanySize = 48;
|
|
36
|
+
const showCompanyTitle = title === true && !isMobile;
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<div
|
|
40
|
+
className={classNames(
|
|
41
|
+
'd-f align-items-center',
|
|
42
|
+
{ 'p-t-half': showCompanyTitle },
|
|
43
|
+
className
|
|
44
|
+
)}
|
|
45
|
+
>
|
|
46
|
+
{showCompanyTitle ? (
|
|
47
|
+
<Wrapper>
|
|
48
|
+
<LogoCompanyTitle height={logoCompanySize} />
|
|
49
|
+
</Wrapper>
|
|
50
|
+
) : typeof title === 'string' ? (
|
|
51
|
+
<Fragment>
|
|
52
|
+
<LogoTitan size={logoSize} mantleFill={mantleFill} logoWrapper={Wrapper} />
|
|
53
|
+
{!isMobile && (
|
|
54
|
+
<LogoTitanTitle className="c-inherit m-l-1">{title}</LogoTitanTitle>
|
|
55
|
+
)}
|
|
56
|
+
</Fragment>
|
|
57
|
+
) : (
|
|
58
|
+
<LogoTitan size={logoSize} mantleFill={mantleFill} logoWrapper={Wrapper} />
|
|
59
|
+
)}
|
|
60
|
+
|
|
61
|
+
{!isMobile && postfix}
|
|
62
|
+
</div>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { withAnvil, withDefaultRedirects, withMemoryRouter } from '../../test/data';
|
|
3
|
+
import { ProfileDropdown } from './layout-profile';
|
|
4
|
+
import { TitanLayout } from './titan-layout';
|
|
5
|
+
|
|
6
|
+
const withTitanLayout = (element: ReactElement) => () => (
|
|
7
|
+
<TitanLayout navigationMainItems={[]} profile={element}>
|
|
8
|
+
<TitanLayout.Content>profile</TitanLayout.Content>
|
|
9
|
+
</TitanLayout>
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
title: 'Navigation/TitanLayoutProfile',
|
|
14
|
+
component: ProfileDropdown,
|
|
15
|
+
decorators: [withDefaultRedirects, withMemoryRouter, withAnvil],
|
|
16
|
+
parameters: {},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const ProfileDefault = withTitanLayout(
|
|
20
|
+
<ProfileDropdown>
|
|
21
|
+
<ProfileDropdown.Link id="first" to="https://google.com" external>
|
|
22
|
+
first link
|
|
23
|
+
</ProfileDropdown.Link>
|
|
24
|
+
<ProfileDropdown.Section id="second" onClick={() => alert('second click')}>
|
|
25
|
+
second link
|
|
26
|
+
</ProfileDropdown.Section>
|
|
27
|
+
<ProfileDropdown.Divider />
|
|
28
|
+
<ProfileDropdown.Section id="content">some content</ProfileDropdown.Section>
|
|
29
|
+
<ProfileDropdown.Divider />
|
|
30
|
+
<ProfileDropdown.Divider />
|
|
31
|
+
<ProfileDropdown.Divider />
|
|
32
|
+
<ProfileDropdown.Link id="third" to="third">
|
|
33
|
+
third link
|
|
34
|
+
</ProfileDropdown.Link>
|
|
35
|
+
<ProfileDropdown.Divider />
|
|
36
|
+
<ProfileDropdown.Section
|
|
37
|
+
id="forth"
|
|
38
|
+
onClick={() => alert('forth click')}
|
|
39
|
+
text="Sign Out user"
|
|
40
|
+
>
|
|
41
|
+
Sign Out
|
|
42
|
+
<span className="c-neutral-60 m-l-1">user</span>
|
|
43
|
+
</ProfileDropdown.Section>
|
|
44
|
+
<ProfileDropdown.Divider />
|
|
45
|
+
</ProfileDropdown>
|
|
46
|
+
);
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import SvgAccountActive from '@servicetitan/anvil2/assets/icons/st/gnav_account_active.svg';
|
|
2
|
+
import SvgAccountInactive from '@servicetitan/anvil2/assets/icons/st/gnav_account_inactive.svg';
|
|
3
|
+
|
|
4
|
+
import { FC, MouseEvent, useEffect, useState } from 'react';
|
|
5
|
+
import { NavLinkComponentProps, NavigationComponentContext } from '../../utils/navigation-context';
|
|
6
|
+
import {
|
|
7
|
+
ProfileDropdown as DesktopProfileDropdown,
|
|
8
|
+
ProfileDropdownLinkProps,
|
|
9
|
+
ProfileDropdownProps,
|
|
10
|
+
ProfileDropdownSectionProps,
|
|
11
|
+
} from '../profile-dropdown/profile-dropdown';
|
|
12
|
+
import { NavigationComponentProps } from './interface-internal';
|
|
13
|
+
import { useTitanLayoutContext } from './layout-context';
|
|
14
|
+
import {
|
|
15
|
+
InternalSideNavigationGroup,
|
|
16
|
+
InternalSideNavigationGroupDivider,
|
|
17
|
+
InternalSideNavigationGroupLink,
|
|
18
|
+
InternalSideNavigationGroupTrigger,
|
|
19
|
+
} from './layout-sidebar-links-internal';
|
|
20
|
+
import { useNotificationsContext, useNotificationsState } from './notifications-context';
|
|
21
|
+
|
|
22
|
+
export type {
|
|
23
|
+
ProfileDropdownProps,
|
|
24
|
+
ProfileDropdownSectionProps,
|
|
25
|
+
ProfileDropdownLinkProps,
|
|
26
|
+
} from '../profile-dropdown/profile-dropdown';
|
|
27
|
+
|
|
28
|
+
const ExternalNavComponent: FC<NavLinkComponentProps> = ({
|
|
29
|
+
children,
|
|
30
|
+
isActive,
|
|
31
|
+
to,
|
|
32
|
+
activeClassName,
|
|
33
|
+
...props
|
|
34
|
+
}) => (
|
|
35
|
+
<a {...props} href={to}>
|
|
36
|
+
{children}
|
|
37
|
+
</a>
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
const ProfileDropdownContent: FC<ProfileDropdownProps> = props => {
|
|
41
|
+
const { breakpoint, NavigationComponent } = useTitanLayoutContext();
|
|
42
|
+
return breakpoint.isMobile ? (
|
|
43
|
+
<MobileProfileDropdown {...props} navigationComponent={NavigationComponent} />
|
|
44
|
+
) : (
|
|
45
|
+
<NavigationComponentContext.Provider value={NavigationComponent}>
|
|
46
|
+
<DesktopProfileDropdown {...props} />
|
|
47
|
+
</NavigationComponentContext.Provider>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
ProfileDropdownContent.displayName = 'ProfileDropdown';
|
|
51
|
+
|
|
52
|
+
const MobileProfileDropdown: FC<ProfileDropdownProps & NavigationComponentProps> = ({
|
|
53
|
+
children,
|
|
54
|
+
...props
|
|
55
|
+
}) => {
|
|
56
|
+
const id = '__profile';
|
|
57
|
+
const [expanded, setExpanded] = useState(false);
|
|
58
|
+
const { hasNotifications, NotificationsContextProvider } = useNotificationsState();
|
|
59
|
+
const { onNotificationsUpdate } = useNotificationsContext();
|
|
60
|
+
const onExpandToggle = (e: MouseEvent<never>) => {
|
|
61
|
+
e.stopPropagation();
|
|
62
|
+
setExpanded(!expanded);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
onNotificationsUpdate(id, hasNotifications);
|
|
67
|
+
}, [hasNotifications, onNotificationsUpdate]);
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<NotificationsContextProvider>
|
|
71
|
+
<InternalSideNavigationGroup
|
|
72
|
+
id={id}
|
|
73
|
+
to={undefined}
|
|
74
|
+
title="Profile"
|
|
75
|
+
icon={SvgAccountInactive}
|
|
76
|
+
iconActive={SvgAccountActive}
|
|
77
|
+
isActive={expanded}
|
|
78
|
+
{...props}
|
|
79
|
+
submenuExpanded={expanded}
|
|
80
|
+
onExpandToggle={onExpandToggle}
|
|
81
|
+
onClick={onExpandToggle}
|
|
82
|
+
tag={{ value: hasNotifications }}
|
|
83
|
+
>
|
|
84
|
+
{children}
|
|
85
|
+
</InternalSideNavigationGroup>
|
|
86
|
+
</NotificationsContextProvider>
|
|
87
|
+
);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const ProfileDropdownDivider: FC = () => {
|
|
91
|
+
const { breakpoint } = useTitanLayoutContext();
|
|
92
|
+
return breakpoint.isMobile ? (
|
|
93
|
+
<InternalSideNavigationGroupDivider />
|
|
94
|
+
) : (
|
|
95
|
+
<DesktopProfileDropdown.Divider />
|
|
96
|
+
);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const getText = (children: any, text: any): string | undefined => {
|
|
100
|
+
if (typeof children === 'string') {
|
|
101
|
+
return children;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (typeof text === 'string') {
|
|
105
|
+
return text;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return undefined;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const getTag = (
|
|
112
|
+
tag: ProfileDropdownLinkProps['tag'],
|
|
113
|
+
counter: ProfileDropdownLinkProps['counter']
|
|
114
|
+
): boolean => {
|
|
115
|
+
return !!tag?.value || !!counter;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const ProfileDropdownSection: FC<ProfileDropdownSectionProps> = props => {
|
|
119
|
+
const { breakpoint } = useTitanLayoutContext();
|
|
120
|
+
return breakpoint.isMobile ? (
|
|
121
|
+
<MobileProfileDropdownSection {...props} />
|
|
122
|
+
) : (
|
|
123
|
+
<DesktopProfileDropdown.Section {...props} />
|
|
124
|
+
);
|
|
125
|
+
};
|
|
126
|
+
const MobileProfileDropdownSection: FC<ProfileDropdownSectionProps> = ({
|
|
127
|
+
children,
|
|
128
|
+
text,
|
|
129
|
+
tooltip,
|
|
130
|
+
title,
|
|
131
|
+
...props
|
|
132
|
+
}) => {
|
|
133
|
+
const sectionText = getText(children, text);
|
|
134
|
+
const { onNotificationsUpdate } = useNotificationsContext();
|
|
135
|
+
onNotificationsUpdate(props.id, getTag(props.tag, props.counter));
|
|
136
|
+
|
|
137
|
+
return sectionText ? (
|
|
138
|
+
<InternalSideNavigationGroupTrigger {...props} title={sectionText} />
|
|
139
|
+
) : null;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const ProfileDropdownLink: FC<ProfileDropdownLinkProps> = props => {
|
|
143
|
+
const { breakpoint, NavigationComponent } = useTitanLayoutContext();
|
|
144
|
+
return breakpoint.isMobile ? (
|
|
145
|
+
<MobileProfileDropdownLink {...props} navigationComponent={NavigationComponent} />
|
|
146
|
+
) : (
|
|
147
|
+
<DesktopProfileDropdown.Link {...props} />
|
|
148
|
+
);
|
|
149
|
+
};
|
|
150
|
+
const MobileProfileDropdownLink: FC<ProfileDropdownLinkProps & NavigationComponentProps> = ({
|
|
151
|
+
external,
|
|
152
|
+
to,
|
|
153
|
+
tooltip,
|
|
154
|
+
text,
|
|
155
|
+
children,
|
|
156
|
+
navigationComponent,
|
|
157
|
+
...props
|
|
158
|
+
}) => {
|
|
159
|
+
const { onNotificationsUpdate } = useNotificationsContext();
|
|
160
|
+
const linkText = getText(children, text);
|
|
161
|
+
const isExternalLink = external ?? to?.startsWith('http');
|
|
162
|
+
onNotificationsUpdate(props.id, getTag(props.tag, props.counter));
|
|
163
|
+
|
|
164
|
+
return linkText ? (
|
|
165
|
+
<InternalSideNavigationGroupLink
|
|
166
|
+
{...props}
|
|
167
|
+
to={to}
|
|
168
|
+
title={linkText}
|
|
169
|
+
navigationComponent={isExternalLink ? ExternalNavComponent : navigationComponent}
|
|
170
|
+
/>
|
|
171
|
+
) : null;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
export const ProfileDropdown = Object.assign(ProfileDropdownContent, {
|
|
175
|
+
Divider: ProfileDropdownDivider,
|
|
176
|
+
Link: ProfileDropdownLink,
|
|
177
|
+
Section: ProfileDropdownSection,
|
|
178
|
+
});
|