feat(overlays): add before-show event to OverlayMixin
This commit is contained in:
parent
45f557183d
commit
57a3c04873
2 changed files with 32 additions and 0 deletions
|
|
@ -36,6 +36,9 @@ export const OverlayMixin = dedupeMixin(
|
||||||
}
|
}
|
||||||
|
|
||||||
set opened(show) {
|
set opened(show) {
|
||||||
|
if (show) {
|
||||||
|
this.dispatchEvent(new Event('before-show'));
|
||||||
|
}
|
||||||
this._opened = show; // mainly captured for sync on connectedCallback
|
this._opened = show; // mainly captured for sync on connectedCallback
|
||||||
if (this._overlayCtrl) {
|
if (this._overlayCtrl) {
|
||||||
this.__syncOpened();
|
this.__syncOpened();
|
||||||
|
|
|
||||||
|
|
@ -323,6 +323,35 @@ storiesOf('Overlay System | Overlay as a WC', module)
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
})
|
})
|
||||||
|
.add(
|
||||||
|
'Responsive switching',
|
||||||
|
() => html`
|
||||||
|
<style>
|
||||||
|
${overlayDemoStyle}
|
||||||
|
</style>
|
||||||
|
<lion-demo-overlay
|
||||||
|
.config=${{ ...withBottomSheetConfig() }}
|
||||||
|
@before-show=${e => {
|
||||||
|
if (window.innerWidth >= 600) {
|
||||||
|
e.target.config = { ...withModalDialogConfig() };
|
||||||
|
} else {
|
||||||
|
e.target.config = { ...withBottomSheetConfig() };
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<lion-button slot="invoker">Overlay</lion-button>
|
||||||
|
<div slot="content" class="overlay">
|
||||||
|
Hello! You can close this notification here:
|
||||||
|
<lion-button
|
||||||
|
class="close-button"
|
||||||
|
@click=${e =>
|
||||||
|
e.target.dispatchEvent(new Event('demo-overlay-close', { bubbles: true }))}
|
||||||
|
>⨯</lion-button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</lion-demo-overlay>
|
||||||
|
`,
|
||||||
|
)
|
||||||
.add('On hover', () => {
|
.add('On hover', () => {
|
||||||
const popup = renderOffline(html`
|
const popup = renderOffline(html`
|
||||||
<lion-demo-overlay
|
<lion-demo-overlay
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue