-
Notifications
You must be signed in to change notification settings - Fork 274
feat(ui5-shellbar): branding slot introduced #11320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
yanaminkova
wants to merge
11
commits into
main
Choose a base branch
from
sb-branding
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+297
−12
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1d5766c
feat(ui5-shellbar): branding slot introduced
yanaminkova 0035162
feat(ui5-shellbar): fix merge conflicts
yanaminkova 7e1edfc
feat(ui5-shellbar): fix merge conflict
yanaminkova 1eac526
feat(ui5-shellbar): fix typo
yanaminkova 481eebe
feat(ui5-shellbar): improvements
yanaminkova 94cbb3f
Merge remote-tracking branch 'origin/main' into sb-branding
yanaminkova b1a0a86
feat(ui5-shellbar): fix
yanaminkova ab9932f
feat(ui5-shellbar): fix tests
yanaminkova e5bcb9a
feat(ui5-shellbar): make brandingTitle slot
yanaminkova 7c42227
Merge remote-tracking branch 'origin/main' into sb-branding
yanaminkova a813438
feat(ui5-shellbar): fix aria-label
yanaminkova File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js"; | ||
import property from "@ui5/webcomponents-base/dist/decorators/property.js"; | ||
import slot from "@ui5/webcomponents-base/dist/decorators/slot.js"; | ||
import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js"; | ||
import jsxRenderer from "@ui5/webcomponents-base/dist/renderer/JsxRenderer.js"; | ||
|
||
import type { | ||
AriaRole, | ||
} from "@ui5/webcomponents-base"; | ||
|
||
// Template | ||
import ShellBarBrandingTemplate from "./ShellBarBrandingTemplate.js"; | ||
|
||
// Styles | ||
import shellBarStyles from "./generated/themes/ShellBar.css.js"; | ||
import shellBarBrandingCss from "./generated/themes/ShellBarBranding.css.js"; | ||
|
||
type ShellBarLogoAccessibilityAttributes = { | ||
role?: Extract<AriaRole, "link" | "button"> | ||
} | ||
|
||
type ShellBarBrandingAccessibilityAttributes = { | ||
logo?: ShellBarLogoAccessibilityAttributes | ||
}; | ||
|
||
/** | ||
* @class | ||
* | ||
* ### Overview | ||
* The `ui5-shellbar-branding` component is intended to be placed inside the branding slot of the | ||
* `ui5-shellbar` component. Its content has higher priority than the `primaryTitle` property | ||
* and the `logo` slot of `ui5-shellbar`. | ||
* | ||
* @constructor | ||
* @extends UI5Element | ||
* @since 2.11.0 | ||
* @public | ||
*/ | ||
@customElement({ | ||
tag: "ui5-shellbar-branding", | ||
languageAware: true, | ||
renderer: jsxRenderer, | ||
template: ShellBarBrandingTemplate, | ||
styles: [shellBarStyles, shellBarBrandingCss], | ||
}) | ||
|
||
class ShellBarBranding extends UI5Element { | ||
/** | ||
* Defines the component href. | ||
* | ||
* **Note:** Standard hyperlink behavior is supported. | ||
* @default undefined | ||
* @public | ||
*/ | ||
@property() | ||
href?: string; | ||
|
||
/** | ||
* Defines the component target. | ||
* | ||
* **Notes:** | ||
* | ||
* - `_self` | ||
* - `_top` | ||
* - `_blank` | ||
* - `_parent` | ||
* - `_search` | ||
* | ||
* **This property must only be used when the `href` property is set.** | ||
* @default undefined | ||
* @public | ||
*/ | ||
@property() | ||
target?: string; | ||
|
||
/** | ||
* Defines the title for the ui5-shellbar-branding component. | ||
* | ||
* @default undefined | ||
* @public | ||
*/ | ||
@slot({ type: HTMLElement, "default": true }) | ||
brandingTitle!: Array<HTMLElement>; | ||
|
||
/** | ||
* Defines additional accessibility attributes to the component. | ||
* | ||
* The accessibilityAttributes object has the following fields, | ||
* where each field is an object supporting one or more accessibility attributes: | ||
* | ||
* - **logo** - `logo.role` | ||
* | ||
* The accessibility attributes support the following values: | ||
* | ||
* - **role**: Defines the accessible ARIA role of the logo area. | ||
* Accepts the following string values: `link` or `button`. | ||
* | ||
* | ||
* @default {} | ||
* @public | ||
*/ | ||
@property({ type: Object }) | ||
accessibilityAttributes: ShellBarBrandingAccessibilityAttributes = {}; | ||
|
||
/** | ||
* Defines the logo of the `ui5-shellbar`. | ||
* For example, you can use `ui5-avatar` or `img` elements as logo. | ||
* @public | ||
*/ | ||
@slot({ type: HTMLElement }) | ||
logo!: Array<HTMLElement>; | ||
|
||
get parsedRef() { | ||
return (this.href && this.href.length > 0) ? this.href : undefined; | ||
} | ||
|
||
get _logoAreaText() { | ||
const defaultSlot = this.shadowRoot!.querySelector("slot:not([name])") as HTMLSlotElement; | ||
if (defaultSlot) { | ||
const assignedNodes = defaultSlot.assignedNodes({ flatten: true }); | ||
const texts = assignedNodes | ||
.filter(n => n.nodeType === Node.TEXT_NODE) | ||
.map(n => n.textContent?.trim()) | ||
.filter(Boolean); | ||
return texts[0]; | ||
} | ||
} | ||
|
||
get accLogoRole() { | ||
return this.accessibilityAttributes.logo?.role || "link"; | ||
} | ||
} | ||
|
||
ShellBarBranding.define(); | ||
|
||
export default ShellBarBranding; | ||
export type { | ||
ShellBarBrandingAccessibilityAttributes, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import type ShellBarBranding from "./ShellBarBranding.js"; | ||
|
||
export default function ShellBarBrandingTemplate(this: ShellBarBranding) { | ||
return ( | ||
<a | ||
part="root" | ||
class="ui5-shellbar-branding-root" | ||
href={this.parsedRef} | ||
target={this.target} | ||
role={this.accLogoRole} | ||
tabIndex={0} | ||
aria-label={this._logoAreaText} | ||
> | ||
<slot name="logo"></slot> | ||
|
||
<h1 class="ui5-shellbar-title"> | ||
<bdi> | ||
<slot></slot> | ||
</bdi> | ||
</h1> | ||
</a> | ||
); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
:host(:not([hidden])) .ui5-shellbar-branding-root { | ||
text-decoration: none; | ||
} | ||
|
||
:host(:not([hidden])) { | ||
display: inline; | ||
} | ||
|
||
.ui5-shellbar-branding-root { | ||
overflow: hidden; | ||
display: flex; | ||
align-items: center; | ||
padding: .25rem .5rem .25rem .25rem; | ||
box-sizing: border-box; | ||
cursor: pointer; | ||
background: var(--sapButton_Lite_Background); | ||
border: 1px solid var(--sapButton_Lite_BorderColor); | ||
color: var(--sapShell_TextColor); | ||
/* fix cutting of the focus outline */ | ||
margin-inline-start: 0.125rem; | ||
} | ||
|
||
.ui5-shellbar-branding-root:focus { | ||
outline: var(--_ui5_shellbar_logo_outline); | ||
border-radius: var(--_ui5_shellbar_logo_border_radius); | ||
} | ||
|
||
.ui5-shellbar-branding-root:hover { | ||
box-shadow: var(--_ui5_shellbar_button_box_shadow); | ||
border-radius: var(--_ui5_shellbar_logo_border_radius); | ||
} | ||
|
||
.ui5-shellbar-branding-root:active:focus { | ||
background: var(--sapShell_Active_Background); | ||
border: 1px solid var(--sapButton_Lite_Active_BorderColor); | ||
color: var(--sapShell_Active_TextColor); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@since 2.10.0