Skip to content

Commit

Permalink
SP-07: Update search
Browse files Browse the repository at this point in the history
  • Loading branch information
Tihi321 committed Aug 9, 2024
1 parent a9d0d61 commit 86d7099
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/blocks/inputs/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,19 @@ import {
getZenvaSearch,
} from "./utils";

const Container = styled("div")`
const Container = styled("div")<{ focus: boolean }>`
width: 100%;
display: flex;
flex-direction: column;
justify-content: center;
gap: 8px;
margin: 48px 0;
opacity: ${(props) => (props.focus ? 0.9 : 0.6)};
transition: opacity 0.3s;
&:hover {
opacity: 0.9;
}
`;

const SearchContainer = styled("div")`
Expand Down Expand Up @@ -68,6 +74,10 @@ const Input = styled("input")`
&::placeholder {
color: var(--text);
}
&:focus {
outline: none;
}
`;

const Submit = styled("button")`
Expand Down Expand Up @@ -178,6 +188,7 @@ const sendMusicSearch = (search: string, openOutside = false) => {
export const Search = () => {
const [searchType, setSearchType] = createSignal<string>("ai");
const [search, setSearch] = createSignal<string>("");
const [searchFocus, setSearchFocus] = createSignal<boolean>(false);

const sendSearch = (openOutside = false) => {
if (searchType() === "ai") {
Expand All @@ -194,7 +205,7 @@ export const Search = () => {
}
};
return (
<Container>
<Container focus={searchFocus()}>
<SearchContainer>
<Input
onInput={(e) => {
Expand All @@ -208,6 +219,12 @@ export const Search = () => {
type="text"
placeholder="Search"
value={search()}
onFocus={(e) => {
setSearchFocus(true);
}}
onBlur={(e) => {
setSearchFocus(false);
}}
/>
<Submit
onMouseDown={(e) => {
Expand Down

0 comments on commit 86d7099

Please sign in to comment.