`;
})
.add('Override the popper config', () => {
let popup;
const invokerNode = document.createElement('button');
invokerNode.innerHTML = 'UK';
invokerNode.addEventListener('click', () => popup.toggle());
popup = overlays.add(
new LocalOverlayController({
hidesOnEsc: true,
popperConfig: {
placement: 'bottom-start',
positionFixed: true,
modifiers: {
keepTogether: {
enabled: true /* Prevents detachment of content element from reference element */,
},
preventOverflow: {
enabled: false /* disables shifting/sliding behavior on secondary axis */,
boundariesElement: 'viewport',
padding: 32 /* when enabled, this is the viewport-margin for shifting/sliding */,
},
flip: {
boundariesElement: 'viewport',
padding: 16 /* viewport-margin for flipping on primary axis */,
},
offset: {
enabled: true,
offset: `0, 16px` /* horizontal and vertical margin (distance between popper and referenceElement) */,
},
},
},
contentTemplate: () =>
html`
United Kingdom
`,
invokerNode,
}),
);
return html`
The API is aligned with Popper.js, visit their documentation for more information:
Popper.js Docs
${invokerNode} ${popup.content}
`;
});
/* TODO: Add this when we have a feature in place that adds scrollbars / overflow when no space is available */
/* .add('Space not available', () => {
let popup;
const invokerNode = document.createElement('button');
invokerNode.innerHTML = 'UK';
invokerNode.addEventListener('click', () => popup.toggle());
let popup = overlays.add(
new LocalOverlayController({
hidesOnEsc: true,
contentTemplate: () => html`
Toggle the placement of this overlay with the buttons. Since there is not enough space
available on the vertical center or the top for this popup, the popup will get
displayed on the available space on the bottom. Try dragging the viewport to
increase/decrease space see the behavior of this.