2021-04-22 16:49:30 +02:00
|
|
|
// Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
2021-04-22 14:18:48 +02:00
|
|
|
export function mergeTooltipAndShortcut(
|
|
|
|
tooltip: string | undefined,
|
2021-10-19 01:06:00 +02:00
|
|
|
shortcutLabel: string | undefined,
|
2021-04-22 14:18:48 +02:00
|
|
|
): string | undefined {
|
2021-04-23 11:48:36 +02:00
|
|
|
if (!tooltip && !shortcutLabel) {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
2021-04-23 05:00:18 +02:00
|
|
|
let buf = tooltip ?? "";
|
|
|
|
if (shortcutLabel) {
|
|
|
|
buf = `${buf} (${shortcutLabel})`;
|
|
|
|
}
|
|
|
|
return buf;
|
2021-04-22 14:18:48 +02:00
|
|
|
}
|
2021-06-24 16:44:08 +02:00
|
|
|
|
2022-11-28 00:33:04 +01:00
|
|
|
export const withButton = (f: (button: HTMLButtonElement) => void) => ({ detail }: CustomEvent): void => {
|
|
|
|
f(detail.button);
|
|
|
|
};
|
2021-06-24 16:44:08 +02:00
|
|
|
|
2022-11-28 00:33:04 +01:00
|
|
|
export const withSpan = (f: (span: HTMLSpanElement) => void) => ({ detail }: CustomEvent): void => {
|
|
|
|
f(detail.span);
|
|
|
|
};
|