-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
experiment: add LitElement based version of vaadin-notification (#8084)
- Loading branch information
1 parent
27b95d6
commit f7b2a1e
Showing
27 changed files
with
215 additions
and
41 deletions.
There are no files selected for viewing
This file contains 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,129 @@ | ||
/** | ||
* @license | ||
* Copyright (c) 2017 - 2024 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
*/ | ||
import { css, html, LitElement } from 'lit'; | ||
import { defineCustomElement } from '@vaadin/component-base/src/define.js'; | ||
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js'; | ||
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js'; | ||
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js'; | ||
import { NotificationContainerMixin, NotificationMixin } from './vaadin-notification-mixin.js'; | ||
import { notificationCardStyles, notificationContainerStyles } from './vaadin-notification-styles.js'; | ||
|
||
/** | ||
* An element used internally by `<vaadin-notification>`. Not intended to be used separately. | ||
* | ||
* @customElement | ||
* @extends HTMLElement | ||
* @mixes NotificationContainerMixin | ||
* @mixes ElementMixin | ||
* @mixes ThemableMixin | ||
* @private | ||
*/ | ||
class NotificationContainer extends NotificationContainerMixin(ElementMixin(ThemableMixin(PolylitMixin(LitElement)))) { | ||
static get styles() { | ||
return notificationContainerStyles; | ||
} | ||
|
||
render() { | ||
return html` | ||
<div region="top-stretch"><slot name="top-stretch"></slot></div> | ||
<div region-group="top"> | ||
<div region="top-start"><slot name="top-start"></slot></div> | ||
<div region="top-center"><slot name="top-center"></slot></div> | ||
<div region="top-end"><slot name="top-end"></slot></div> | ||
</div> | ||
<div region="middle"><slot name="middle"></slot></div> | ||
<div region-group="bottom"> | ||
<div region="bottom-start"><slot name="bottom-start"></slot></div> | ||
<div region="bottom-center"><slot name="bottom-center"></slot></div> | ||
<div region="bottom-end"><slot name="bottom-end"></slot></div> | ||
</div> | ||
<div region="bottom-stretch"><slot name="bottom-stretch"></slot></div> | ||
`; | ||
} | ||
|
||
static get is() { | ||
return 'vaadin-notification-container'; | ||
} | ||
} | ||
|
||
/** | ||
* An element used internally by `<vaadin-notification>`. Not intended to be used separately. | ||
* | ||
* @customElement | ||
* @extends HTMLElement | ||
* @mixes ThemableMixin | ||
* @mixes ElementMixin | ||
* @private | ||
*/ | ||
class NotificationCard extends ElementMixin(ThemableMixin(PolylitMixin(LitElement))) { | ||
static get styles() { | ||
return notificationCardStyles; | ||
} | ||
|
||
render() { | ||
return html` | ||
<div part="overlay"> | ||
<div part="content"> | ||
<slot></slot> | ||
</div> | ||
</div> | ||
`; | ||
} | ||
|
||
static get is() { | ||
return 'vaadin-notification-card'; | ||
} | ||
|
||
/** @protected */ | ||
ready() { | ||
super.ready(); | ||
this.setAttribute('role', 'alert'); | ||
} | ||
} | ||
|
||
/** | ||
* LitElement based version of `<vaadin-notification>` web component. | ||
* | ||
* ## Disclaimer | ||
* | ||
* This component is an experiment and not yet a part of Vaadin platform. | ||
* There is no ETA regarding specific Vaadin version where it'll land. | ||
* Feel free to try this code in your apps as per Apache 2.0 license. | ||
*/ | ||
class Notification extends NotificationMixin(ElementMixin(ThemableMixin(PolylitMixin(LitElement)))) { | ||
static get styles() { | ||
return css` | ||
:host { | ||
display: none !important; | ||
} | ||
`; | ||
} | ||
|
||
render() { | ||
return html` | ||
<vaadin-notification-card | ||
theme="${this._theme || ''}" | ||
aria-live="${this.__computeAriaLive(this.assertive)}" | ||
></vaadin-notification-card> | ||
`; | ||
} | ||
|
||
static get is() { | ||
return 'vaadin-notification'; | ||
} | ||
|
||
/** | ||
* Fired when the notification is closed. | ||
* | ||
* @event closed | ||
*/ | ||
} | ||
|
||
defineCustomElement(NotificationContainer); | ||
defineCustomElement(NotificationCard); | ||
defineCustomElement(Notification); | ||
|
||
export { Notification }; |
This file contains 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 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,2 @@ | ||
import '../vaadin-lit-notification.js'; | ||
import './animation.common.js'; |
This file contains 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,2 @@ | ||
import '../vaadin-notification.js'; | ||
import './animation.common.js'; |
This file contains 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 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,2 @@ | ||
import '../vaadin-lit-notification.js'; | ||
import './lit.common.js'; |
This file contains 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,2 @@ | ||
import '../vaadin-notification.js'; | ||
import './lit.common.js'; |
2 changes: 2 additions & 0 deletions
2
packages/notification/test/lit-renderer-directives-lit.test.js
This file contains 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,2 @@ | ||
import '../vaadin-lit-notification.js'; | ||
import './lit-renderer-directives.common.js'; |
2 changes: 2 additions & 0 deletions
2
packages/notification/test/lit-renderer-directives-polymer.test.js
This file contains 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,2 @@ | ||
import '../vaadin-notification.js'; | ||
import './lit-renderer-directives.common.js'; |
1 change: 0 additions & 1 deletion
1
...tion/test/lit-renderer-directives.test.js → ...on/test/lit-renderer-directives.common.js
This file contains 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
6 changes: 3 additions & 3 deletions
6
packages/notification/test/lit.test.js → packages/notification/test/lit.common.js
This file contains 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 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,3 @@ | ||
import './not-animated-styles.js'; | ||
import '../vaadin-lit-notification.js'; | ||
import './multiple.common.js'; |
This file contains 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,3 @@ | ||
import './not-animated-styles.js'; | ||
import '../vaadin-notification.js'; | ||
import './multiple.common.js'; |
14 changes: 0 additions & 14 deletions
14
packages/notification/test/multiple.test.js → ...ages/notification/test/multiple.common.js
This file contains 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 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,2 @@ | ||
import '../vaadin-lit-notification.js'; | ||
import './notification.common.js'; |
This file contains 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,2 @@ | ||
import '../vaadin-notification.js'; | ||
import './notification.common.js'; |
This file contains 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 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,2 @@ | ||
import '../vaadin-lit-notification.js'; | ||
import './renderer.common.js'; |
This file contains 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,2 @@ | ||
import '../vaadin-notification.js'; | ||
import './renderer.common.js'; |
6 changes: 3 additions & 3 deletions
6
packages/notification/test/renderer.test.js → ...ages/notification/test/renderer.common.js
This file contains 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 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,2 @@ | ||
import '../vaadin-lit-notification.js'; | ||
import './statichelper.common.js'; |
This file contains 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,2 @@ | ||
import '../vaadin-notification.js'; | ||
import './statichelper.common.js'; |
Oops, something went wrong.