forked from LaconicNetwork/icns-frontend
Merge branch 'Thunnini/improve-search-input'
This commit is contained in:
commit
1693167982
@ -1,4 +1,4 @@
|
|||||||
import { Dispatch, FunctionComponent, SetStateAction } from "react";
|
import { Dispatch, FunctionComponent, SetStateAction, useState } from "react";
|
||||||
|
|
||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
import color from "../../styles/color";
|
import color from "../../styles/color";
|
||||||
@ -13,9 +13,11 @@ interface Props {
|
|||||||
export const SearchInput: FunctionComponent<Props> = (props) => {
|
export const SearchInput: FunctionComponent<Props> = (props) => {
|
||||||
const { searchValue, setSearchValue } = props;
|
const { searchValue, setSearchValue } = props;
|
||||||
|
|
||||||
|
const [isFocused, setIsFocused] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SearchContainer>
|
<SearchContainer>
|
||||||
<SearchIconContainer>
|
<SearchIconContainer focused={isFocused}>
|
||||||
<SearchIcon />
|
<SearchIcon />
|
||||||
</SearchIconContainer>
|
</SearchIconContainer>
|
||||||
|
|
||||||
@ -26,6 +28,12 @@ export const SearchInput: FunctionComponent<Props> = (props) => {
|
|||||||
onChange={(event) => {
|
onChange={(event) => {
|
||||||
setSearchValue(event.target.value);
|
setSearchValue(event.target.value);
|
||||||
}}
|
}}
|
||||||
|
onFocus={() => {
|
||||||
|
setIsFocused(true);
|
||||||
|
}}
|
||||||
|
onBlur={() => {
|
||||||
|
setIsFocused(false);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</SearchContainer>
|
</SearchContainer>
|
||||||
);
|
);
|
||||||
@ -44,11 +52,19 @@ const SearchContainer = styled.div`
|
|||||||
background-color: ${color.grey["700"]};
|
background-color: ${color.grey["700"]};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const SearchIconContainer = styled.div`
|
const SearchIconContainer = styled.div<{
|
||||||
|
focused: boolean;
|
||||||
|
}>`
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
width: 1.3rem;
|
width: ${({ focused }) => (focused ? 0 : "1.3rem")};
|
||||||
height: 1.3rem;
|
height: 1.3rem;
|
||||||
|
|
||||||
|
transition: width 0.2s ease-out;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const SearchText = styled.input`
|
const SearchText = styled.input`
|
||||||
@ -75,5 +91,10 @@ const SearchText = styled.input`
|
|||||||
outline: none;
|
outline: none;
|
||||||
|
|
||||||
width: 10rem;
|
width: 10rem;
|
||||||
|
|
||||||
|
::placeholder,
|
||||||
|
::-webkit-input-placeholder {
|
||||||
|
color: ${color.grey["600"]};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
Loading…
Reference in New Issue
Block a user