From 5701bef6e94155550de88a45f4b24db3f6cde27b Mon Sep 17 00:00:00 2001 From: Cory LaViska Date: Fri, 1 Dec 2023 10:29:37 -0500 Subject: [PATCH] backport 1749 --- cspell.json | 1 + docs/pages/components/popup.md | 125 +++++++++++++++++++ docs/pages/resources/changelog.md | 6 + src/components/menu-item/menu-item.styles.ts | 14 +-- src/components/popup/popup.component.ts | 95 ++++++++++++++ src/components/popup/popup.styles.ts | 20 +++ src/components/tooltip/tooltip.component.ts | 16 ++- src/components/tooltip/tooltip.styles.ts | 2 - src/components/tooltip/tooltip.test.ts | 9 +- 9 files changed, 265 insertions(+), 23 deletions(-) diff --git a/cspell.json b/cspell.json index 2fe43af29..6332d3e86 100644 --- a/cspell.json +++ b/cspell.json @@ -103,6 +103,7 @@ "monospace", "mousedown", "mousemove", + "mouseout", "mouseup", "multiselectable", "nextjs", diff --git a/docs/pages/components/popup.md b/docs/pages/components/popup.md index 1dcd55315..55ce7a54f 100644 --- a/docs/pages/components/popup.md +++ b/docs/pages/components/popup.md @@ -1530,6 +1530,131 @@ const App = () => { }; ``` +### Hover Bridge + +When a gap exists between the anchor and the popup element, this option will add a "hover bridge" that fills the gap using an invisible element. This makes listening for events such as `mouseover` and `mouseout` more sane because the pointer never technically leaves the element. The hover bridge will only be drawn when the popover is active. For demonstration purposes, the bridge in this example is shown in orange. + +```html:preview + + + +``` + +```jsx:react +import { useState } from 'react'; +import WaPopup from '@shoelace-style/shoelace/dist/react/popup'; +import WaRange from '@shoelace-style/shoelace/dist/react/range'; +import WaSwitch from '@shoelace-style/shoelace/dist/react/switch'; +const css = ` + .popup-hover-bridge span[slot='anchor'] { + display: inline-block; + width: 150px; + height: 150px; + border: dashed 2px var(--wa-color-neutral-spot); + margin: 50px; + } + + .popup-hover-bridge .box { + width: 100px; + height: 50px; + background: var(--wa-color-brand-spot); + border-radius: var(--wa-corners-s); + } + + .popup-hover-bridge wa-range { + max-width: 260px; + margin-top: .5rem; + } + + .popup-hover-bridge wa-popup::part(hover-bridge) { + background: tomato; + opacity: .5; + } +`; +const App = () => { + const [hoverBridge, setHoverBridge] = useState(true); + const [distance, setDistance] = useState(10); + const [skidding, setSkidding] = useState(0); + return ( + <> +