From 57a3c04873d2f7e6cc879f4d129a10d7d863a8f7 Mon Sep 17 00:00:00 2001 From: Joren Broekema Date: Wed, 27 Nov 2019 08:46:51 +0100 Subject: [PATCH] feat(overlays): add before-show event to OverlayMixin --- packages/overlays/src/OverlayMixin.js | 3 +++ packages/overlays/stories/index.stories.js | 29 ++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/packages/overlays/src/OverlayMixin.js b/packages/overlays/src/OverlayMixin.js index 552775074..f639abe11 100644 --- a/packages/overlays/src/OverlayMixin.js +++ b/packages/overlays/src/OverlayMixin.js @@ -36,6 +36,9 @@ export const OverlayMixin = dedupeMixin( } set opened(show) { + if (show) { + this.dispatchEvent(new Event('before-show')); + } this._opened = show; // mainly captured for sync on connectedCallback if (this._overlayCtrl) { this.__syncOpened(); diff --git a/packages/overlays/stories/index.stories.js b/packages/overlays/stories/index.stories.js index e33c82de1..1c7b2cde9 100644 --- a/packages/overlays/stories/index.stories.js +++ b/packages/overlays/stories/index.stories.js @@ -323,6 +323,35 @@ storiesOf('Overlay System | Overlay as a WC', module) `; }) + .add( + 'Responsive switching', + () => html` + + { + if (window.innerWidth >= 600) { + e.target.config = { ...withModalDialogConfig() }; + } else { + e.target.config = { ...withBottomSheetConfig() }; + } + }} + > + Overlay +
+ Hello! You can close this notification here: + + e.target.dispatchEvent(new Event('demo-overlay-close', { bubbles: true }))} + >тип +
+
+ `, + ) .add('On hover', () => { const popup = renderOffline(html`