Skip to content
This repository has been archived by the owner on Jul 31, 2024. It is now read-only.

Commit

Permalink
FLOW-944 trying out global popover overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
vikas-cldcvr committed Oct 13, 2023
1 parent ea8e5f5 commit 23f951e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
29 changes: 20 additions & 9 deletions packages/flow-core/src/components/f-popover/f-popover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ import { flowElement } from "./../../utils";
import { injectCss } from "@cldcvr/flow-core-config";
injectCss("f-popover", globalStyle);

const overlay = document.createElement("div");
overlay.classList.add("f-overlay");
overlay.dataset.qaOverlay = "true";

// export type FPopoverVariant = "relative" | "absolute";
export type FPopoverPlacement =
| "top"
Expand Down Expand Up @@ -366,16 +370,23 @@ export class FPopover extends FRoot {
}
});
if (this.open) {
const overlay = this.isTooltip
? nothing
: html`<div
class="f-overlay"
data-transparent=${!this.overlay}
data-qa-overlay
@click=${this.overlayClick}
></div>`;
if (!this.isTooltip) {
if (!this.overlay) {
overlay.dataset.transparent = "true";
} else {
delete overlay.dataset.transparent;
}
}
// const overlay = this.isTooltip
// ? nothing
// : html`<div
// class="f-overlay"
// data-transparent=${!this.overlay}
// data-qa-overlay
// @click=${this.overlayClick}
// ></div>`;
this.computePosition(this.isTooltip);
return html`<slot></slot>${overlay} `;
return html`<slot></slot>`;
} else {
if (this.targetElement) {
this.targetElement.style.removeProperty("z-index");
Expand Down
6 changes: 4 additions & 2 deletions stories/flow-core/f-popover.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export const Playground = {
});
};

return html` <f-div height="100px" align="middle-center">
return html` <f-div height="hug-content" direction="column" align="middle-center">
<f-div height="500px"></f-div>
<f-popover
.open=${args.open}
.overlay=${args.overlay}
Expand All @@ -39,12 +40,13 @@ export const Playground = {
?auto-height=${args["auto-height"]}
?close-on-escape=${args["close-on-escape"]}
>
<f-div state="tertiary" padding="medium">
<f-div state="tertiary" direction="column" gap="small" padding="medium">
<f-text>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet enim ut mi
egestas, non efficitur odio varius. Phasellus accumsan pellentesque ex vehicula
tristique.
</f-text>
<f-select .options=${["option1", "option2", "option3"]}></f-select>
</f-div>
</f-popover>
<f-button id="popoverTarget" label="Open" @click=${handlePopover}></f-button>
Expand Down

0 comments on commit 23f951e

Please sign in to comment.