Skip to content

Commit 3f4e4f9

Browse files
authored
feat(search): Enhance shortcut key transition for OS detection (#6554)
* feat(search): Enhance shortcut key transition for OS detection * fix(search): Optimize transition and apply style directly to kbd
1 parent 2aa5562 commit 3f4e4f9

File tree

5 files changed

+17
-7
lines changed

5 files changed

+17
-7
lines changed

components/Common/Search/index.module.css

+4-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
absolute
3030
right-2
3131
ml-2
32-
md:visible
33-
[&>kbd]:font-ibm-plex-mono;
32+
font-ibm-plex-mono
33+
motion-safe:transition-opacity
34+
motion-safe:duration-100
35+
md:visible;
3436
}

components/Common/Search/index.tsx

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use client';
22

33
import { MagnifyingGlassIcon } from '@heroicons/react/24/outline';
4+
import classNames from 'classnames';
45
import { useTranslations } from 'next-intl';
56
import { useState, type FC } from 'react';
67

@@ -31,6 +32,7 @@ export const SearchButton: FC = () => {
3132
const { os } = useDetectOS();
3233

3334
const osCommandKey = os === 'MAC' ? '⌘' : 'Ctrl';
35+
const isOSLoading = os === 'LOADING';
3436

3537
return (
3638
<>
@@ -42,9 +44,14 @@ export const SearchButton: FC = () => {
4244
<MagnifyingGlassIcon className={styles.magnifyingGlassIcon} />
4345

4446
{t('components.search.searchBox.placeholder')}
45-
<span title={`${osCommandKey} K`} className={styles.shortcutIndicator}>
46-
<kbd>{osCommandKey} K</kbd>
47-
</span>
47+
<kbd
48+
title={`${osCommandKey} K`}
49+
className={classNames(styles.shortcutIndicator, {
50+
'opacity-0': isOSLoading,
51+
})}
52+
>
53+
<abbr>{osCommandKey} K</abbr>
54+
</kbd>
4855
</button>
4956

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

hooks/react-client/useDetectOS.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type UserOSState = {
1515

1616
const useDetectOS = () => {
1717
const [userOSState, setUserOSState] = useState<UserOSState>({
18-
os: 'OTHER',
18+
os: 'LOADING',
1919
bitness: 86,
2020
architecture: 'ARM',
2121
});

types/userOS.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export type UserOS = 'MAC' | 'WIN' | 'LINUX' | 'OTHER';
1+
export type UserOS = 'MAC' | 'WIN' | 'LINUX' | 'OTHER' | 'LOADING';

util/downloadUtils.ts

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export const bitnessItems = {
9191
},
9292
],
9393
OTHER: [],
94+
LOADING: [],
9495
};
9596

9697
type formatDropdownItemsType = {

0 commit comments

Comments
 (0)