Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DSS-491 - optimize overlay #129

Draft
wants to merge 47 commits into
base: feature/popover
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
2cb7083
feat: add PdsPopover
ju-Skinner Jan 23, 2024
84659fb
chore(pds-popover): update function names to not duplicate
QuintonJason Jan 24, 2024
0c9e64f
feat(pds-list-options): add pds list options and pds list components …
QuintonJason Sep 6, 2023
7114104
chore(pds-popover): update list option in list
QuintonJason Sep 6, 2023
006990d
docs(popover): update copy and section title
QuintonJason Sep 6, 2023
d60364b
docs(pds-popover): clean up demo code
QuintonJason Sep 6, 2023
cf0c6b1
test(pds-popover): add units tests
QuintonJason Sep 8, 2023
15d826e
test(list-options): add specs
QuintonJason Sep 8, 2023
0183eb4
chore(list-options): add keyboard support
QuintonJason Sep 11, 2023
24f5436
docs(list-options): update stories
QuintonJason Sep 11, 2023
105d4ca
chore(list-options): remove list options and put into own pr and jira…
QuintonJason Sep 11, 2023
c44915a
chore(readme): auto correcting of readme files
QuintonJason Sep 11, 2023
a904954
docs(popover): add story with avatar dropdown as trigger
QuintonJason Sep 11, 2023
c598248
docs(popover): update default props and clean up copy
QuintonJason Sep 11, 2023
6f92af9
docs(popover): add decorator to demos and add id to popover content
QuintonJason Dec 1, 2023
6a06a6f
chore(input): revert readme to next version
QuintonJason Dec 1, 2023
dbc7aa6
chore(input): revert readme to next version
QuintonJason Dec 1, 2023
d8e38c5
chore(input): revert readme to next version
QuintonJason Dec 1, 2023
5f559ca
refactor(popover): move class interpolation outside of return
QuintonJason Dec 4, 2023
4026da9
refactor(popover): extract placement to a type
QuintonJason Dec 4, 2023
2fdde28
test(popover): add has-arrow test
QuintonJason Dec 4, 2023
88a4b73
test(popover): write e2e tests
QuintonJason Dec 4, 2023
b4d8f94
test(popover): add new line
QuintonJason Dec 4, 2023
afe9967
docs(pds-popover): updated default props
QuintonJason Dec 13, 2023
4aa469f
chore(pds-popover): add floating ui
QuintonJason Dec 19, 2023
ccb231a
feat(pds-popover): implement floating ui components
QuintonJason Dec 19, 2023
b3e6a6e
style(pds-popover): remove css arrow
QuintonJason Dec 19, 2023
ea6dc37
chore(pds-popover): add hoisted prop and begin fixed position functio…
QuintonJason Dec 19, 2023
046455a
chore(pds-popover): add autoupdate for fixed positioning popovers
QuintonJason Dec 19, 2023
40deb71
chore(pds-popover): fix storybook canvas overflow issue
QuintonJason Dec 20, 2023
2a4a3f7
chore(pds-popover): update stories and props to customizable popover
QuintonJason Dec 20, 2023
6946ec5
chore(floating-ui): add floatingui core and update tooltip use popove…
QuintonJason Dec 20, 2023
3146228
style(popover): add parts styles and update docs
QuintonJason Dec 20, 2023
4911da8
docs(pds-popover): update docs
QuintonJason Dec 20, 2023
1f5da1d
style(pds-popover): add exportparts to popover for style customizatio…
QuintonJason Dec 22, 2023
212509c
test(pds-popover): add spec and e2e tests
QuintonJason Dec 22, 2023
a1af8e6
chore(pds-popover): update story props
QuintonJason Dec 22, 2023
e9708fc
chore(pds-popover): added missing file
QuintonJason Dec 22, 2023
1fcf24e
chore(popover): remove comments and update copy
QuintonJason Dec 22, 2023
1c833d0
style(pds-popover): add more resilient width css statements
QuintonJason Jan 22, 2024
7b846d5
chore(pds-popover): align work after rebase
QuintonJason Jan 24, 2024
6879a7c
docs(pds-tooltip): clean up docs
QuintonJason Jan 24, 2024
0699a45
test(pds-tooltip): revisit tests
QuintonJason Jan 24, 2024
71ecc1f
chore(pds-popover): change private vars to props
QuintonJason Feb 7, 2024
935ce6f
chore(floating-ui): move deps to core package json
QuintonJason Feb 7, 2024
4c82624
test(pds-tooltip): fix tooltip test
QuintonJason Feb 8, 2024
95cbef9
chore(pds-popover): change props to private for overlay vars
QuintonJason Feb 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions libs/core/.storybook/preview-head.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@
<script nomodule src="/pine-core/index.esm.js"></script>

