Skip to content

Commit 08fc5f3

Browse files
authored
feat(ui5-shellbar): add "logo" slot (#1842)
Replace the existing property "logo" with a slot with the same name to enable users set an element of their choice and freedom to customize it. FIXES: #1841 BREAKING_CHANGE: property "logo" has been removed, use the "logo" slot instead as follows: ```html <ui5-shellbar> <img slot="logo" src="../../../assets/images/sap-logo-svg.svg"/> </ui5-shellbar> ```
1 parent f95807d commit 08fc5f3

File tree

6 files changed

+292
-268
lines changed

6 files changed

+292
-268
lines changed

packages/fiori/src/ShellBar.hbs

+12-5
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,17 @@
1111
{{/if}}
1212

1313
{{#if hasFocusableLogo}}
14-
<img class="ui5-shellbar-logo"
15-
src="{{logo}}"
16-
@click="{{_logoPress}}"
14+
<span class="ui5-shellbar-logo"
1715
role="button"
1816
aria-label="{{_logoText}}"
1917
title="{{_logoText}}"
18+
@click="{{_logoPress}}"
2019
@keydown="{{_logoKeydown}}"
2120
@keyup="{{_logoKeyup}}"
2221
tabindex="0"
23-
/>
22+
>
23+
<slot name="logo"></slot>
24+
</span>
2425
{{/if}}
2526

2627
{{#if showArrowDown}}
@@ -31,7 +32,13 @@
3132
aria-expanded="{{menuPopoverExpanded}}"
3233
>
3334
{{#if hasNonFocusableLogo}}
34-
<img class="ui5-shellbar-logo" src="{{logo}}" aria-label="{{_logoText}}" title="{{_logoText}}"/>
35+
<span
36+
class="ui5-shellbar-logo"
37+
aria-label="{{_logoText}}"
38+
title="{{_logoText}}"
39+
>
40+
<slot name="logo"></slot>
41+
</span>
3542
{{/if}}
3643

3744
{{#if primaryTitle}}

packages/fiori/src/ShellBar.js

+29-12
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,6 @@ const metadata = {
4141
languageAware: true,
4242
properties: /** @lends sap.ui.webcomponents.fiori.ShellBar.prototype */ {
4343

44-
/**
45-
* Defines the <code>logo</code> source URI.
46-
* @type {string}
47-
* @defaultvalue ""
48-
* @public
49-
*/
50-
logo: {
51-
type: String,
52-
},
53-
5444
/**
5545
* Defines the <code>primaryTitle</code>.
5646
* <br><br>
@@ -132,10 +122,20 @@ const metadata = {
132122
type: Boolean,
133123
},
134124

125+
/**
126+
* @private
127+
*/
135128
coPilotActive: {
136129
type: Boolean,
137130
},
138131

132+
/**
133+
* @private
134+
*/
135+
withLogo: {
136+
type: Boolean,
137+
},
138+
139139
_itemsInfo: {
140140
type: Object,
141141
},
@@ -194,6 +194,18 @@ const metadata = {
194194
type: HTMLElement,
195195
},
196196

197+
/**
198+
* Defines the logo of the <code>ui5-shellbar</code>.
199+
* For example, you can use <code>ui5-avatar</code> or <code>img</code> elements as logo.
200+
* @type {HTMLElement}
201+
* @slot
202+
* @since 1.0.0-rc.8
203+
* @public
204+
*/
205+
logo: {
206+
type: HTMLElement,
207+
},
208+
197209
/**
198210
* Defines the items displayed in menu after a click on the primary title.
199211
* <br><br>
@@ -509,6 +521,7 @@ class ShellBar extends UI5Element {
509521
const animationsOn = getAnimationMode() === AnimationMode.Full;
510522
const coPilotAnimation = getFeature("CoPilotAnimation");
511523
this.coPilot = coPilotAnimation && animationsOn ? coPilotAnimation : { animated: false };
524+
this.withLogo = this.hasLogo;
512525

513526
this._hiddenIcons = this._itemsInfo.filter(info => {
514527
const isHidden = (info.classes.indexOf("ui5-shellbar-hidden-button") !== -1);
@@ -909,11 +922,15 @@ class ShellBar extends UI5Element {
909922
}
910923

911924
get hasFocusableLogo() {
912-
return this.logo && !this.nonFocusableLogo;
925+
return this.hasLogo && !this.nonFocusableLogo;
913926
}
914927

915928
get hasNonFocusableLogo() {
916-
return this.logo && this.nonFocusableLogo;
929+
return this.hasLogo && this.nonFocusableLogo;
930+
}
931+
932+
get hasLogo() {
933+
return !!this.logo.length;
917934
}
918935

919936
get showArrowDown() {

packages/fiori/src/themes/ShellBar.css

+8-2
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ slot[name="profile"] {
255255
cursor: pointer;
256256
}
257257

258-
:host(:not([logo])) .ui5-shellbar-menu-button {
258+
:host(:not([with-logo])) .ui5-shellbar-menu-button {
259259
margin-left: 0;
260260
}
261261

@@ -377,6 +377,12 @@ ui5-icon[data-count]::before {
377377
outline: 1px dotted var(--sapContent_ContrastFocusColor);
378378
}
379379

380+
::slotted([slot="logo"]) {
381+
height: 1.675rem;
382+
max-width: 3rem;
383+
pointer-events: none;
384+
}
385+
380386
/**
381387
* IE styles
382388
*/
@@ -391,7 +397,7 @@ ui5-input:not([value-state]):not([readonly]):hover {
391397
border: 1px solid var(--sapShell_InteractiveBorderColor);
392398
}
393399

394-
ui5-input[value-state]:not([value-stat="None"])[focused] {
400+
ui5-input[value-state]:not([value-state="None"])[focused] {
395401
outline: 1px dotted var(--sapContent_ContrastFocusColor);
396402
}
397403
/* IE styles end */

0 commit comments

Comments
 (0)