Skip to content

Commit

Permalink
feat: add shortcut text hint to the search field (#3269)
Browse files Browse the repository at this point in the history
* feat: add shortcut text hint to the search field

* fix: search box width to fit the shortcut hint text

* fix: error when not running on Mac due to an undefined `os` variable
  • Loading branch information
rhumbertgz authored and 0xi4o committed Sep 30, 2024
1 parent 788f807 commit 8e30669
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/ui/src/layout/MainLayout/ViewHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ import { StyledFab } from '@/ui-component/button/StyledFab'
import { IconSearch, IconArrowLeft, IconEdit } from '@tabler/icons-react'

import useSearchShorcut from '@/hooks/useSearchShortcut'
import { getOS } from '@/utils/genericHelper'

const os = getOS()
const isMac = os === 'macos'
const isDesktop = isMac || os === 'windows' || os === 'linux'
const keyboardShortcut = isMac ? '[ ⌘ + F ]' : '[ Ctrl + F ]'

const ViewHeader = ({
children,
Expand Down Expand Up @@ -93,7 +99,7 @@ const ViewHeader = ({
inputRef={searchInputRef}
size='small'
sx={{
width: '280px',
width: '325px',
height: '100%',
display: { xs: 'none', sm: 'flex' },
borderRadius: 2,
Expand All @@ -103,7 +109,7 @@ const ViewHeader = ({
}
}}
variant='outlined'
placeholder={searchPlaceholder}
placeholder={`${searchPlaceholder} ${isDesktop ? keyboardShortcut : ''}`}
onChange={onSearchChange}
startAdornment={
<Box
Expand Down

0 comments on commit 8e30669

Please sign in to comment.