Skip to content

Commit 0702ef3

Browse files
Chore: add searchbar shortcut indicator (#6548)
* chore: add searchbar shortcut indicator * style: add searchbar shortcut indicator styles * style: add font to shortcut indicator * refactor: replace let with const * style: add font-family to kbd element
1 parent 13d4cf2 commit 0702ef3

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

components/Common/Search/index.module.css

+9
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,12 @@
2323
top-[8px]
2424
size-5;
2525
}
26+
27+
.shortcutIndicator {
28+
@apply invisible
29+
absolute
30+
right-2
31+
ml-2
32+
md:visible
33+
[&>kbd]:font-ibm-plex-mono;
34+
}

components/Common/Search/index.tsx

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useTranslations } from 'next-intl';
55
import { useState, type FC } from 'react';
66

77
import { WithSearchBox } from '@/components/Common/Search/States/WithSearchBox';
8+
import { useDetectOS } from '@/hooks';
89
import { useKeyboardCommands } from '@/hooks/react-client';
910

1011
import styles from './index.module.css';
@@ -27,6 +28,10 @@ export const SearchButton: FC = () => {
2728
}
2829
});
2930

31+
const { os } = useDetectOS();
32+
33+
const osCommandKey = os === 'MAC' ? '⌘' : 'Ctrl';
34+
3035
return (
3136
<>
3237
<button
@@ -37,6 +42,9 @@ export const SearchButton: FC = () => {
3742
<MagnifyingGlassIcon className={styles.magnifyingGlassIcon} />
3843

3944
{t('components.search.searchBox.placeholder')}
45+
<span title={`${osCommandKey} K`} className={styles.shortcutIndicator}>
46+
<kbd>{osCommandKey} K</kbd>
47+
</span>
4048
</button>
4149

4250
{isOpen ? <WithSearchBox onClose={closeSearchBox} /> : null}

0 commit comments

Comments
 (0)