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

fix(core/message-bar): message bar #1688

Merged
merged 18 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/pretty-guests-jog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@siemens/ix-angular': minor
'@siemens/ix': minor
'@siemens/ix-vue': minor
---

`ix-message-bar`: Event `closedChange` can now be prevented via `event.preventDefault()`.
An additional event is added to get notified after the close animation of the `ix-message-bar` is finished.
5 changes: 5 additions & 0 deletions packages/angular-test-app/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ import MenuCategory from '../preview-examples/menu-category';
import MenuWithBottomTabs from '../preview-examples/menu-with-bottom-tabs';
import Message from '../preview-examples/message';
import MessageBar from '../preview-examples/message-bar';
import MessageBarRemoval from '../preview-examples/message-bar-removal';
import ModalByInstance from '../preview-examples/modal-by-instance';
import ModalByInstanceContent from '../preview-examples/modal-by-instance-content';
import ModalByTemplate from '../preview-examples/modal-by-template';
Expand Down Expand Up @@ -716,6 +717,10 @@ const routes: Routes = [
path: 'message-bar',
component: MessageBar,
},
{
path: 'message-bar-removal',
component: MessageBarRemoval,
},
{
path: 'modal-by-instance-content',
component: ModalByInstanceContent,
Expand Down
2 changes: 2 additions & 0 deletions packages/angular-test-app/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ import MenuCategory from '../preview-examples/menu-category';
import MenuWithBottomTabs from '../preview-examples/menu-with-bottom-tabs';
import Message from '../preview-examples/message';
import MessageBar from '../preview-examples/message-bar';
import MessageBarRemoval from '../preview-examples/message-bar-removal';
import ModalByInstance from '../preview-examples/modal-by-instance';
import ModalByInstanceContent from '../preview-examples/modal-by-instance-content';
import ModalByTemplate from '../preview-examples/modal-by-template';
Expand Down Expand Up @@ -372,6 +373,7 @@ import WorkflowVertical from '../preview-examples/workflow-vertical';
MenuWithBottomTabs,
Message,
MessageBar,
MessageBarRemoval,
ModalByInstanceContent,
ModalByInstance,
ModalByTemplate,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!--
SPDX-FileCopyrightText: 2025 Siemens AG

SPDX-License-Identifier: MIT

This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
-->

<div class="message-bar">
<ix-message-bar
*ngIf="messageBarVisible"
(closeAnimationCompleted)="handleCloseAnimationCompleted()"
>
Message text
</ix-message-bar>

<ix-button
*ngIf="!messageBarVisible"
(click)="handleShowMessage()"
>
Show message bar
</ix-button>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* SPDX-FileCopyrightText: 2024 Siemens AG
*
* SPDX-License-Identifier: MIT
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import { Component } from '@angular/core';

@Component({
selector: 'app-message-bar-single-removal',
templateUrl: './message-bar-removal.html',
styleUrls: ['./message-bar.css']
})
export default class MessageBarRemoval {
messageBarVisible = true;

handleCloseAnimationCompleted() {
this.messageBarVisible = false;
}

handleShowMessage() {
this.messageBarVisible = true;
}
}
19 changes: 19 additions & 0 deletions packages/angular-test-app/src/preview-examples/message-bar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!--
SPDX-FileCopyrightText: 2025 Siemens AG
SPDX-License-Identifier: MIT
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
-->

<div class="message-bar">
<ix-message-bar dismissible="false">Message text</ix-message-bar>
<ix-message-bar dismissible="false" type="warning">Message text</ix-message-bar>
<ix-message-bar dismissible="false" type="danger">
<div class="d-flex align-items-center justify-content-between">
Message text
<ix-button>Action</ix-button>
</div>
</ix-message-bar>
</div>
13 changes: 1 addition & 12 deletions packages/angular-test-app/src/preview-examples/message-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,7 @@ import { Component } from '@angular/core';

@Component({
selector: 'app-example',
template: `
<div class="message-bar">
<ix-message-bar>Message text</ix-message-bar>
<ix-message-bar type="warning">Message text</ix-message-bar>
<ix-message-bar type="danger">
<div class="d-flex align-items-center justify-content-between">
Message text
<ix-button>Action</ix-button>
</div>
</ix-message-bar>
</div>
`,
templateUrl: './message-bar.html',
styleUrls: ['./message-bar.css'],
})
export default class MessageBar {}
6 changes: 5 additions & 1 deletion packages/angular/src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1812,7 +1812,7 @@ export class IxMessageBar {
constructor(c: ChangeDetectorRef, r: ElementRef, protected z: NgZone) {
c.detach();
this.el = r.nativeElement;
proxyOutputs(this, this.el, ['closedChange']);
proxyOutputs(this, this.el, ['closedChange', 'closeAnimationCompleted']);
}
}

Expand All @@ -1822,6 +1822,10 @@ export declare interface IxMessageBar extends Components.IxMessageBar {
* An event emitted when the close button is clicked
*/
closedChange: EventEmitter<CustomEvent<any>>;
/**
* An event emitted when the close animation is completed
*/
closeAnimationCompleted: EventEmitter<CustomEvent<any>>;
}


Expand Down
14 changes: 14 additions & 0 deletions packages/core/component-doc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13934,6 +13934,20 @@
],
"methods": [],
"events": [
{
"event": "closeAnimationCompleted",
"detail": "any",
"bubbles": true,
"complexType": {
"original": "any",
"resolved": "any",
"references": {}
},
"cancelable": true,
"composed": true,
"docs": "An event emitted when the close animation is completed",
"docsTags": []
},
{
"event": "closedChange",
"detail": "any",
Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4435,6 +4435,7 @@ declare global {
};
interface HTMLIxMessageBarElementEventMap {
"closedChange": any;
"closeAnimationCompleted": any;
}
interface HTMLIxMessageBarElement extends Components.IxMessageBar, HTMLStencilElement {
addEventListener<K extends keyof HTMLIxMessageBarElementEventMap>(type: K, listener: (this: HTMLIxMessageBarElement, ev: IxMessageBarCustomEvent<HTMLIxMessageBarElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
Expand Down Expand Up @@ -7231,6 +7232,10 @@ declare namespace LocalJSX {
* If true, close button is enabled and alert can be dismissed by the user
*/
"dismissible"?: boolean;
/**
* An event emitted when the close animation is completed
*/
"onCloseAnimationCompleted"?: (event: IxMessageBarCustomEvent<any>) => void;
/**
* An event emitted when the close button is clicked
*/
Expand Down
29 changes: 19 additions & 10 deletions packages/core/src/components/message-bar/message-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ export class MessageBar {
*/
@Event() closedChange!: EventEmitter;

/**
* An event emitted when the close animation is completed
*/
@Event() closeAnimationCompleted!: EventEmitter;

@State() icon?: 'error' | 'warning' | 'info';

@State() color?: NotificationColor;
Expand All @@ -66,16 +71,20 @@ export class MessageBar {
}

private closeAlert(el: HTMLElement) {
anime({
targets: el,
duration: MessageBar.duration,
opacity: [1, 0],
easing: 'easeOutSine',
complete: () => {
el.classList.add('d-none');
},
});
this.closedChange.emit();
const { defaultPrevented } = this.closedChange.emit();

if (!defaultPrevented) {
anime({
targets: el,
duration: MessageBar.duration,
opacity: [1, 0],
easing: 'easeOutSine',
complete: () => {
el.classList.add('d-none');
this.closeAnimationCompleted.emit();
},
});
}
}

render() {
Expand Down
36 changes: 36 additions & 0 deletions packages/documentation/docs/controls/_message_bar_code.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import Props from './../auto-generated/ix-message-bar/props.md';
import Events from './../auto-generated/ix-message-bar/events.md';
import Playground from '@site/src/components/PlaygroundV3';

## Development

### Examples

#### Basic
The message bar Web Component only provides the visual appearance of the message bar.
To fully utilize the message bar, you need to implement a mechanism to remove it from the DOM when it is no longer needed.
This typically involves handling the close event and updating the state of your application to reflect the removal of the message bar.

<Playground
name="message-bar"
height="14rem"
>
</Playground>

#### Dismissible

<Playground
name="message-bar-removal"
height="14rem"
>
</Playground>

## API

### Properties

<Props />

### Events

<Events />
4 changes: 2 additions & 2 deletions packages/documentation/docs/controls/_toast_styleguide.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ Toasts are small pop-ups that provide simple feedback on a process. They are UI
- Do use toasts to instantly inform a user about the outcome of an action
- Do include shortcuts to undo an action immediately after it's taken
- Do stick with a consistent position for toasts within the same app and avoid interchanging their positions
- Donโ€™t use toasts for high-priority or critical alerts that prevent the user from continuing their work (use a [modal](modal.md) or a [message bar](messagebar.md) instead)
- Donโ€™t use toasts for high-priority or critical alerts that prevent the user from continuing their work (use a [modal](modal.md) or a [message bar](message-bar.mdx) instead)
- Donโ€™t edit or reuse icons or icon colors from the four predefined toast types when creating custom toasts

### Related patterns

- [Modal](modal.md)
- [Message bar](messagebar.md)
- [Message bar](message-bar.mdx)
- [Drawer](drawer.md)
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ Unlike a modal, popover news does not prevent users from navigating and interact
### Dos and Donโ€™ts

- Do use popover news for "nice to know" information
- Donโ€˜t use popover news for essential information a user must read, instead use a [modal](../modal.md) or a [message bar](../messagebar.md)
- Donโ€˜t use popover news for essential information a user must read, instead use a [modal](../modal.md) or a [message bar](../message-bar.mdx)
- Donโ€˜t use popover news for system feedback or messages, instead use a [modal](../modal.md) or a [toast message](../toast.md)

### Related patterns

- [Toast message](../toast.md)
- [Modal](../modal.md)
- [Message bar](../messagebar.md)
- [Message bar](../message-bar.mdx)
5 changes: 5 additions & 0 deletions packages/documentation/docs/controls/message-bar.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import DocsCode from './\_message_bar_code.mdx';

# Message bar

<DocsCode />
24 changes: 0 additions & 24 deletions packages/documentation/docs/controls/messagebar.md

This file was deleted.

40 changes: 20 additions & 20 deletions packages/documentation/docs/migration/uxt.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,27 +75,27 @@ If you're facing any other problems, please raise an issue in GitHub [raising an

As some of the components are named differently in Industrial Experience, please consult this list of the most important component name differences to help make your migration easier:

| **User Experience Toolkit** | **Industrial Experience** |
| ------------------------------------------------ | --------------------------------------------------------------------- |
| App bar | [Nav menu](../controls/application-frame/application-menu.md) |
| Badge | [Pill](../controls/pill.md), [chip](../controls/chip.md) |
| Busy indicator | [Spinner](../controls/spinner.md) |
| **User Experience Toolkit** | **Industrial Experience** |
| ------------------------------------------------ |--------------------------------------------------------------------------------------------------------|
| App bar | [Nav menu](../controls/application-frame/application-menu.md) |
| Badge | [Pill](../controls/pill.md), [chip](../controls/chip.md) |
| Busy indicator | [Spinner](../controls/spinner.md) |
| Button<br/>- primary<br/>- secondary<br/>- ghost | [Button](../controls/buttons/button.md)<br/>- primary filled<br/>- primary outline<br/>- primary ghost |
| Card grid | [Layout grid](../controls/layout-grid.md) |
| Container | [Card](../controls/card.md) |
| Dialog | [Modal](../controls/modal.md) |
| Dropzone | [Upload](../controls/upload.md) |
| List | [Event list](../controls/event-list.md) |
| Stepper | [Workflow](../controls/workflow.md) |
| Menu | [Dropdown button](../controls/buttons/dropdown-button.md) |
| Message | [Message bar](../controls/messagebar.md) |
| Notification | [Toast](../controls/toast.md) |
| Pager | [Pagination](../controls/pagination.md) |
| Popover | [Tooltip](../controls/tooltip.md), [dropdown](../controls/dropdown.md) |
| Switch | [Toggle](../controls/toggle.mdx) |
| Context region | [Pane](../controls/panes.md) (inline right) |
| Item region | [Pane](../controls/panes.md) (floating right) |
| Leading region | [Pane](../controls/panes.md) (inline left) |
| Card grid | [Layout grid](../controls/layout-grid.md) |
| Container | [Card](../controls/card.md) |
| Dialog | [Modal](../controls/modal.md) |
| Dropzone | [Upload](../controls/upload.md) |
| List | [Event list](../controls/event-list.md) |
| Stepper | [Workflow](../controls/workflow.md) |
| Menu | [Dropdown button](../controls/buttons/dropdown-button.md) |
| Message | [Message bar](../controls/message-bar.mdx) |
| Notification | [Toast](../controls/toast.md) |
| Pager | [Pagination](../controls/pagination.md) |
| Popover | [Tooltip](../controls/tooltip.md), [dropdown](../controls/dropdown.md) |
| Switch | [Toggle](../controls/toggle.mdx) |
| Context region | [Pane](../controls/panes.md) (inline right) |
| Item region | [Pane](../controls/panes.md) (floating right) |
| Leading region | [Pane](../controls/panes.md) (inline left) |

## System icons

Expand Down
Loading
Loading