2020-10-02 15:10:00 +00:00
|
|
|
/**
|
|
|
|
* This module implements tooltips of two kinds:
|
|
|
|
* - to be shown on hover, similar to the native "title" attribute (popweasel meant to provide
|
|
|
|
* that, but its machinery isn't really needed). TODO these aren't yet implemented.
|
|
|
|
* - to be shown briefly, as a transient notification next to some action element.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import {prepareForTransition} from 'app/client/ui/transitions';
|
2022-10-19 23:06:05 +00:00
|
|
|
import {testId, theme, vars} from 'app/client/ui2018/cssVars';
|
2021-03-08 21:08:13 +00:00
|
|
|
import {icon} from 'app/client/ui2018/icons';
|
2022-10-19 23:06:05 +00:00
|
|
|
import {menuCssClass} from 'app/client/ui2018/menus';
|
2023-02-01 12:55:41 +00:00
|
|
|
import {dom, DomContents, DomElementArg, DomElementMethod, styled} from 'grainjs';
|
2020-10-02 15:10:00 +00:00
|
|
|
import Popper from 'popper.js';
|
2022-10-19 23:06:05 +00:00
|
|
|
import {cssMenu, defaultMenuOptions, IMenuOptions, setPopupToCreateDom} from 'popweasel';
|
2020-10-02 15:10:00 +00:00
|
|
|
|
2021-03-05 15:17:07 +00:00
|
|
|
export interface ITipOptions {
|
2022-10-19 23:06:05 +00:00
|
|
|
/**
|
|
|
|
* Where to place the tooltip relative to the reference element.
|
|
|
|
*
|
|
|
|
* Defaults to 'top'.
|
|
|
|
*
|
|
|
|
* See https://popper.js.org/docs/v1/#popperplacements--codeenumcode.
|
|
|
|
*/
|
2020-10-02 15:10:00 +00:00
|
|
|
placement?: Popper.Placement;
|
|
|
|
|
2022-10-19 23:06:05 +00:00
|
|
|
/** When set, a tooltip will replace any previous tooltip with the same key. */
|
2021-03-05 15:17:07 +00:00
|
|
|
key?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface ITransientTipOptions extends ITipOptions {
|
2022-10-19 23:06:05 +00:00
|
|
|
/** When to remove the transient tooltip. Defaults to 2000ms. */
|
2020-10-02 15:10:00 +00:00
|
|
|
timeoutMs?: number;
|
2021-03-05 15:17:07 +00:00
|
|
|
}
|
2020-10-02 15:10:00 +00:00
|
|
|
|
2021-03-08 21:08:13 +00:00
|
|
|
export interface IHoverTipOptions extends ITransientTipOptions {
|
2022-10-19 23:06:05 +00:00
|
|
|
/** How soon after mouseenter to show it. Defaults to 200 ms. */
|
2021-03-08 21:08:13 +00:00
|
|
|
openDelay?: number;
|
|
|
|
|
2022-10-19 23:06:05 +00:00
|
|
|
/** If set and non-zero, remove the tip automatically after this time. */
|
2021-03-08 21:08:13 +00:00
|
|
|
timeoutMs?: number;
|
|
|
|
|
2022-10-19 23:06:05 +00:00
|
|
|
/**
|
|
|
|
* How soon after mouseleave to hide it.
|
|
|
|
*
|
|
|
|
* Defaults to 100 ms.
|
|
|
|
*
|
|
|
|
* A non-zero delay gives the pointer some time to be outside of the trigger
|
|
|
|
* and the tooltip content if the user moves the pointer from one to the other.
|
|
|
|
*/
|
2021-03-08 21:08:13 +00:00
|
|
|
closeDelay?: number;
|
|
|
|
|
2022-10-19 23:06:05 +00:00
|
|
|
/**
|
|
|
|
* Also show the tip on clicking the element it's attached to.
|
|
|
|
*
|
|
|
|
* Defaults to false.
|
|
|
|
*
|
|
|
|
* Should only be set to true if `closeOnClick` is false.
|
|
|
|
*/
|
2021-03-08 21:08:13 +00:00
|
|
|
openOnClick?: boolean;
|
2022-10-19 23:06:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Hide the tip on clicking the element it's attached to.
|
|
|
|
*
|
|
|
|
* Defaults to true.
|
|
|
|
*
|
|
|
|
* Should only be set to true if `openOnClick` is false.
|
|
|
|
*/
|
|
|
|
closeOnClick?: boolean;
|
2021-03-08 21:08:13 +00:00
|
|
|
}
|
|
|
|
|
2022-10-19 23:06:05 +00:00
|
|
|
export type ITooltipContent = ITooltipContentFunc | DomContents;
|
|
|
|
|
2021-03-08 21:08:13 +00:00
|
|
|
export type ITooltipContentFunc = (ctl: ITooltipControl) => DomContents;
|
|
|
|
|
2021-03-05 15:17:07 +00:00
|
|
|
export interface ITooltipControl {
|
|
|
|
close(): void;
|
2021-03-08 21:08:13 +00:00
|
|
|
getDom(): HTMLElement; // The tooltip DOM.
|
2020-10-02 15:10:00 +00:00
|
|
|
}
|
|
|
|
|
2022-10-19 23:06:05 +00:00
|
|
|
/**
|
|
|
|
* Map of open tooltips, mapping the key (from ITipOptions) to ITooltipControl that allows removing
|
|
|
|
* the tooltip.
|
|
|
|
*/
|
2021-03-05 15:17:07 +00:00
|
|
|
const openTooltips = new Map<string, ITooltipControl>();
|
2020-10-02 15:10:00 +00:00
|
|
|
|
2021-03-05 15:17:07 +00:00
|
|
|
/**
|
|
|
|
* Show tipContent briefly (2s by default), in a tooltip next to refElem (on top of it, by default).
|
|
|
|
* See also ITipOptions.
|
|
|
|
*/
|
2021-05-25 09:24:00 +00:00
|
|
|
export function showTransientTooltip(
|
|
|
|
refElem: Element,
|
2022-10-19 23:06:05 +00:00
|
|
|
tipContent: ITooltipContent,
|
2021-05-25 09:24:00 +00:00
|
|
|
options: ITransientTipOptions = {}) {
|
|
|
|
const ctl = showTooltip(refElem, typeof tipContent == 'function' ? tipContent : () => tipContent, options);
|
2021-03-05 15:17:07 +00:00
|
|
|
const origClose = ctl.close;
|
|
|
|
ctl.close = () => { clearTimeout(timer); origClose(); };
|
|
|
|
|
|
|
|
const timer = setTimeout(ctl.close, options.timeoutMs || 2000);
|
2021-05-25 09:24:00 +00:00
|
|
|
return ctl;
|
2021-03-05 15:17:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the return value of tipContent(ctl) in a tooltip next to refElem (on top of it, by default).
|
|
|
|
* Returns ctl. In both places, ctl is an object with a close() method, which closes the tooltip.
|
|
|
|
* See also ITipOptions.
|
|
|
|
*/
|
|
|
|
export function showTooltip(
|
2021-03-08 21:08:13 +00:00
|
|
|
refElem: Element, tipContent: ITooltipContentFunc, options: ITipOptions = {}
|
2021-03-05 15:17:07 +00:00
|
|
|
): ITooltipControl {
|
2022-10-19 23:06:05 +00:00
|
|
|
const placement: Popper.Placement = options.placement ?? 'top';
|
2020-10-02 15:10:00 +00:00
|
|
|
const key = options.key;
|
2022-10-19 23:06:05 +00:00
|
|
|
const hasKey = key && openTooltips.has(key);
|
2021-04-30 17:28:52 +00:00
|
|
|
let closed = false;
|
2020-10-02 15:10:00 +00:00
|
|
|
|
|
|
|
// If we had a previous tooltip with the same key, clean it up.
|
2021-03-05 15:17:07 +00:00
|
|
|
if (key) { openTooltips.get(key)?.close(); }
|
|
|
|
|
|
|
|
// Cleanup involves destroying the Popper instance, removing the element, etc.
|
|
|
|
function close() {
|
2021-04-30 17:28:52 +00:00
|
|
|
if (closed) { return; }
|
|
|
|
closed = true;
|
2021-03-05 15:17:07 +00:00
|
|
|
popper.destroy();
|
|
|
|
dom.domDispose(content);
|
|
|
|
content.remove();
|
|
|
|
if (key) { openTooltips.delete(key); }
|
|
|
|
}
|
2021-03-08 21:08:13 +00:00
|
|
|
const ctl: ITooltipControl = {close, getDom: () => content};
|
2020-10-02 15:10:00 +00:00
|
|
|
|
|
|
|
// Add the content element.
|
2021-03-08 21:08:13 +00:00
|
|
|
const content = cssTooltip({role: 'tooltip'}, tipContent(ctl), testId(`tooltip`));
|
2020-10-02 15:10:00 +00:00
|
|
|
document.body.appendChild(content);
|
|
|
|
|
|
|
|
// Create a popper for positioning the tooltip content relative to refElem.
|
|
|
|
const popperOptions: Popper.PopperOptions = {
|
|
|
|
modifiers: {preventOverflow: {boundariesElement: 'viewport'}},
|
|
|
|
placement,
|
|
|
|
};
|
|
|
|
const popper = new Popper(refElem, content, popperOptions);
|
|
|
|
|
2021-04-30 17:28:52 +00:00
|
|
|
// If refElem is disposed we close the tooltip.
|
|
|
|
dom.onDisposeElem(refElem, close);
|
|
|
|
|
2022-10-19 23:06:05 +00:00
|
|
|
// If we're not replacing the tooltip, fade in the content using transitions.
|
|
|
|
if (!hasKey) {
|
|
|
|
prepareForTransition(content, () => { content.style.opacity = '0'; });
|
|
|
|
content.style.opacity = '';
|
|
|
|
}
|
2020-10-02 15:10:00 +00:00
|
|
|
|
2021-03-05 15:17:07 +00:00
|
|
|
if (key) { openTooltips.set(key, ctl); }
|
|
|
|
return ctl;
|
2020-10-02 15:10:00 +00:00
|
|
|
}
|
|
|
|
|
2021-03-08 21:08:13 +00:00
|
|
|
/**
|
|
|
|
* Render a tooltip on hover. Suitable for use during dom construction, e.g.
|
2022-10-19 23:06:05 +00:00
|
|
|
* dom('div', 'Trigger', hoverTooltip('Hello!')
|
2021-03-08 21:08:13 +00:00
|
|
|
*/
|
2022-10-19 23:06:05 +00:00
|
|
|
export function hoverTooltip(tipContent: ITooltipContent, options?: IHoverTipOptions): DomElementMethod {
|
|
|
|
const defaultOptions: IHoverTipOptions = {placement: 'bottom'};
|
|
|
|
return (elem) => setHoverTooltip(elem, tipContent, {...defaultOptions, ...options});
|
2021-03-08 21:08:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attach a tooltip to the given element, to be rendered on hover.
|
|
|
|
*/
|
2022-10-19 23:06:05 +00:00
|
|
|
export function setHoverTooltip(
|
|
|
|
refElem: Element,
|
|
|
|
tipContent: ITooltipContent,
|
|
|
|
options: IHoverTipOptions = {}
|
|
|
|
) {
|
|
|
|
const {key, openDelay = 200, timeoutMs, closeDelay = 100, openOnClick, closeOnClick = true} = options;
|
|
|
|
|
|
|
|
const tipContentFunc = typeof tipContent === 'function' ? tipContent : () => tipContent;
|
2021-03-08 21:08:13 +00:00
|
|
|
|
|
|
|
// Controller for closing the tooltip, if one is open.
|
|
|
|
let tipControl: ITooltipControl|undefined;
|
|
|
|
|
|
|
|
// Timer to open or close the tooltip, depending on whether tipControl is set.
|
|
|
|
let timer: ReturnType<typeof setTimeout>|undefined;
|
|
|
|
|
|
|
|
function clearTimer() {
|
|
|
|
if (timer) { clearTimeout(timer); timer = undefined; }
|
|
|
|
}
|
|
|
|
function resetTimer(func: () => void, delay: number) {
|
|
|
|
clearTimer();
|
|
|
|
timer = setTimeout(func, delay);
|
|
|
|
}
|
|
|
|
function scheduleCloseIfOpen() {
|
|
|
|
clearTimer();
|
|
|
|
if (tipControl) { resetTimer(close, closeDelay); }
|
|
|
|
}
|
|
|
|
function open() {
|
|
|
|
clearTimer();
|
2022-10-19 23:06:05 +00:00
|
|
|
tipControl = showTooltip(refElem, ctl => tipContentFunc({...ctl, close}), options);
|
2021-03-08 21:08:13 +00:00
|
|
|
dom.onElem(tipControl.getDom(), 'mouseenter', clearTimer);
|
|
|
|
dom.onElem(tipControl.getDom(), 'mouseleave', scheduleCloseIfOpen);
|
2022-10-19 23:06:05 +00:00
|
|
|
dom.onDisposeElem(tipControl.getDom(), () => close());
|
2021-03-08 21:08:13 +00:00
|
|
|
if (timeoutMs) { resetTimer(close, timeoutMs); }
|
|
|
|
}
|
|
|
|
function close() {
|
|
|
|
clearTimer();
|
|
|
|
tipControl?.close();
|
|
|
|
tipControl = undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We simulate hover effect by handling mouseenter/mouseleave.
|
|
|
|
dom.onElem(refElem, 'mouseenter', () => {
|
|
|
|
if (!tipControl && !timer) {
|
2022-10-19 23:06:05 +00:00
|
|
|
// If we're replacing a tooltip, open without delay.
|
|
|
|
const delay = key && openTooltips.has(key) ? 0 : openDelay;
|
|
|
|
resetTimer(open, delay);
|
2021-03-08 21:08:13 +00:00
|
|
|
} else if (tipControl) {
|
|
|
|
// Already shown, reset to newly-shown state.
|
|
|
|
clearTimer();
|
|
|
|
if (timeoutMs) { resetTimer(close, timeoutMs); }
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
dom.onElem(refElem, 'mouseleave', scheduleCloseIfOpen);
|
|
|
|
|
2022-10-19 23:06:05 +00:00
|
|
|
if (openOnClick) {
|
|
|
|
// If requested, re-open on click.
|
2021-03-08 21:08:13 +00:00
|
|
|
dom.onElem(refElem, 'click', () => { close(); open(); });
|
2022-10-19 23:06:05 +00:00
|
|
|
} else if (closeOnClick) {
|
|
|
|
// If requested, close on click.
|
|
|
|
dom.onElem(refElem, 'click', () => { close(); });
|
2021-03-08 21:08:13 +00:00
|
|
|
}
|
2021-05-04 07:39:17 +00:00
|
|
|
|
2022-10-19 23:06:05 +00:00
|
|
|
// Close tooltip if refElem is disposed.
|
2021-05-04 07:39:17 +00:00
|
|
|
dom.onDisposeElem(refElem, close);
|
2021-03-08 21:08:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Build a handy button for closing a tooltip.
|
|
|
|
*/
|
|
|
|
export function tooltipCloseButton(ctl: ITooltipControl): HTMLElement {
|
|
|
|
return cssTooltipCloseButton(icon('CrossSmall'),
|
|
|
|
dom.on('click', () => ctl.close()),
|
|
|
|
testId('tooltip-close'),
|
|
|
|
);
|
|
|
|
}
|
2020-10-02 15:10:00 +00:00
|
|
|
|
2022-06-06 16:21:26 +00:00
|
|
|
/**
|
2023-02-01 12:55:41 +00:00
|
|
|
* Renders an info icon that shows a tooltip with the specified `content` on click.
|
2022-06-06 16:21:26 +00:00
|
|
|
*/
|
2023-02-01 12:55:41 +00:00
|
|
|
export function infoTooltip(content: DomContents, menuOptions?: IMenuOptions, ...domArgs: DomElementArg[]) {
|
|
|
|
return cssInfoTooltipButton('?',
|
|
|
|
(elem) => {
|
|
|
|
setPopupToCreateDom(
|
|
|
|
elem,
|
|
|
|
(ctl) => {
|
|
|
|
return cssInfoTooltipPopup(
|
|
|
|
cssInfoTooltipPopupCloseButton(
|
|
|
|
icon('CrossSmall'),
|
|
|
|
dom.on('click', () => ctl.close()),
|
|
|
|
testId('info-tooltip-close'),
|
|
|
|
),
|
|
|
|
cssInfoTooltipPopupBody(
|
|
|
|
content,
|
|
|
|
testId('info-tooltip-popup-body'),
|
|
|
|
),
|
|
|
|
dom.cls(menuCssClass),
|
|
|
|
dom.cls(cssMenu.className),
|
|
|
|
dom.onKeyDown({
|
|
|
|
Enter: () => ctl.close(),
|
|
|
|
Escape: () => ctl.close(),
|
|
|
|
}),
|
|
|
|
(popup) => { setTimeout(() => popup.focus(), 0); },
|
|
|
|
testId('info-tooltip-popup'),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
{...defaultMenuOptions, ...{placement: 'bottom-end'}, ...menuOptions},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
testId('info-tooltip'),
|
|
|
|
...domArgs,
|
|
|
|
);
|
2022-06-06 16:21:26 +00:00
|
|
|
}
|
|
|
|
|
2023-02-01 12:55:41 +00:00
|
|
|
export interface WithInfoTooltipOptions {
|
2022-10-19 23:06:05 +00:00
|
|
|
domArgs?: DomElementArg[];
|
|
|
|
tooltipButtonDomArgs?: DomElementArg[];
|
|
|
|
tooltipMenuOptions?: IMenuOptions;
|
|
|
|
}
|
|
|
|
|
2022-06-06 16:21:26 +00:00
|
|
|
/**
|
2022-10-19 23:06:05 +00:00
|
|
|
* Wraps `domContent` with a info tooltip button that displays the provided
|
|
|
|
* `tooltipContent` on click, and returns the wrapped element.
|
|
|
|
*
|
|
|
|
* The tooltip button is displayed to the right of `domContents`, and displays
|
|
|
|
* a popup on click. The popup can be dismissed by clicking away from it, clicking
|
|
|
|
* the close button in the top-right corner, or pressing Enter or Escape.
|
|
|
|
*
|
|
|
|
* Arguments can be passed to both the top-level wrapped DOM element and the
|
|
|
|
* tooltip button element with `options.domArgs` and `options.tooltipButtonDomArgs`
|
|
|
|
* respectively.
|
|
|
|
*
|
|
|
|
* Usage:
|
|
|
|
*
|
2023-02-01 12:55:41 +00:00
|
|
|
* withInfoTooltip(
|
2022-10-19 23:06:05 +00:00
|
|
|
* dom('div', 'Hello World!'),
|
|
|
|
* dom('p', 'This is some text to show inside the tooltip.'),
|
|
|
|
* )
|
2022-06-06 16:21:26 +00:00
|
|
|
*/
|
2023-02-01 12:55:41 +00:00
|
|
|
export function withInfoTooltip(
|
2023-01-19 17:37:24 +00:00
|
|
|
domContents: DomContents,
|
|
|
|
tooltipContent: DomContents,
|
2023-02-01 12:55:41 +00:00
|
|
|
options: WithInfoTooltipOptions = {},
|
2023-01-19 17:37:24 +00:00
|
|
|
) {
|
2023-02-01 12:55:41 +00:00
|
|
|
const {domArgs, tooltipButtonDomArgs, tooltipMenuOptions} = options;
|
2023-01-19 17:37:24 +00:00
|
|
|
return cssDomWithTooltip(
|
|
|
|
domContents,
|
2023-02-01 12:55:41 +00:00
|
|
|
infoTooltip(tooltipContent, tooltipMenuOptions, tooltipButtonDomArgs),
|
2023-01-19 17:37:24 +00:00
|
|
|
...(domArgs ?? [])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-02-01 12:55:41 +00:00
|
|
|
/**
|
|
|
|
* Renders an column info icon that shows a tooltip with the specified `content` on click.
|
|
|
|
*/
|
|
|
|
export function columnInfoTooltip(content: DomContents, menuOptions?: IMenuOptions, ...domArgs: DomElementArg[]) {
|
|
|
|
return cssColumnInfoTooltipButton(
|
|
|
|
icon('Info', dom.cls("info_toggle_icon")),
|
|
|
|
(elem) => {
|
|
|
|
setPopupToCreateDom(
|
|
|
|
elem,
|
|
|
|
(ctl) => {
|
|
|
|
return cssInfoTooltipPopup(
|
|
|
|
cssInfoTooltipPopupCloseButton(
|
|
|
|
icon('CrossSmall'),
|
|
|
|
dom.on('click', () => ctl.close()),
|
|
|
|
testId('column-info-tooltip-close'),
|
|
|
|
),
|
|
|
|
cssInfoTooltipPopupBody(
|
|
|
|
content,
|
2023-02-15 15:41:58 +00:00
|
|
|
{ style: 'white-space: pre-wrap;' },
|
2023-02-01 12:55:41 +00:00
|
|
|
testId('column-info-tooltip-popup-body'),
|
|
|
|
),
|
|
|
|
dom.cls(menuCssClass),
|
|
|
|
dom.cls(cssMenu.className),
|
|
|
|
dom.onKeyDown({
|
|
|
|
Enter: () => ctl.close(),
|
|
|
|
Escape: () => ctl.close(),
|
|
|
|
}),
|
|
|
|
(popup) => { setTimeout(() => popup.focus(), 0); },
|
|
|
|
testId('column-info-tooltip-popup'),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
{ ...defaultMenuOptions, ...{ placement: 'bottom-end' }, ...menuOptions },
|
|
|
|
);
|
|
|
|
},
|
|
|
|
testId('column-info-tooltip'),
|
|
|
|
...domArgs,
|
2022-06-06 16:21:26 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-02-01 12:55:41 +00:00
|
|
|
const cssColumnInfoTooltipButton = styled('div', `
|
|
|
|
cursor: pointer;
|
|
|
|
--icon-color: ${theme.infoButtonFg};
|
|
|
|
border-radius: 50%;
|
|
|
|
display: inline-block;
|
|
|
|
margin-left: 5px;
|
2023-02-23 09:18:38 +00:00
|
|
|
line-height: 0px;
|
|
|
|
|
2023-02-01 12:55:41 +00:00
|
|
|
&:hover {
|
|
|
|
--icon-color: ${theme.infoButtonHoverFg};
|
|
|
|
}
|
|
|
|
&:active {
|
|
|
|
--icon-color: ${theme.infoButtonActiveFg};
|
|
|
|
}
|
|
|
|
`);
|
|
|
|
|
|
|
|
|
2020-10-02 15:10:00 +00:00
|
|
|
const cssTooltip = styled('div', `
|
|
|
|
position: absolute;
|
|
|
|
z-index: 5000; /* should be higher than a modal */
|
2022-09-06 01:51:57 +00:00
|
|
|
background-color: ${theme.tooltipBg};
|
2020-10-02 15:10:00 +00:00
|
|
|
border-radius: 3px;
|
|
|
|
box-shadow: 0 0 2px rgba(0,0,0,0.5);
|
|
|
|
text-align: center;
|
2022-09-06 01:51:57 +00:00
|
|
|
color: ${theme.tooltipFg};
|
2020-10-02 15:10:00 +00:00
|
|
|
width: auto;
|
|
|
|
font-family: sans-serif;
|
|
|
|
font-size: 10pt;
|
|
|
|
padding: 8px 16px;
|
|
|
|
margin: 4px;
|
|
|
|
transition: opacity 0.2s;
|
|
|
|
`);
|
2021-03-08 21:08:13 +00:00
|
|
|
|
|
|
|
const cssTooltipCloseButton = styled('div', `
|
|
|
|
cursor: pointer;
|
|
|
|
user-select: none;
|
|
|
|
width: 16px;
|
|
|
|
height: 16px;
|
|
|
|
line-height: 16px;
|
|
|
|
text-align: center;
|
|
|
|
margin: -4px -4px -4px 8px;
|
2022-09-06 01:51:57 +00:00
|
|
|
--icon-color: ${theme.tooltipCloseButtonFg};
|
2021-03-08 21:08:13 +00:00
|
|
|
border-radius: 16px;
|
|
|
|
|
|
|
|
&:hover {
|
2022-09-06 01:51:57 +00:00
|
|
|
background-color: ${theme.tooltipCloseButtonHoverBg};
|
|
|
|
--icon-color: ${theme.tooltipCloseButtonHoverFg};
|
2021-03-08 21:08:13 +00:00
|
|
|
}
|
|
|
|
`);
|
2022-06-06 16:21:26 +00:00
|
|
|
|
2023-02-01 12:55:41 +00:00
|
|
|
const cssInfoTooltipButton = styled('div', `
|
2022-06-06 16:21:26 +00:00
|
|
|
flex-shrink: 0;
|
2022-10-19 23:06:05 +00:00
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
height: ${vars.largeFontSize};
|
|
|
|
width: ${vars.largeFontSize};
|
|
|
|
border: 1px solid ${theme.controlSecondaryFg};
|
|
|
|
color: ${theme.controlSecondaryFg};
|
|
|
|
border-radius: 50%;
|
|
|
|
cursor: pointer;
|
|
|
|
user-select: none;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
border: 1px solid ${theme.controlSecondaryHoverFg};
|
|
|
|
color: ${theme.controlSecondaryHoverFg};
|
|
|
|
}
|
2022-06-06 16:21:26 +00:00
|
|
|
`);
|
|
|
|
|
2022-10-19 23:06:05 +00:00
|
|
|
const cssInfoTooltipPopup = styled('div', `
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
background-color: ${theme.popupBg};
|
2022-06-06 16:21:26 +00:00
|
|
|
max-width: 200px;
|
2022-10-19 23:06:05 +00:00
|
|
|
margin: 4px;
|
|
|
|
padding: 0px;
|
|
|
|
`);
|
|
|
|
|
|
|
|
const cssInfoTooltipPopupBody = styled('div', `
|
|
|
|
color: ${theme.text};
|
|
|
|
text-align: left;
|
|
|
|
padding: 0px 16px 16px 16px;
|
|
|
|
`);
|
|
|
|
|
|
|
|
const cssInfoTooltipPopupCloseButton = styled('div', `
|
|
|
|
flex-shrink: 0;
|
|
|
|
align-self: flex-end;
|
|
|
|
cursor: pointer;
|
|
|
|
--icon-color: ${theme.controlSecondaryFg};
|
|
|
|
margin: 8px 8px 4px 0px;
|
|
|
|
padding: 2px;
|
|
|
|
border-radius: 4px;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
background-color: ${theme.hover};
|
|
|
|
}
|
|
|
|
`);
|
|
|
|
|
|
|
|
const cssDomWithTooltip = styled('div', `
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
column-gap: 8px;
|
2022-06-06 16:21:26 +00:00
|
|
|
`);
|