Skip to content

Commit

Permalink
fix: conditionally render search bar based on page state
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinRohlf committed Dec 3, 2024
1 parent 6748995 commit c6ac929
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions src/components/Header/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,24 +102,30 @@ export default function SearchBar({
})

return (
<form className={styles.search} autoComplete={!value ? 'off' : 'on'}>
<animated.div style={springStile} className={styles.springContainer}>
<InputElement
ref={searchBarRef}
type="search"
name="search"
placeholder={placeholder || 'Search...'}
value={value}
onChange={handleChange}
required
size="small"
className={styles.input}
onKeyPress={handleKeyPress}
/>
<button onClick={handleButtonClick} className={styles.button}>
<SearchIcon className={styles.searchIcon} />
</button>
</animated.div>
</form>
<>
{isSearchPage || isSearchBarVisible ? (
<form className={styles.search} autoComplete={!value ? 'off' : 'on'}>
<animated.div style={springStile} className={styles.springContainer}>
<InputElement
ref={searchBarRef}
type="search"
name="search"
placeholder={placeholder || 'Search...'}
value={value}
onChange={handleChange}
required
size="small"
className={styles.input}
onKeyPress={handleKeyPress}
/>
<button onClick={handleButtonClick} className={styles.button}>
<SearchIcon className={styles.searchIcon} />
</button>
</animated.div>
</form>
) : (
<> </>
)}
</>
)
}

0 comments on commit c6ac929

Please sign in to comment.