import { storiesOf, html } from '@open-wc/demoing-storybook'; import { css } from '@lion/core'; import { overlays, LocalOverlayController } 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; position: absolute; background-color: white; border-radius: 2px; border: 1px solid grey; 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 = overlays.add( new LocalOverlayController({ hidesOnEsc: true, hidesOnOutsideClick: true, contentTemplate: () => html`
United Kingdom
`, invokerTemplate: () => html` `, }), ); return html`
In the ${popup.invoker}${popup.content} the weather is nice.
`; }) .add('Change preferred position', () => { const popup = overlays.add( new LocalOverlayController({ hidesOnEsc: true, hidesOnOutsideClick: true, placement: 'top right', contentTemplate: () => html`
United Kingdom
`, invokerTemplate: () => html` `, }), ); return html`
In the ${popup.invoker}${popup.content} the weather is nice.
`; }) .add('Single placement parameter', () => { const popup = overlays.add( new LocalOverlayController({ hidesOnEsc: true, hidesOnOutsideClick: true, placement: 'bottom', contentTemplate: () => html`
Supplying placement with a single parameter will assume 'center' for the other.
`, invokerTemplate: () => html` `, }), ); return html`
${popup.invoker}${popup.content}
`; }) .add('On hover', () => { const popup = overlays.add( new LocalOverlayController({ hidesOnEsc: true, hidesOnOutsideClick: true, placement: 'bottom', contentTemplate: () => html`
United Kingdom
`, invokerTemplate: () => html` `, }), ); return html`
In the beautiful ${popup.invoker}${popup.content} the weather is nice.
`; }) .add('On an input', () => { const popup = overlays.add( new LocalOverlayController({ contentTemplate: () => html`
United Kingdom
`, invokerTemplate: () => html` popup.show()} @blur=${() => popup.hide()} /> `, }), ); return html`
${popup.invoker}${popup.content}
`; }) .add('On toggle', () => { const popup = overlays.add( new LocalOverlayController({ hidesOnEsc: true, hidesOnOutsideClick: true, contentTemplate: () => html`
United Kingdom
`, invokerTemplate: () => html` `, }), ); return html`
`; }) .add('trapsKeyboardFocus', () => { const popup = overlays.add( new LocalOverlayController({ hidesOnEsc: true, hidesOnOutsideClick: true, trapsKeyboardFocus: true, contentTemplate: () => html`
Anchor
Tabindex
Content editable
`, invokerTemplate: () => html` `, }), ); return html`
${popup.invoker}${popup.content}
`; });