#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere
TypeScript dockerhacktoberfestjavapdfpdf-converterpdf-editorpdf-manipulationpdf-mergerpdf-ocrpdf-toolspdf-web-appspdfmergerself-hosted
Put the tooltip close button in the header as a quiet icon (#8968)
EthanHealy01acbdd0e05cef
diff --git a/frontend/src/editor/core/components/shared/Tooltip.tsx b/frontend/src/editor/core/components/shared/Tooltip.tsxindex 47ed3d45b0..8dfe529cdc 100644--- a/frontend/src/editor/core/components/shared/Tooltip.tsx+++ b/frontend/src/editor/core/components/shared/Tooltip.tsx@@ -63,8 +63,10 @@ export interface TooltipProps {/** Split out so only tooltips with a header need the logo and the providers behind it. */function TooltipHeader({header,+ action,}: {header: NonNullable<TooltipProps["header"]>;+ action?: React.ReactNode;}) {const { tooltipLogo } = useLogoAssets();return (@@ -79,6 +81,7 @@ function TooltipHeader({)}</div><span className={styles["tooltip-title"]}>{header.title}</span>+ {action}</div>);}@@ -407,6 +410,32 @@ export const Tooltip: React.FC<TooltipProps> = ({const shouldShowTooltip = open;const shouldShowCloseButton = showCloseButton || isPinned;+ const floatingCloseButton = shouldShowCloseButton && !header;++ // currentColor: the button takes the colour of whatever it sits on, so it+ // reads white on the pinned header and follows the theme everywhere else.+ const closeButton = shouldShowCloseButton ? (+ <ActionIcon+ variant="quiet"+ size="sm"+ className={`${styles["tooltip-close"]} ${floatingCloseButton ? styles["tooltip-close-floating"] : ""}`}+ style={+ {+ "--ai-color": "currentColor",+ "--ai-hover-color": "currentColor",+ } as React.CSSProperties+ }+ onClick={(e) => {+ e.stopPropagation();+ setIsPinned(false);+ setOpen(false);+ }}+ title={t("tooltip.close", "Close tooltip")}+ aria-label={t("tooltip.close", "Close tooltip")}+ >+ <Icon name="x" size="1rem" />+ </ActionIcon>+ ) : null;const tooltipElement = shouldShowTooltip ? (<div@@ -443,21 +472,7 @@ export const Tooltip: React.FC<TooltipProps> = ({: undefined}>- {shouldShowCloseButton && (- <ActionIcon- variant="tertiary"- className={styles["tooltip-pin-button"]}- onClick={(e) => {- e.stopPropagation();- setIsPinned(false);- setOpen(false);- }}- title={t("tooltip.close", "Close tooltip")}- aria-label={t("tooltip.close", "Close tooltip")}- >- <Icon name="x" size="1.25rem" />- </ActionIcon>- )}+ {floatingCloseButton && closeButton}{arrow && !sidebarTooltip && (<divclassName={`${styles["tooltip-arrow"]} ${getArrowStyleClass(arrowClass!)}`}@@ -472,11 +487,11 @@ export const Tooltip: React.FC<TooltipProps> = ({}/>)}- {header && <TooltipHeader header={header} />}+ {header && <TooltipHeader header={header} action={closeButton} />}<TooltipContentcontent={content}tips={tips}- extraRightPadding={shouldShowCloseButton ? 48 : 0}+ extraRightPadding={floatingCloseButton ? 32 : 0}/></div>) : null;diff --git a/frontend/src/editor/core/components/shared/tooltip/Tooltip.module.css b/frontend/src/editor/core/components/shared/tooltip/Tooltip.module.cssindex 0912306010..a813828172 100644--- a/frontend/src/editor/core/components/shared/tooltip/Tooltip.module.css+++ b/frontend/src/editor/core/components/shared/tooltip/Tooltip.module.css@@ -36,38 +36,25 @@border-color: var(--primary-color, var(--c-primary));}-/* Close button */-.tooltip-pin-button {- position: absolute;- top: 0.5rem;- right: 0.5rem;- font-size: 0.875rem;- background: var(--c-surface-raised);- padding: 0.25rem;- border-radius: 0.25rem;- border: 0.0625rem solid var(--c-border);- cursor: pointer;- transition:- background-color 0.2s ease,- border-color 0.2s ease;- z-index: 1;- display: flex;- align-items: center;- justify-content: center;- min-width: 1.5rem;- min-height: 1.5rem;+/* Negative block margins keep the header at its text height; the inline-end+ margin lines the glyph's ink up with the logo's inset on the other side. */+.tooltip-close {+ flex-shrink: 0;+ margin: -0.375rem -0.6875rem -0.375rem 0;+ opacity: 0.85;+ transition: opacity 0.15s ease;}-.tooltip-pin-button:hover {- background-color: var(--c-danger) !important;- border-color: var(--c-danger) !important;+.tooltip-close:hover {+ opacity: 1;}-.tooltip-pin-button:focus,-.tooltip-pin-button:focus-visible {- outline: none;- border-color: var(--c-border) !important;- background-color: var(--c-surface-raised) !important;+.tooltip-close-floating {+ position: absolute;+ top: 0.5rem;+ right: 0.5rem;+ margin: 0;+ z-index: 1;}/* Tooltip Header */