import { storiesOf, html, withKnobs } from '@open-wc/demoing-storybook'; import { css, render } from '@lion/core'; import '@lion/icon/lion-icon.js'; import '@lion/button/lion-button.js'; import { withBottomSheetConfig, withDropdownConfig, withModalDialogConfig } from '../index.js'; import '../lion-overlay.js'; function renderOffline(litHtmlTemplate) { const offlineRenderContainer = document.createElement('div'); render(litHtmlTemplate, offlineRenderContainer); return offlineRenderContainer.firstElementChild; } // Currently toggling while opened doesn't work (see OverlayController) /* let toggledPlacement = 'top'; const togglePlacement = popupController => { const placements = [ 'top-end', 'top', 'top-start', 'right-end', 'right', 'right-start', 'bottom-start', 'bottom', 'bottom-end', 'left-start', 'left', 'left-end', ]; toggledPlacement = placements[(placements.indexOf(toggledPlacement) + 1) % placements.length]; popupController.updatePopperConfig({ togglePlacement }); }; */ const overlayDemoStyle = css` .demo-box { width: 200px; background-color: white; border-radius: 2px; border: 1px solid grey; padding: 8px; } .demo-box_placements { display: flex; flex-direction: column; width: 173px; margin: 0 auto; margin-top: 68px; } lion-overlay { padding: 10px; } .close-button { color: black; font-size: 28px; line-height: 28px; } .demo-box__column { display: flex; flex-direction: column; } .overlay { display: block; position: absolute; font-size: 16px; color: white; background-color: black; border-radius: 4px; padding: 8px; } .demo-popup { padding: 10px; border: 1px solid black; } @media (max-width: 480px) { .overlay { display: none; } } `; storiesOf('Overlay System | Overlay Component', module) .addDecorator(withKnobs) .add( 'Default', () => html`
Important note: Your slot="content" gets moved to global overlay container.
After initialization it is no longer a child of lion-overlay
To close your overlay from some action performed inside the content slot, fire a
close event.
For the overlay to close, it will need to bubble to the content slot (use
bubbles: true. Also composed: true if it needs to traverse shadow
boundaries)
The demo below demonstrates this
Local
${overlay('local')}Global
${overlay()}