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

feat(tooltip-base): added options to disable middleware in floatingui #2128

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/tasty-guests-allow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ebay/ebayui-core": minor
---

tooltip-base: added options to disable floating-ui middleware
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
offset,
arrow,
type Placement,
inline,
} from "@floating-ui/dom";
import { pointerStyles } from "./constants";
import type { WithNormalizedProps } from "../../../global";
Expand All @@ -22,6 +23,8 @@ interface TooptipBaseInput {
"render-body"?: Marko.Renderable;
placement?: Placement;
"no-flip"?: boolean;
"not-inline"?: boolean;
"no-shift"?: boolean;
pointer?: keyof typeof pointerStyles;
"on-base-expand"?: (event: { originalEvent: Event }) => void;
"on-base-collapse"?: (event: { originalEvent: Event }) => void;
Expand Down Expand Up @@ -122,8 +125,6 @@ class TooltipBase extends Marko.Component<Input> {
}

updateTip() {
const isTourtip = this.input.type === "tourtip";

computePosition(
this.hostEl as HTMLElement,
this.overlayEl as HTMLElement,
Expand All @@ -133,8 +134,9 @@ class TooltipBase extends Marko.Component<Input> {
pointerStyles[this.input.pointer ?? "bottom"],
middleware: [
offset(this.input.offset || 6),
!this.input.notInline && inline(),
!this.input.noFlip && flip(),
!isTourtip && shift(),
!this.input.noShift && shift(),
arrow({
element: this.arrowEl as HTMLElement,
padding: 20,
Expand Down
2 changes: 2 additions & 0 deletions src/components/ebay-infotip/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ interface InfotipInput extends Omit<Marko.Input<"span">, `on${string}`> {
renderBody?: Marko.Renderable;
} & Iterable<any>;
"no-flip"?: TooltipBaseInput["no-flip"];
"not-inline"?: TooltipBaseInput["not-inline"];
"no-shift"?: TooltipBaseInput["no-shift"];
content: Marko.AttrTag<Marko.Input<"span">>;
"a11y-close-button-text"?: AttrString;
"on-expand"?: () => void;
Expand Down
4 changes: 4 additions & 0 deletions src/components/ebay-infotip/index.marko
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ $ const {
pointer = "bottom",
variant,
noFlip,
noShift,
notInline,
...htmlInput
} = input;

Expand All @@ -25,6 +27,8 @@ $ var classPrefix = !isModal ? "infotip" : "dialog--mini";
type=classPrefix
overlayId:scoped="overlay"
noFlip=noFlip
noShift=noShift
notInline=notInline
offset=input.offset
pointer=input.pointer
placement=input.placement
Expand Down
16 changes: 15 additions & 1 deletion src/components/ebay-infotip/infotip.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,21 @@ export default {
},
noFlip: {
control: { type: "boolean" },
description: "disables flipping tooltip when its offscreen",
description: "disables flipping infotip when its offscreen",
table: {
defaultValue: { summary: "false" },
},
},
noShift: {
control: { type: "boolean" },
description: "disables shifting infotip when its offscreen",
table: {
defaultValue: { summary: "false" },
},
},
notInline: {
control: { type: "boolean" },
description: "disables moving infotip to be inline with content when it is rendered",
table: {
defaultValue: { summary: "false" },
},
Expand Down
2 changes: 2 additions & 0 deletions src/components/ebay-tooltip/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ interface TooltipInput extends Omit<Marko.Input<"span">, `on${string}`> {
pointer?: TooltipBaseInput["pointer"];
placement?: TooltipBaseInput["placement"];
offset?: TooltipBaseInput["offset"];
"not-inline"?: TooltipBaseInput["not-inline"];
"no-shift"?: TooltipBaseInput["no-shift"];
"no-flip"?: TooltipBaseInput["no-flip"];
"on-expand"?: () => void;
"on-collapse"?: () => void;
Expand Down
4 changes: 4 additions & 0 deletions src/components/ebay-tooltip/index.marko
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ $ const {
offset,
placement,
pointer = "bottom",
noShift,
notInline,
noFlip,
...htmlInput
} = input;
Expand All @@ -25,6 +27,8 @@ $ const {
type="tooltip"
overlayId:scoped="overlay"
noFlip=noFlip
notInline=notInline
noShift=noShift
noHover=noHover
pointer=pointer
placement=placement
Expand Down
14 changes: 14 additions & 0 deletions src/components/ebay-tooltip/tooltip.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,20 @@ export default {
defaultValue: { summary: "false" },
},
},
noShift: {
control: { type: "boolean" },
description: "disables shifting tooltip when its offscreen",
table: {
defaultValue: { summary: "false" },
},
},
notInline: {
control: { type: "boolean" },
description: "disables moving tooltip to be inline with content when it is rendered",
table: {
defaultValue: { summary: "false" },
},
},
onCollapse: {
action: "on-collapse",
description: "Triggered on menu collapse",
Expand Down
2 changes: 2 additions & 0 deletions src/components/ebay-tourtip/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ interface TourtipInput extends Omit<Marko.Input<"span">, `on${string}`> {
content?: TooltipOverlayInput["content"];
"a11y-close-text"?: TooltipOverlayInput["a11yCloseText"];
"no-flip"?: TooltipBaseInput["noFlip"];
"not-inline"?: TooltipBaseInput["not-inline"];
"no-shift"?: TooltipBaseInput["no-shift"];
footer?: TooltipOverlayInput["footer"] & {
index?: string;
};
Expand Down
4 changes: 4 additions & 0 deletions src/components/ebay-tourtip/index.marko
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ $ const {
host,
open,
noFlip,
notInline,
noShift = true,
pointer = "bottom",
...htmlInput
} = input;
Expand All @@ -17,6 +19,8 @@ $ const {
key="base"
type="tourtip"
noFlip=noFlip
notInline=notInline
noShift=noShift
pointer=input.pointer
placement=input.placement
offset=input.offset
Expand Down
16 changes: 15 additions & 1 deletion src/components/ebay-tourtip/tourtip.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,21 @@ export default {
},
noFlip: {
control: { type: "boolean" },
description: "disables flipping tooltip when its offscreen",
description: "disables flipping tourtip when its offscreen",
table: {
defaultValue: { summary: "false" },
},
},
noShift: {
control: { type: "boolean" },
description: "disables shifting tourtip when its offscreen",
table: {
defaultValue: { summary: "true" },
},
},
notInline: {
control: { type: "boolean" },
description: "disables moving tourtip to be inline with content when it is rendered",
table: {
defaultValue: { summary: "false" },
},
Expand Down
Loading