diff --git a/packages/components/src/components/notification-banner/notification-banner.tsx b/packages/components/src/components/notification-banner/notification-banner.tsx index bc24798f3e..a6a035453f 100644 --- a/packages/components/src/components/notification-banner/notification-banner.tsx +++ b/packages/components/src/components/notification-banner/notification-banner.tsx @@ -9,9 +9,19 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -import { Component, h, Host, Prop, Element, Method } from '@stencil/core'; +import { + Component, + h, + Host, + Prop, + Element, + Method, + Event, + EventEmitter, +} from '@stencil/core'; import classNames from 'classnames'; import statusNote from '../../utils/status-note'; +import { emitEvent } from '../../utils/utils'; @Component({ tag: 'scale-notification-banner', @@ -28,6 +38,8 @@ export class NotificationBanner { @Prop() autoHide?: boolean = false; @Prop() autoHideDuration?: number = 3000; @Prop() href: string; + /** Fires when the notification banner has been dismissed */ + @Event({ eventName: 'scale-close' }) scaleClose: EventEmitter; hasSlotText?: boolean; hasSlotLink?: boolean; @@ -97,6 +109,7 @@ export class NotificationBanner { close = () => { this.opened = false; + emitEvent(this, 'scaleClose'); }; render() { diff --git a/packages/components/src/components/notification-banner/readme.md b/packages/components/src/components/notification-banner/readme.md index 8e8e7c1dcc..2220acd386 100644 --- a/packages/components/src/components/notification-banner/readme.md +++ b/packages/components/src/components/notification-banner/readme.md @@ -17,6 +17,13 @@ | `variant` | `variant` | | `"error" \| "informational" \| "success" \| "warning"` | `'informational'` | +## Events + +| Event | Description | Type | +| ------------- | ----------------------------------------------------- | ------------------- | +| `scale-close` | Fires when the notification banner has been dismissed | `CustomEvent` | + + ## Methods ### `open() => Promise` diff --git a/packages/components/src/components/notification-message/notification-message.tsx b/packages/components/src/components/notification-message/notification-message.tsx index 4c0f5b416a..ebb6465fe4 100644 --- a/packages/components/src/components/notification-message/notification-message.tsx +++ b/packages/components/src/components/notification-message/notification-message.tsx @@ -9,9 +9,19 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -import { Component, h, Host, Prop, Element, Method } from '@stencil/core'; +import { + Component, + h, + Host, + Prop, + Element, + Method, + Event, + EventEmitter, +} from '@stencil/core'; import classNames from 'classnames'; import statusNote from '../../utils/status-note'; +import { emitEvent } from '../../utils/utils'; @Component({ tag: 'scale-notification-message', @@ -27,6 +37,8 @@ export class NotificationMessage { @Prop({ reflect: true }) opened: boolean; @Prop() autoHide?: boolean = false; @Prop() autoHideDuration?: number = 3000; + /** Fires when the notification message has been dismissed */ + @Event({ eventName: 'scale-close' }) scaleClose: EventEmitter; hasSlotText: boolean; @@ -93,6 +105,7 @@ export class NotificationMessage { close = () => { this.opened = false; + emitEvent(this, 'scaleClose'); }; render() { diff --git a/packages/components/src/components/notification-message/readme.md b/packages/components/src/components/notification-message/readme.md index 3a5ac2e15f..3b5af3389d 100644 --- a/packages/components/src/components/notification-message/readme.md +++ b/packages/components/src/components/notification-message/readme.md @@ -14,6 +14,13 @@ | `variant` | `variant` | | `"error" \| "informational" \| "success" \| "warning"` | `'informational'` | +## Events + +| Event | Description | Type | +| ------------- | ------------------------------------------------------ | ------------------- | +| `scale-close` | Fires when the notification message has been dismissed | `CustomEvent` | + + ## Methods ### `open() => Promise`