-
Notifications
You must be signed in to change notification settings - Fork 276
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
15
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.
Open
Changes from all commits
Commits
Show all changes
15 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 f22f2d8
feat(ui5-shellbar): replace usage of primary-title
yanaminkova a688339
feat(ui5-shellbar): remove unnecessary tests
yanaminkova 1a352dc
feat(ui5-shellbar): fix css
yanaminkova 1f58894
Merge branch 'main' into sb-branding
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import ShellBar from "../../src/ShellBar.js"; | ||
import ShellBarBranding from "../../src/ShellBarBranding.js" | ||
|
||
describe("ShellBarBranding", () => { | ||
const basicTemplate = (brandingProps = {}, shellBarProps = {}) => { | ||
const defaultShellBarProps = { | ||
id: "shellbar", | ||
...shellBarProps | ||
}; | ||
|
||
const defaultBrandingProps = { | ||
id: "shellbarBranding", | ||
brandingTitle: "Branding Comp", | ||
slot: "branding", | ||
...brandingProps | ||
}; | ||
|
||
cy.mount( | ||
<ShellBar {...defaultShellBarProps}> | ||
<ShellBarBranding {...defaultBrandingProps}> | ||
<img id="brandingLogo" src="https://upload.wikimedia.org/wikipedia/commons/5/59/SAP_2011_logo.svg" slot="logo"/> | ||
</ShellBarBranding> | ||
</ShellBar> | ||
); | ||
|
||
cy.get("#shellbar").find("#shellbarBranding").shadow().as("shellbarBranding"); | ||
}; | ||
|
||
describe("Properties", () => { | ||
it("Test ui5-shellbar-branding href property", () => { | ||
basicTemplate({ href: "https://sap.github.io/ui5-webcomponents/", target: "_blank" }); | ||
|
||
cy.get("@shellbarBranding") | ||
.find("a") | ||
.should("have.prop", "href", "https://sap.github.io/ui5-webcomponents/"); | ||
}); | ||
|
||
it("Test ui5-shellbar-branding target property", () => { | ||
basicTemplate({ href: "https://sap.github.io/ui5-webcomponents/", target: "_blank" }); | ||
|
||
cy.get("@shellbarBranding") | ||
.find("a") | ||
.should("have.attr", "target", "_blank"); | ||
}); | ||
|
||
it("Test ui5-shellbar-branding brandingTitle property", () => { | ||
basicTemplate(); | ||
|
||
cy.get("@shellbarBranding") | ||
.find(".ui5-shellbar-title") | ||
.should("exist") | ||
.and("contain.text", "Branding Comp"); | ||
}); | ||
}); | ||
|
||
describe("Slots", () => { | ||
it("Test ui5-shellbar-branding logo slot", () => { | ||
basicTemplate(); | ||
|
||
cy.get("#brandingLogo") | ||
.should("exist") | ||
.should("have.attr", "slot", "logo"); | ||
|
||
cy.get("@shellbarBranding") | ||
.find("slot[name='logo']") | ||
.should("exist"); | ||
}); | ||
}); | ||
|
||
describe("Accessibility", () => { | ||
it("Test ui5-shellbar-branding accessibility - default logo role", () => { | ||
basicTemplate(); | ||
|
||
cy.get("@shellbarBranding") | ||
.find("a") | ||
.should("have.attr", "role", "link"); | ||
}); | ||
|
||
it("Test ui5-shellbar-branding accessibility - custom logo role", () => { | ||
basicTemplate({ | ||
accessibilityAttributes: { logo: { role: "button" } } | ||
}); | ||
|
||
cy.get("@shellbarBranding") | ||
.find("a") | ||
.should("have.attr", "role", "button"); | ||
}); | ||
|
||
it("Test ui5-shellbar-branding accessibility - aria-label", () => { | ||
basicTemplate(); | ||
|
||
cy.get("@shellbarBranding") | ||
.find("a") | ||
.should("have.attr", "aria-label", "Branding Comp"); | ||
}); | ||
|
||
it("Test ui5-shellbar-branding tabIndex", () => { | ||
basicTemplate(); | ||
|
||
cy.get("@shellbarBranding") | ||
.find("a") | ||
.should("have.attr", "tabIndex", "0"); | ||
}); | ||
}); | ||
}); |
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,131 @@ | ||
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 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.10.0 | ||
* @public | ||
* @experimental | ||
*/ | ||
@customElement({ | ||
tag: "ui5-shellbar-branding", | ||
languageAware: true, | ||
renderer: jsxRenderer, | ||
template: ShellBarBrandingTemplate, | ||
styles: 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 | ||
*/ | ||
@property() | ||
brandingTitle?: string; | ||
|
||
/** | ||
* 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() { | ||
return this.brandingTitle ?? ""; | ||
} | ||
|
||
get accBrandingRole() { | ||
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,22 @@ | ||
import type ShellBarBranding from "./ShellBarBranding.js"; | ||
|
||
export default function ShellBarBrandingTemplate(this: ShellBarBranding) { | ||
return ( | ||
<a | ||
class="ui5-shellbar-branding-root" | ||
href={this.parsedRef} | ||
target={this.target} | ||
role={this.accBrandingRole} | ||
tabIndex={0} | ||
aria-label={this._logoAreaText} | ||
> | ||
<slot name="logo"></slot> | ||
|
||
{this.brandingTitle && ( | ||
<h1 class="ui5-shellbar-title"> | ||
<bdi>{this.brandingTitle}</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
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.
The logo is no longer an interactive area, role link does not make sense. Seems to me that it needs to be img or presentation (decorative). This need to be checked with accessibility spec.
Uh oh!
There was an error while loading. Please reload this page.
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.
The value returned by this getter is assigned to the anchor element, not to the logo itself. I might rename the getter to better reflect what it's used for.