-
Notifications
You must be signed in to change notification settings - Fork 280
Expand file tree
/
Copy pathShellBarTemplate.tsx
More file actions
259 lines (234 loc) · 8.7 KB
/
ShellBarTemplate.tsx
File metadata and controls
259 lines (234 loc) · 8.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
import Button from "@ui5/webcomponents/dist/Button.js";
import ButtonBadge from "@ui5/webcomponents/dist/ButtonBadge.js";
import Popover from "@ui5/webcomponents/dist/Popover.js";
import List from "@ui5/webcomponents/dist/List.js";
import type ShellBar from "./ShellBar.js";
import ShellBarItem from "./ShellBarItem.js";
import {
ShellBarSearchField,
ShellBarSearchFieldFullWidth
} from "./shellbar/templates/ShellBarSearchTemplate.js";
import {
ShellBarSearchField as ShellBarSearchFieldLegacy,
ShellBarSearchButton as ShellBarSearchButtonLegacy,
ShellBarSearchFieldFullWidth as ShellBarSearchFieldFullWidthLegacy,
} from "./shellbar/templates/ShellBarSearchLegacyTemplate.js";
import {
ShellBarLegacyBrandingArea,
} from "./shellbar/templates/ShellBarLegacyTemplate.js";
export default function ShellBarTemplate(this: ShellBar) {
const isLegacySearch = !this.isSelfCollapsibleSearch;
const SearchInBarTemplate = isLegacySearch ? ShellBarSearchFieldLegacy : ShellBarSearchField;
const SearchFullWidthTemplate = isLegacySearch ? ShellBarSearchFieldFullWidthLegacy : ShellBarSearchFieldFullWidth;
const profileAction = this.getAction("profile");
const overflowAction = this.getAction("overflow");
const assistantAction = this.getAction("assistant");
const notificationsAction = this.getAction("notifications");
const productSwitchAction = this.getAction("products");
const actionsAccInfo = this.actionsAccessibilityInfo;
return (
<>
<header class="ui5-shellbar-root" part="root" onKeyDown={this._onKeyDown} aria-label={this.texts.shellbar}>
{/* Full-width search overlay */}
{this.showFullWidthSearch && SearchFullWidthTemplate.call(this)}
{this.enabledFeatures.startButton && (
<div class="ui5-shellbar-start-button ui5-shellbar-gap-end">
<slot name="startButton"></slot>
</div>
)}
{this.enabledFeatures.branding && (
<div class="ui5-shellbar-branding-area">
<slot name="branding"></slot>
</div>
)}
{/* Legacy branding (logo + primaryTitle) when no menu items */}
{!this.enabledFeatures.branding && ShellBarLegacyBrandingArea.call(this)}
<div class="ui5-shellbar-overflow-container">
<div class="ui5-shellbar-overflow-container-inner">
{this.enabledFeatures.content && (
<div
class="ui5-shellbar-content-area ui5-shellbar-content-items"
role={this.contentRole}
aria-label={this.texts.contentItems}
>
{/* Start separator */}
{this.separatorConfig.showStartSeparator && (
<div class="ui5-shellbar-separator ui5-shellbar-separator-start"></div>
)}
{/* Start content items */}
{this.startContent.map(item => {
const itemId = (item as any)._individualSlot as string;
const packedSep = this.getPackedSeparatorInfo(item, true);
return (
<div
key={itemId}
id={itemId}
class={{
"ui5-shellbar-content-item ui5-shellbar-gap-start": true,
"ui5-shellbar-hidden": this.isHidden(itemId),
}}
>
{packedSep.shouldPack && (
<div class="ui5-shellbar-separator ui5-shellbar-separator-start"></div>
)}
<slot name={(item as any)._individualSlot}></slot>
</div>
);
})}
{/* Spacer: Grows to fill available space, used to measure if space is tight, should be in DOM always */}
<div class="ui5-shellbar-spacer"></div>
{/* End content items */}
{this.endContent.map(item => {
const itemId = (item as any)._individualSlot as string;
const packedSep = this.getPackedSeparatorInfo(item, false);
return (
<div
key={itemId}
id={itemId}
class={{
"ui5-shellbar-content-item ui5-shellbar-gap-start": true,
"ui5-shellbar-hidden": this.isHidden(itemId),
}}
>
<slot name={itemId}></slot>
{packedSep.shouldPack && (
<div class="ui5-shellbar-separator ui5-shellbar-separator-end ui5-shellbar-gap-start"></div>
)}
</div>
);
})}
{/* End separator */}
{this.separatorConfig.showEndSeparator && (
<div class="ui5-shellbar-separator ui5-shellbar-separator-end ui5-shellbar-gap-start"></div>
)}
</div>
)}
{this.enabledFeatures.search && SearchInBarTemplate.call(this)}
{this.enabledFeatures.search && isLegacySearch && ShellBarSearchButtonLegacy.call(this)}
{assistantAction && (
<div class={{
"ui5-shellbar-assistant-button ui5-shellbar-gap-start": true,
"ui5-shellbar-hidden": this.isHidden("assistant")
}}>
<slot name="assistant"></slot>
</div>
)}
{notificationsAction && (
<Button
data-ui5-stable={notificationsAction.stableDomRef}
class={{
"ui5-shellbar-bell-button ui5-shellbar-action-button ui5-shellbar-gap-start": true,
"ui5-shellbar-hidden": this.isHidden("notifications")
}}
icon={notificationsAction.icon}
design="Transparent"
onClick={this.handleNotificationsClick}
tooltip={actionsAccInfo.notifications.title}
accessibilityAttributes={actionsAccInfo.notifications.accessibilityAttributes}
>
{notificationsAction?.count && (
<ButtonBadge slot="badge" design="OverlayText" text={notificationsAction?.count} />
)}
</Button>
)}
{/* Custom Items */}
{this.items.map(item => (
<div
key={item._id}
class={{
"ui5-shellbar-custom-item ui5-shellbar-gap-start": true,
"ui5-shellbar-hidden": this.isHidden(item._id),
}}
data-ui5-stable={item.stableDomRef}
>
{!item.inOverflow ? <slot name={(item as any)._individualSlot}></slot> : null}
</div>
))}
{overflowAction && (
<Button
data-ui5-stable={overflowAction.stableDomRef}
id="ui5-shellbar-overflow-button"
class={{
"ui5-shellbar-overflow-button ui5-shellbar-action-button ui5-shellbar-gap-start": true,
"ui5-shellbar-hidden": this.isHidden("overflow")
}}
icon={overflowAction.icon}
design="Transparent"
onClick={this.handleOverflowClick}
tooltip={actionsAccInfo.overflow.title}
accessibilityAttributes={actionsAccInfo.overflow.accessibilityAttributes}
>
{this.overflowBadge && (
<ButtonBadge
slot="badge"
design={this.overflowBadge === " " ? "AttentionDot" : "OverlayText"}
text={this.overflowBadge === " " ? "" : this.overflowBadge}
/>
)}
</Button>
)}
{profileAction && (
<Button
data-profile-btn
data-ui5-stable={profileAction.stableDomRef}
class={{
"ui5-shellbar-image-button ui5-shellbar-action-button ui5-shellbar-gap-start": true,
"ui5-shellbar-hidden": this.isHidden("profile")
}}
design="Transparent"
onClick={this.handleProfileClick}
tooltip={actionsAccInfo.profile.title}
accessibilityAttributes={actionsAccInfo.profile.accessibilityAttributes}
>
<slot name="profile"></slot>
</Button>
)}
{productSwitchAction && (
<Button
data-ui5-stable={productSwitchAction.stableDomRef}
class={{
"ui5-shellbar-button-product-switch ui5-shellbar-action-button ui5-shellbar-gap-start": true,
"ui5-shellbar-hidden": this.isHidden("products")
}}
icon={productSwitchAction.icon}
design="Transparent"
onClick={this.handleProductSwitchClick}
tooltip={actionsAccInfo.products.title}
accessibilityAttributes={actionsAccInfo.products.accessibilityAttributes}
></Button>
)}
</div>
</div>
</header>
{/* Overflow Popover */}
<Popover
class="ui5-shellbar-overflow-popover"
open={this.overflowPopoverOpen}
onClose={this.onPopoverClose}
opener="ui5-shellbar-overflow-button"
placement="Bottom"
hideArrow={true}
horizontalAlign={this.popoverHorizontalAlign} // TODO: add test
>
<List separators="None" onClick={this.handleOverflowItemClick}>
{this.overflowItems.map(item => {
if (item.type === "action") {
const actionData = item.data;
return (
<ShellBarItem
key={item.id}
icon={actionData.icon ? `sap-icon://${actionData.icon}` : ""}
data-action-id={item.id}
count={actionData.count}
inOverflow={true}
text={this.getActionOverflowText(item.id)}
/>
);
}
return <slot key={item.id} name={item.data._individualSlot}></slot>;
})}
</List>
</Popover>
</>
);
}