<link rel="stylesheet" href="/pine-core/pine-core.css" />

<style>
.docs-story div[scale] {
/* This is needed to prevent the storybook canvases from cropping
components meant to overflow */
transform: none !important;
}
</style>
2 changes: 2 additions & 0 deletions libs/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
"test.watch": "stencil test --spec --e2e --watchAll --coverage"
},
"dependencies": {
"@floating-ui/dom": "^1.5.3",
"@floating-ui/core": "^1.5.2",
"@pine-ds/icons": "^3.4.0",
"@stencil/core": "^4.8.1",
"sortablejs": "^1.15.0"
Expand Down
167 changes: 143 additions & 24 deletions libs/core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
* It contains typing information for all components that exist in this project.
*/
import { HTMLStencilElement, JSXBase } from "@stencil/core/internal";
import { OverlayPlacementType } from "./utils/types";
import { TextareaChangeEventDetail } from "./components/pds-textarea/textarea-interface";
export { OverlayPlacementType } from "./utils/types";
export { TextareaChangeEventDetail } from "./components/pds-textarea/textarea-interface";
export namespace Components {
interface PdsAvatar {
Expand Down Expand Up @@ -310,6 +312,52 @@ export namespace Components {
*/
"variant": 'inline' | 'plain';
}
interface PdsPopover {
/**
* A unique identifier used for the underlying component id attribute.
*/
"componentId": string;
/**
* Determines whether or not the popover has an arrow
* @defaultValue false
*/
"hasArrow"?: boolean;
/**
* Hides the popover by disabling the opened property
*/
"hidePdsPopover": () => Promise<void>;
/**
* Determines how the popover is positioned relative to the trigger element. By default, the popover will use `absolute` positioning, which allows the popover to scroll with the page. Setting this to `fixed` handles most used. However, if the trigger element is within a container that has `overflow: hidden` set, the popover will not be able to escape the container and get clipped. In this case, you can set the `hoisted` property to `true` to use `fixed` positioning instead. Be aware that this is less performant, as it requires recalculating the popover position on scroll. Only use this option if you need it.
* @defaultValue false
*/
"hoisted"?: boolean;
/**
* Sets the offset distance(in pixels) between the popover and the trigger element
*/
"offset"?: number;
/**
* Determines whether or not the popover is visible
* @defaultValue false
*/
"opened": boolean;
/**
* Sets the padding(in pixels) of the popover content element
*/
"padding"?: number;
/**
* Determines the preferred position of the popover
* @defaultValue "right"
*/
"placement": OverlayPlacementType;
/**
* Shows the popover by enabling the opened property
*/
"showPdsPopover": () => Promise<void>;
/**
* Toggles the popover visibility on click
*/
"togglePdsPopover": () => Promise<void>;
}
interface PdsProgress {
/**
* Determines whether or not progress is animated.
Expand Down Expand Up @@ -618,32 +666,34 @@ export namespace Components {
* Hides the tooltip by disabling the opened property
*/
"hideTooltip": () => Promise<void>;
/**
* Determines how the popover is positioned relative to the trigger element. By default, the popover will use `absolute` positioning, which allows the popover to scroll with the page. Setting this to `fixed` handles most used. However, if the trigger element is within a container that has `overflow: hidden` set, the popover will not be able to escape the container and get clipped. In this case, you can set the `hoisted` property to `true` to use `fixed` positioning instead. Be aware that this is less performant, as it requires recalculating the popover position on scroll. Only use this option if you need it.
* @defaultValue false
*/
"hoisted"?: boolean;
/**
* Enable this option when using the content slot
* @defaultValue false
*/
"htmlContent": boolean;
/**
* Sets the offset distance(in pixels) between the popover and the trigger element
*/
"offset"?: number;
/**
* Determines whether or not the tooltip is visible
* @defaultValue false
*/
"opened": boolean;
/**
* Sets the padding(in pixels) of the popover content element
*/
"padding"?: number;
/**
* Determines the preferred position of the tooltip
* @defaultValue "right"
*/
"placement": 'top'
| 'top-start'
| 'top-end'
| 'right'
| 'right-start'
| 'right-end'
| 'bottom'
| 'bottom-start'
| 'bottom-end'
| 'left'
| 'left-start'
| 'left-end';
"placement": OverlayPlacementType;
/**
* Shows the tooltip by enabling the opened property
*/
Expand All @@ -666,6 +716,10 @@ export interface PdsInputCustomEvent<T> extends CustomEvent<T> {
detail: T;
target: HTMLPdsInputElement;
}
export interface PdsPopoverCustomEvent<T> extends CustomEvent<T> {
detail: T;
target: HTMLPdsPopoverElement;
}
export interface PdsRadioCustomEvent<T> extends CustomEvent<T> {
detail: T;
target: HTMLPdsRadioElement;
Expand Down Expand Up @@ -797,6 +851,24 @@ declare global {
prototype: HTMLPdsLinkElement;
new (): HTMLPdsLinkElement;
};
interface HTMLPdsPopoverElementEventMap {
"pdsPopoverHide": any;
"pdsPopoverShow": any;
}
interface HTMLPdsPopoverElement extends Components.PdsPopover, HTMLStencilElement {
addEventListener<K extends keyof HTMLPdsPopoverElementEventMap>(type: K, listener: (this: HTMLPdsPopoverElement, ev: PdsPopoverCustomEvent<HTMLPdsPopoverElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
removeEventListener<K extends keyof HTMLPdsPopoverElementEventMap>(type: K, listener: (this: HTMLPdsPopoverElement, ev: PdsPopoverCustomEvent<HTMLPdsPopoverElementEventMap[K]>) => any, options?: boolean | EventListenerOptions): void;
removeEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
}
var HTMLPdsPopoverElement: {
prototype: HTMLPdsPopoverElement;
new (): HTMLPdsPopoverElement;
};
interface HTMLPdsProgressElement extends Components.PdsProgress, HTMLStencilElement {
}
var HTMLPdsProgressElement: {
Expand Down Expand Up @@ -992,6 +1064,7 @@ declare global {
"pds-image": HTMLPdsImageElement;
"pds-input": HTMLPdsInputElement;
"pds-link": HTMLPdsLinkElement;
"pds-popover": HTMLPdsPopoverElement;
"pds-progress": HTMLPdsProgressElement;
"pds-radio": HTMLPdsRadioElement;
"pds-sortable": HTMLPdsSortableElement;
Expand Down Expand Up @@ -1329,6 +1402,48 @@ declare namespace LocalJSX {
*/
"variant"?: 'inline' | 'plain';
}
interface PdsPopover {
/**
* A unique identifier used for the underlying component id attribute.
*/
"componentId"?: string;
/**
* Determines whether or not the popover has an arrow
* @defaultValue false
*/
"hasArrow"?: boolean;
/**
* Determines how the popover is positioned relative to the trigger element. By default, the popover will use `absolute` positioning, which allows the popover to scroll with the page. Setting this to `fixed` handles most used. However, if the trigger element is within a container that has `overflow: hidden` set, the popover will not be able to escape the container and get clipped. In this case, you can set the `hoisted` property to `true` to use `fixed` positioning instead. Be aware that this is less performant, as it requires recalculating the popover position on scroll. Only use this option if you need it.
* @defaultValue false
*/
"hoisted"?: boolean;
/**
* Sets the offset distance(in pixels) between the popover and the trigger element
*/
"offset"?: number;
/**
* Emitted after a popover is closed
*/
"onPdsPopoverHide"?: (event: PdsPopoverCustomEvent<any>) => void;
/**
* Emitted after a popover is shown
*/
"onPdsPopoverShow"?: (event: PdsPopoverCustomEvent<any>) => void;
/**
* Determines whether or not the popover is visible
* @defaultValue false
*/
"opened"?: boolean;
/**
* Sets the padding(in pixels) of the popover content element
*/
"padding"?: number;
/**
* Determines the preferred position of the popover
* @defaultValue "right"
*/
"placement"?: OverlayPlacementType;
}
interface PdsProgress {
/**
* Determines whether or not progress is animated.
Expand Down Expand Up @@ -1658,11 +1773,20 @@ declare namespace LocalJSX {
* @defaultValue true
*/
"hasArrow"?: boolean;
/**
* Determines how the popover is positioned relative to the trigger element. By default, the popover will use `absolute` positioning, which allows the popover to scroll with the page. Setting this to `fixed` handles most used. However, if the trigger element is within a container that has `overflow: hidden` set, the popover will not be able to escape the container and get clipped. In this case, you can set the `hoisted` property to `true` to use `fixed` positioning instead. Be aware that this is less performant, as it requires recalculating the popover position on scroll. Only use this option if you need it.
* @defaultValue false
*/
"hoisted"?: boolean;
/**
* Enable this option when using the content slot
* @defaultValue false
*/
"htmlContent"?: boolean;
/**
* Sets the offset distance(in pixels) between the popover and the trigger element
*/
"offset"?: number;
/**
* Emitted after a tooltip is closed
*/
Expand All @@ -1676,22 +1800,15 @@ declare namespace LocalJSX {
* @defaultValue false
*/
"opened"?: boolean;
/**
* Sets the padding(in pixels) of the popover content element
*/
"padding"?: number;
/**
* Determines the preferred position of the tooltip
* @defaultValue "right"
*/
"placement"?: 'top'
| 'top-start'
| 'top-end'
| 'right'
| 'right-start'
| 'right-end'
| 'bottom'
| 'bottom-start'
| 'bottom-end'
| 'left'
| 'left-start'
| 'left-end';
"placement"?: OverlayPlacementType;
}
interface IntrinsicElements {
"pds-avatar": PdsAvatar;
Expand All @@ -1703,6 +1820,7 @@ declare namespace LocalJSX {
"pds-image": PdsImage;
"pds-input": PdsInput;
"pds-link": PdsLink;
"pds-popover": PdsPopover;
"pds-progress": PdsProgress;
"pds-radio": PdsRadio;
"pds-sortable": PdsSortable;
Expand Down Expand Up @@ -1734,6 +1852,7 @@ declare module "@stencil/core" {
"pds-image": LocalJSX.PdsImage & JSXBase.HTMLAttributes<HTMLPdsImageElement>;
"pds-input": LocalJSX.PdsInput & JSXBase.HTMLAttributes<HTMLPdsInputElement>;
"pds-link": LocalJSX.PdsLink & JSXBase.HTMLAttributes<HTMLPdsLinkElement>;
"pds-popover": LocalJSX.PdsPopover & JSXBase.HTMLAttributes<HTMLPdsPopoverElement>;
"pds-progress": LocalJSX.PdsProgress & JSXBase.HTMLAttributes<HTMLPdsProgressElement>;
"pds-radio": LocalJSX.PdsRadio & JSXBase.HTMLAttributes<HTMLPdsRadioElement>;
"pds-sortable": LocalJSX.PdsSortable & JSXBase.HTMLAttributes<HTMLPdsSortableElement>;
Expand Down
72 changes: 72 additions & 0 deletions libs/core/src/components/pds-popover/pds-popover.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
:host {
--popover-background-color: var(--pine-color-base-white);
--popover-color: var(--pine-color-neutral-charcoal-400);
--popover-arrow-color: var(--popover-background-color);

display: inline-block;
position: relative;

&::part(content) {
background-color: var(--popover-background-color);
color: var(--popover-color);
}
}

div {
// These custom props are not reachable
--box-shadow: var(--pine-box-shadow-md);
--arrow-size: 8px;
--arrow-offset: 14px;

--overlay-border-radius: var(--pine-border-radius-md);
--overlay-font-size: var(--pine-font-size-body-sm);
--overlay-line-height: var(--pine-line-height-sm);
--overlay-width: 240px;
--overlay-padding: var(--pine-spacing-xs) 12px;

--arrow-pointing-down: var(--arrow-size) var(--arrow-size) 0;
--arrow-pointing-to-the-right: var(--arrow-size) 0 var(--arrow-size) var(--arrow-size);
--arrow-pointing-to-the-left: var(--arrow-size) var(--arrow-size) var(--arrow-size) 0;
--arrow-pointing-up: 0 var(--arrow-size) var(--arrow-size);
}

.pds-popover__content {
border-radius: var(--overlay-border-radius);
box-shadow: var(--box-shadow);
color: var(--popover-content-color);
display: none;
font-size: var(--overlay-font-size);
line-height: var(--overlay-line-height);
max-width: var(--overlay-width);
min-width: var(--overlay-width);
padding: var(--overlay-padding);
position: absolute;
/* add three width variations needed due to position values */
width: var(--overlay-width);

.pds-popover--hoisted & {
position: fixed;
}

.pds-popover--is-open & {
display: block;
z-index: 1000;
}

:host(.pds-popover--has-html-content) & {
width: auto;
}
}

.pds-popover__trigger {
display: inline-block;
}

.pds-popover__arrow {
background-color: var(--popover-arrow-color);
height: var(--arrow-size);
position: absolute;
transform: rotate(45deg);
width: var(--arrow-size);
z-index: -1;
}
Loading
Loading