import { storiesOf, html } from '@open-wc/demoing-storybook'; import { fixtureSync } from '@open-wc/testing-helpers'; import { css } from '@lion/core'; import { OverlayController } from '../index.js'; const popupDemoStyle = css` .demo-box { width: 200px; height: 40px; background-color: white; border-radius: 2px; border: 1px solid grey; margin: 240px auto 240px 240px; padding: 8px; } .demo-popup { display: block; max-width: 250px; background-color: white; border-radius: 2px; box-shadow: 0 0 6px 0 rgba(0, 0, 0, 0.12), 0 6px 6px 0 rgba(0, 0, 0, 0.24); padding: 8px; } `; storiesOf('Local Overlay System|Local Overlay', module) .add('Basic', () => { const popup = new OverlayController({ placementMode: 'local', hidesOnEsc: true, hidesOnOutsideClick: true, contentNode: fixtureSync(html`
United Kingdom
`), invokerNode: fixtureSync(html` `), }); return html`
In the ${popup.invoker}${popup.content} the weather is nice.
`; }) .add('Change preferred position', () => { const popup = new OverlayController({ placementMode: 'local', hidesOnEsc: true, hidesOnOutsideClick: true, popperConfig: { placement: 'top-end', }, contentNode: fixtureSync(html`
United Kingdom
`), invokerNode: fixtureSync(html` `), }); return html`
In the ${popup.invoker}${popup.content} the weather is nice.
`; }) .add('Single placement parameter', () => { const popup = new OverlayController({ placementMode: 'local', hidesOnEsc: true, hidesOnOutsideClick: true, popperConfig: { placement: 'bottom', }, contentNode: fixtureSync(html`
Supplying placement with a single parameter will assume 'center' for the other.
`), invokerNode: fixtureSync(html` `), }); return html`
${popup.invoker}${popup.content}
`; }) .add('On hover', () => { const popup = new OverlayController({ placementMode: 'local', hidesOnEsc: true, hidesOnOutsideClick: true, popperConfig: { placement: 'bottom', }, contentNode: fixtureSync(html`
United Kingdom
`), invokerNode: fixtureSync(html` `), }); return html`
In the beautiful ${popup.invoker}${popup.content} the weather is nice.
`; }) .add('On an input', () => { const popup = new OverlayController({ placementMode: 'local', contentNode: fixtureSync(html`
United Kingdom
`), invokerNode: fixtureSync(html` popup.show()} @focusout=${() => popup.hide()} /> `), }); return html`
${popup.invoker}${popup.content}
`; }) .add('trapsKeyboardFocus', () => { const popup = new OverlayController({ placementMode: 'local', hidesOnEsc: true, hidesOnOutsideClick: true, trapsKeyboardFocus: true, contentNode: fixtureSync(html`
Anchor
Tabindex
Content editable
`), invokerNode: fixtureSync(html` `), }); return html`
${popup.invoker}${popup.content}
`; });