aboutsummaryrefslogtreecommitdiff
path: root/dokka-subprojects/plugin-base-frontend/src/main/components/search/dokkaSearchAnchor.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'dokka-subprojects/plugin-base-frontend/src/main/components/search/dokkaSearchAnchor.tsx')
-rw-r--r--dokka-subprojects/plugin-base-frontend/src/main/components/search/dokkaSearchAnchor.tsx32
1 files changed, 32 insertions, 0 deletions
diff --git a/dokka-subprojects/plugin-base-frontend/src/main/components/search/dokkaSearchAnchor.tsx b/dokka-subprojects/plugin-base-frontend/src/main/components/search/dokkaSearchAnchor.tsx
new file mode 100644
index 00000000..f7c6cf46
--- /dev/null
+++ b/dokka-subprojects/plugin-base-frontend/src/main/components/search/dokkaSearchAnchor.tsx
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ */
+
+import React from "react";
+import Tooltip from '@jetbrains/ring-ui/components/tooltip/tooltip';
+import SearchIcon from 'react-svg-loader!../assets/searchIcon.svg';
+import {CustomAnchorProps} from "./types";
+import {Hotkey} from "../utils/hotkey";
+
+const HOTKEY_LETTER = 'k'
+const HOTKEY_TOOLTIP_DISPLAY_DELAY = 0.5 * 1000 // seconds
+
+export const DokkaSearchAnchor = ({wrapperProps, buttonProps, popup}: CustomAnchorProps) => {
+ const hotkeys = new Hotkey()
+ hotkeys.registerHotkeyWithAccel(buttonProps.onClick, HOTKEY_LETTER)
+
+ return (
+ <span {...wrapperProps}>
+ <Tooltip
+ title={`${hotkeys.getOsAccelKeyName()} + ${HOTKEY_LETTER.toUpperCase()}`}
+ delay={HOTKEY_TOOLTIP_DISPLAY_DELAY}
+ popupProps={{className: "search-hotkey-popup"}}
+ >
+ <button type="button" {...buttonProps}>
+ <SearchIcon/>
+ </button>
+ </Tooltip>
+ {popup}
+ </span>
+ )
+}