Skip to content

Commit 7186c69

Browse files
authored
feat: add className option to Notification.show (#10727)
1 parent bce41f2 commit 7186c69

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

packages/notification/src/vaadin-notification-mixin.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,9 @@ export const NotificationMixin = (superClass) =>
229229
if (options && options.theme) {
230230
notification.setAttribute('theme', options.theme);
231231
}
232+
if (options && options.className) {
233+
notification.overlayClass = options.className;
234+
}
232235
notification.renderer = renderer;
233236
document.body.appendChild(notification);
234237
notification.opened = true;

packages/notification/src/vaadin-notification.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export * from './vaadin-notification-mixin.js';
1616

1717
export interface ShowOptions {
1818
assertive?: boolean;
19+
className?: string;
1920
duration?: number;
2021
position?: NotificationPosition;
2122
theme?: string;
@@ -105,8 +106,9 @@ declare class Notification extends NotificationMixin(ElementMixin(HTMLElement))
105106
* ```ts
106107
* {
107108
* assertive?: boolean
108-
* position?: string
109+
* className?: string
109110
* duration?: number
111+
* position?: string
110112
* theme?: string
111113
* }
112114
* ```

packages/notification/test/statichelper.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ describe('static helpers', () => {
5252
expect(notification.getAttribute('theme')).to.equal('error');
5353
});
5454

55+
it('show should set the overlayClass from className option', async () => {
56+
const notification = Notification.show('Hello world', { className: 'my-custom-class' });
57+
await nextFrame();
58+
expect(notification.overlayClass).to.equal('my-custom-class');
59+
expect(notification._card.classList.contains('my-custom-class')).to.be.true;
60+
});
61+
5562
it('show should work with a duration of zero', async () => {
5663
const notification = Notification.show('Hello world', { duration: 0 });
5764
await nextFrame();

0 commit comments

Comments
 (0)