Files
deepseek-harness/packages/client/ui-primitives/src/HoverCard.module.css
T
LegGasai 1d200479dc refactor(primitives): place compact hover cards by CSS anchor positioning
The compact card's side and bottom hold were computed in script from the
window size and the anchor's rect, measured again after the card mounted, and
kept current by scroll and resize listeners. The stylesheet now anchors the
card to its wrapper: beside the end edge, else the start edge, each also with
the card's bottom held at the viewport's margin.

A card that fits on neither side used to sit over its anchor, which left the
row under it unclickable. It now opens below the anchor from the anchor's
start edge, or above it; a card too tall for either stays in the viewport's
bottom end corner.
2026-11-15 18:34:14 +08:00

151 lines
3.6 KiB
CSS

/* Block, not inline-flex: consumers wrap full-width list rows and an
* inline wrapper would shrink them; the card still measures this rect. */
.root {
position: relative;
display: block;
}
/* The preview remains hit-testable so pointer entry cancels the grace close. */
.card {
position: fixed;
z-index: 100;
box-sizing: border-box;
width: 244px;
padding: 12px 16px;
border-radius: var(--dsw-radius-lg);
background: var(--dsw-alias-hovercard-bg);
box-shadow: var(--dsw-shadow-lv3);
}
/* A compact card sits beside its anchor's end edge with its top on the
anchor's top: the insets keep it 8px from the anchor and from the viewport's
edges. When that would cross the viewport, the first fallback that fits
places it: beside the start edge; on either side with its bottom at the
viewport's margin; then, with room on neither side, below the anchor from
the anchor's start edge, or above it, so the card does not cover its anchor.
A card too tall for that holds the viewport's bottom and end margins.
Chromium tries five fallbacks, so there the browser's own overflow shift
keeps such a card inside the viewport instead, against its edges. */
.compact {
position-area: inline-end span-block-end;
inset: 0 8px 8px;
position-try-fallbacks:
flip-inline,
--dsh-hover-card-low,
--dsh-hover-card-low flip-inline,
--dsh-hover-card-below,
--dsh-hover-card-above,
--dsh-hover-card-held;
}
@position-try --dsh-hover-card-low {
position-area: inline-end span-all;
align-self: end;
}
@position-try --dsh-hover-card-below {
position-area: block-end span-inline-end;
inset: 8px 8px 8px 0;
}
@position-try --dsh-hover-card-above {
position-area: block-start span-inline-end;
inset: 8px 8px 8px 0;
}
@position-try --dsh-hover-card-held {
position-area: span-all;
justify-self: end;
align-self: end;
}
.copyable {
cursor: pointer;
}
.copyable:focus-visible {
outline: var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary));
outline-offset: 2px;
}
.feedback {
display: flex;
align-items: center;
justify-content: center;
}
.copied {
color: var(--dsw-alias-hovercard-label-primary);
font-size: 14px;
line-height: 20px;
text-align: center;
}
.status {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip: rect(0 0 0 0);
white-space: nowrap;
}
.preview {
display: flex;
flex-direction: column;
padding: 0;
overflow: hidden;
border: 0;
border-radius: var(--dsw-radius-lg);
background: var(--dsw-alias-bg-layer-1);
color: var(--dsw-alias-label-primary);
box-shadow: var(--dsw-elevation-panel);
opacity: 1;
transition: opacity var(--dsh-hover-preview-fade) linear;
}
@starting-style {
.preview { opacity: 0; }
}
.preview[data-closing] {
opacity: 0;
pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
.preview { transition: none; }
}
.inline { display: inline; }
.media {
--dsh-scrollbar-thumb: var(--dsw-alias-scrollbar-bg-l2);
--dsh-scrollbar-thumb-hover: var(--dsw-alias-scrollbar-hover-l2);
overflow: auto;
padding: 8px;
border: 0;
color: var(--dsw-alias-label-primary);
background: var(--dsw-specific-menu);
backdrop-filter: var(--dsw-menu-backdrop-filter);
box-shadow: var(--dsw-elevation-panel);
}
.fitContent {
width: max-content;
}
.portal {
display: contents;
}
.bridge {
position: fixed;
z-index: 100;
}
/* The display:contents portal has no box to subtract from native drag regions. */
:global(:where(html[data-platform='darwin'])) .card,
:global(:where(html[data-platform='darwin'])) .bridge {
-webkit-app-region: no-drag;
}