|
|
@ -1,5 +1,5 @@ |
|
|
|
import c from "classnames"; |
|
|
|
import c from "classnames"; |
|
|
|
import { useState } from "react"; |
|
|
|
import { forwardRef, useState } from "react"; |
|
|
|
|
|
|
|
|
|
|
|
import { Flare } from "@/components/utils/Flare"; |
|
|
|
import { Flare } from "@/components/utils/Flare"; |
|
|
|
|
|
|
|
|
|
|
@ -13,50 +13,53 @@ export interface SearchBarProps { |
|
|
|
value: string; |
|
|
|
value: string; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function SearchBarInput(props: SearchBarProps) { |
|
|
|
export const SearchBarInput = forwardRef<HTMLInputElement, SearchBarProps>( |
|
|
|
const [focused, setFocused] = useState(false); |
|
|
|
(props, ref) => { |
|
|
|
|
|
|
|
const [focused, setFocused] = useState(false); |
|
|
|
|
|
|
|
|
|
|
|
function setSearch(value: string) { |
|
|
|
function setSearch(value: string) { |
|
|
|
props.onChange(value, false); |
|
|
|
props.onChange(value, false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<Flare.Base |
|
|
|
<Flare.Base |
|
|
|
className={c({ |
|
|
|
className={c({ |
|
|
|
"hover:flare-enabled group relative flex flex-col rounded-[28px] transition-colors sm:flex-row sm:items-center": |
|
|
|
"hover:flare-enabled group relative flex flex-col rounded-[28px] transition-colors sm:flex-row sm:items-center": |
|
|
|
true, |
|
|
|
true, |
|
|
|
"bg-search-background": !focused, |
|
|
|
|
|
|
|
"bg-search-focused": focused, |
|
|
|
|
|
|
|
})} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<Flare.Light |
|
|
|
|
|
|
|
flareSize={400} |
|
|
|
|
|
|
|
enabled={focused} |
|
|
|
|
|
|
|
className="rounded-[28px]" |
|
|
|
|
|
|
|
backgroundClass={c({ |
|
|
|
|
|
|
|
"transition-colors": true, |
|
|
|
|
|
|
|
"bg-search-background": !focused, |
|
|
|
"bg-search-background": !focused, |
|
|
|
"bg-search-focused": focused, |
|
|
|
"bg-search-focused": focused, |
|
|
|
})} |
|
|
|
})} |
|
|
|
/> |
|
|
|
> |
|
|
|
|
|
|
|
<Flare.Light |
|
|
|
<Flare.Child className="flex flex-1 flex-col"> |
|
|
|
flareSize={400} |
|
|
|
<div className="pointer-events-none absolute bottom-0 left-5 top-0 flex max-h-14 items-center text-search-icon"> |
|
|
|
enabled={focused} |
|
|
|
<Icon icon={Icons.SEARCH} /> |
|
|
|
className="rounded-[28px]" |
|
|
|
</div> |
|
|
|
backgroundClass={c({ |
|
|
|
|
|
|
|
"transition-colors": true, |
|
|
|
<TextInputControl |
|
|
|
"bg-search-background": !focused, |
|
|
|
onUnFocus={() => { |
|
|
|
"bg-search-focused": focused, |
|
|
|
setFocused(false); |
|
|
|
})} |
|
|
|
props.onUnFocus(); |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
onFocus={() => setFocused(true)} |
|
|
|
|
|
|
|
onChange={(val) => setSearch(val)} |
|
|
|
|
|
|
|
value={props.value} |
|
|
|
|
|
|
|
className="w-full flex-1 bg-transparent px-4 py-4 pl-12 text-search-text placeholder-search-placeholder focus:outline-none sm:py-4 sm:pr-2" |
|
|
|
|
|
|
|
placeholder={props.placeholder} |
|
|
|
|
|
|
|
/> |
|
|
|
/> |
|
|
|
</Flare.Child> |
|
|
|
|
|
|
|
</Flare.Base> |
|
|
|
<Flare.Child className="flex flex-1 flex-col"> |
|
|
|
); |
|
|
|
<div className="pointer-events-none absolute bottom-0 left-5 top-0 flex max-h-14 items-center text-search-icon"> |
|
|
|
} |
|
|
|
<Icon icon={Icons.SEARCH} /> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<TextInputControl |
|
|
|
|
|
|
|
ref={ref} |
|
|
|
|
|
|
|
onUnFocus={() => { |
|
|
|
|
|
|
|
setFocused(false); |
|
|
|
|
|
|
|
props.onUnFocus(); |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
onFocus={() => setFocused(true)} |
|
|
|
|
|
|
|
onChange={(val) => setSearch(val)} |
|
|
|
|
|
|
|
value={props.value} |
|
|
|
|
|
|
|
className="w-full flex-1 bg-transparent px-4 py-4 pl-12 text-search-text placeholder-search-placeholder focus:outline-none sm:py-4 sm:pr-2" |
|
|
|
|
|
|
|
placeholder={props.placeholder} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
</Flare.Child> |
|
|
|
|
|
|
|
</Flare.Base> |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
); |
|
|
|