Skip to content
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

Shellbar motion design #11132

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
36 changes: 31 additions & 5 deletions packages/fiori/src/ShellBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,9 @@ class ShellBar extends UI5Element {
_overflowNotifications: string | null;
_lastOffsetWidth = 0;
_observableContent: Array<HTMLElement> = [];
_isAnimating: boolean = false;
_autoRestoreSearchField = false;
_handleAnimationEndRef = this._handleAnimationEnd.bind(this);

_headerPress: () => void;

Expand Down Expand Up @@ -737,7 +739,9 @@ class ShellBar extends UI5Element {

onAfterRendering() {
this._lastOffsetWidth = this.offsetWidth;
this._overflowActions();
if (!this._isAnimating) {
this._overflowActions();
}
this.onInitialRendering();
}

Expand Down Expand Up @@ -785,7 +789,7 @@ class ShellBar extends UI5Element {

_resetItemsVisibility(items: Array<HTMLElement>) {
items.forEach(item => {
item.classList.remove("ui5-shellbar-hidden-button");
item.classList.contains("ui5-shellbar-hidden-button") && item.classList.remove("ui5-shellbar-hidden-button");
});
}

Expand Down Expand Up @@ -855,12 +859,33 @@ class ShellBar extends UI5Element {
ResizeHandler.deregister(this, this._handleResize);
}

_handleAnimationEnd() {
this._isAnimating = false;
this.searchField[0].removeEventListener("animationend", this._handleAnimationEndRef);
this._overflowActions();
this.shadowRoot!.querySelector("header")!.classList.remove("ui5-shellbar-animating");
}

_attachAnimationEndHandlers() {
const searchWrapper = this.shadowRoot!.querySelector(".ui5-shellbar-search-field");
this._isAnimating = true;
this.shadowRoot!.querySelector("header")!.classList.add("ui5-shellbar-animating");
searchWrapper?.addEventListener("animationend", this._handleAnimationEndRef);
setTimeout(() => {
if (this._isAnimating) {
this._handleAnimationEnd();
}
}, RESIZE_THROTTLE_RATE);
}

_handleSearchIconPress() {
const searchButtonRef = this.shadowRoot!.querySelector<Button>(".ui5-shellbar-search-button")!;
const defaultPrevented = !this.fireDecoratorEvent("search-button-click", {
targetRef: searchButtonRef,
searchFieldVisible: this.showSearchField,
});
this._attachAnimationEndHandlers();

if (defaultPrevented) {
return;
}
Expand Down Expand Up @@ -932,6 +957,7 @@ class ShellBar extends UI5Element {

_handleCancelButtonPress() {
this.showSearchField = false;
this._attachAnimationEndHandlers();
}

_handleProductSwitchPress(e: MouseEvent) {
Expand Down Expand Up @@ -1235,7 +1261,7 @@ class ShellBar extends UI5Element {
return {
wrapper: {
"ui5-shellbar-root": true,
"ui5-shellbar-with-searchfield": this.hasSearchField,
"ui5-shellbar-with-searchfield": this.hasSearchField
},
button: {
"ui5-shellbar-menu-button--interactive": this.hasMenuItems,
Expand All @@ -1259,7 +1285,7 @@ class ShellBar extends UI5Element {
get styles() {
return {
searchField: {
"display": this.showSearchField ? "flex" : "none",
"display": this.showSearchField || this._isAnimating ? "flex" : "none",
},
};
}
Expand Down Expand Up @@ -1416,7 +1442,7 @@ class ShellBar extends UI5Element {
return this.contentItems.length > 0;
}

get hidableDomElements(): HTMLElement [] {
get hidableDomElements(): HTMLElement[] {
const items = Array.from(this.shadowRoot!.querySelectorAll<HTMLElement>(".ui5-shellbar-button:not(.ui5-shellbar-search-button):not(.ui5-shellbar-overflow-button):not(.ui5-shellbar-cancel-button):not(.ui5-shellbar-no-overflow-button)"));
const assistant = this.shadowRoot!.querySelector<HTMLElement>(".ui5-shellbar-assistant-button");
const searchButton = this.shadowRoot!.querySelector<HTMLElement>(".ui5-shellbar-search-button");
Expand Down
4 changes: 2 additions & 2 deletions packages/fiori/src/ShellBarTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default function ShellBarTemplate(this: ShellBar) {
{this.startContent.map((item, index) => {
const itemInfo = this._contentInfo.find(info => info.id === item._individualSlot);
return (
<div key={item._individualSlot} id={item._individualSlot} class={itemInfo?.classes}>
<div key={item._individualSlot} id={item._individualSlot} class={itemInfo?.classes} data-hide-order={`${item.getAttribute("data-hide-order")}`}>
{!this.showStartSeparatorInWrapper && index === 0 && (
<div class={{
"ui5-shellbar-separator": true,
Expand All @@ -100,7 +100,7 @@ export default function ShellBarTemplate(this: ShellBar) {
{this.endContent.map((item, index) => {
const itemInfo = this._contentInfo.find(info => info.id === item._individualSlot);
return (
<div key={item._individualSlot} id={item._individualSlot} class={itemInfo?.classes}>
<div key={item._individualSlot} id={item._individualSlot} class={itemInfo?.classes} data-hide-order={item.getAttribute("data-hide-order")}>
<slot name={item._individualSlot}></slot>
{!this.showEndSeparatorInWrapper && index === this.endContent.length - 1 && (
<div class={{
Expand Down
106 changes: 102 additions & 4 deletions packages/fiori/src/themes/ShellBar.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
line-height: inherit;
letter-spacing: inherit;
word-spacing: inherit;
flex-shrink: 0;
}

::slotted([ui5-toggle-button][slot="assistant"]) {
Expand Down Expand Up @@ -445,11 +446,17 @@ slot[name="profile"] {
}

.ui5-shellbar-search-field {
padding-inline-start: var(--_ui5-shellbar-content-margin-start);
min-width: var(--_ui5_shellbar_search_field_width);
align-items: center;
flex-grow: 1;
margin-inline-start: 0.5rem;
display: flex;
width: 0;
overflow: hidden;
}

:host([show-search-field]:not(.ui5-shellbar-animating)) .ui5-shellbar-search-field {
min-width: var(--_ui5_shellbar_search_field_width);
padding-inline-start: var(--_ui5-shellbar-content-margin-start);
}

.ui5-shellbar-overflow-container-right-child > :first-child,
Expand Down Expand Up @@ -486,7 +493,6 @@ slot[name="profile"] {
color: var(--_ui5_shellbar_search_field_color);
height: 2.25rem;
width: 100%;
min-width: var(--_ui5_shellbar_search_field_width);
}

:host([breakpoint-size="M"]) ::slotted([ui5-input]),
Expand Down Expand Up @@ -533,12 +539,17 @@ slot[name="profile"] {
width: auto;
}

.ui5-shellbar-animating .ui5-shellbar-content-item {
animation: motion-show 0.2s cubic-bezier(0.2, 0.2, 0.38, 0.9);
animation-fill-mode: forwards;
}

/* if class contains ui5-shellbar-hidden-button */
::slotted(.ui5-shellbar-hidden-button),
.ui5-shellbar-hidden-button,
.ui5-shellbar-invisible-button {
visibility: hidden;
order: -1;
visibility: hidden;
opacity: 0;
min-width: 0;
width: 0;
Expand All @@ -547,4 +558,91 @@ slot[name="profile"] {
padding-inline-start: 0;
border: 0;
margin-inline-start: 0;
}



.ui5-shellbar-animating .ui5-shellbar-content-item.ui5-shellbar-hidden-button {
animation: motion-hide 0.2s cubic-bezier(0.2, 0.2, 0.38, 0.9);
animation-fill-mode: forwards;
}
.ui5-shellbar-content-item[data-hide-order = 1] {
animation-duration: 0.01s;
}
.ui5-shellbar-content-item[data-hide-order = 2] {
animation-duration: 0.1s;
}
.ui5-shellbar-content-item[data-hide-order = 3] {
animation-duration: 0.15s;
}
.ui5-shellbar-content-item[data-hide-order = 4] {
animation-duration: 0.2s;
}
.ui5-shellbar-content-item[data-hide-order = 5] {
animation-duration: 0.25s;
}
.ui5-shellbar-content-item[data-hide-order = 6] {
animation-duration: 0.3s;
}
.ui5-shellbar-content-item[data-hide-order = 7] {
animation-duration: 0.35s;
}
.ui5-shellbar-content-item[data-hide-order = 8] {
animation-duration: 0.4s;
}
.ui5-shellbar-content-item[data-hide-order = 9] {
animation-duration: 0.45s;
}
.ui5-shellbar-content-item[data-hide-order = 10] {
animation-duration: 0.5s;
}

.ui5-shellbar-animating .ui5-shellbar-search-field {
animation: expand-shrink 0.2s cubic-bezier(0.2, 0.2, 0.38, 0.9);
}

:host([show-search-field]) .ui5-shellbar-animating .ui5-shellbar-search-field,
:host([show-search-field]) .ui5-shellbar-animating .ui5-shellbar-search-full-width-wrapper {
animation: expand-grow 0.2s cubic-bezier(0.2, 0.2, 0.38, 0.9) forwards;
}

@keyframes motion-hide {
from {
opacity: 1;
}
to {
opacity: 0;
}
}

@keyframes motion-show {
from {
opacity: 0;
}
to {
opacity: 1;
}
}

@keyframes expand-grow {
from {
min-width: 0;
opacity: 0;
}
to {
min-width: var(--_ui5_shellbar_search_field_width);
opacity: 1;
}
}

@keyframes expand-shrink {
from {
min-width: var(--_ui5_shellbar_search_field_width);
opacity: 1;
}
to {
min-width: 0;
opacity: 0;
padding-inline-start: 0;
}
}