import { storiesOf, html, withKnobs, object } from '@open-wc/demoing-storybook'; import { css } from '@lion/core'; import '@lion/icon/lion-icon.js'; import '@lion/button/lion-button.js'; import '../lion-dialog.js'; const dialogDemoStyle = 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-dialog { padding: 10px; } .close-button { color: black; font-size: 28px; line-height: 28px; } .demo-box__column { display: flex; flex-direction: column; } .dialog { display: block; position: absolute; font-size: 16px; color: white; background-color: black; border-radius: 4px; padding: 8px; } @media (max-width: 480px) { .dialog { display: none; } } `; storiesOf('Overlays Specific WC | Dialog', module) .addDecorator(withKnobs) .add( 'Button dialog', () => html`

Important note: Your slot="content" gets moved to global overlay container. After initialization it is no longer a child of lion-dialog

To close your dialog from some action performed inside the content slot, fire a close event.

For the dialog 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

Dialog
Hello! You can close this notification here: e.target.dispatchEvent(new Event('dialog-close', { bubbles: true }))} >⨯
`, ) .add('Custom configuration', () => { const dialog = placement => html` Dialog ${placement}
Hello! You can close this notification here: e.target.dispatchEvent(new Event('dialog-close', { bubbles: true }))} >⨯
`; return html`
${dialog('center')} ${dialog('top-left')} ${dialog('top-right')} ${dialog('bottom-left')} ${dialog('bottom-right')}
`; }) .add('Toggle placement with knobs', () => { const dialog = html` Dialog
Hello! You can close this notification here: e.target.dispatchEvent(new Event('dialog-close', { bubbles: true }))} >⨯
`; return html`
${dialog}
`; });