Skip to content

Commit a059a7a

Browse files
committed
feat: add support for no border and bg in search bar
1 parent 0d92258 commit a059a7a

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/Common/SearchBar/SearchBar.component.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const SearchBar = ({
4747
containerClassName,
4848
shouldDebounce = false,
4949
debounceTimeout = 300,
50+
noBackgroundAndBorder = false,
5051
}: SearchBarProps) => {
5152
const [showClearButton, setShowClearButton] = useState(!!initialSearchText)
5253
const inputRef = useRef<HTMLInputElement>()
@@ -97,17 +98,19 @@ const SearchBar = ({
9798

9899
return (
99100
<div className={containerClassName}>
100-
<div className="search-bar bc-n50 focus-within-border-b5 dc__hover-border-n300 dc__block w-100 min-w-200 dc__position-rel en-2 bw-1 br-4 h-32">
101+
<div
102+
className={`search-bar ${noBackgroundAndBorder ? 'dc__no-border dc__no-background dc__hover-n50' : 'bc-n50 en-2 dc__hover-border-n300'} focus-within-border-b5 dc__block w-100 min-w-200 dc__position-rel br-4 bw-1 h-32`}
103+
>
101104
<Search className="search-bar__icon dc__position-abs icon-color-n6 icon-dim-16" />
102105
<input
103106
placeholder="Search"
104107
data-testid="search-bar"
105108
type="text"
106109
{...inputProps}
107110
defaultValue={initialSearchText}
108-
className={`search-bar__input bc-n50 dc__position-abs w-100 h-100 br-4 dc__no-border pt-6 pr-10 pb-6 pl-30 fs-13 lh-20 fw-4 cn-9 placeholder-cn5 ${
111+
className={`search-bar__input dc__position-abs w-100 h-100 br-4 dc__no-border pt-6 pr-10 pb-6 pl-30 fs-13 lh-20 fw-4 cn-9 placeholder-cn5 ${
109112
showClearButton ? 'pr-30' : 'pr-10'
110-
}`}
113+
} ${noBackgroundAndBorder ? 'dc__no-background' : 'bc-n50'}`}
111114
onChange={handleChange}
112115
onKeyDown={handleKeyDown}
113116
ref={inputRef}

src/Common/SearchBar/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,8 @@ export interface SearchBarProps {
3131
* Timeout for the debounce handler to be triggered
3232
*/
3333
debounceTimeout?: number
34+
/**
35+
* Hide the background and border of the search
36+
*/
37+
noBackgroundAndBorder?: boolean
3438
}

0 commit comments

Comments
 (0)