Last active
October 12, 2021 15:45
-
-
Save nazifbara/2b4f39ccef6e4a401455619cabf09dce to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import styled from 'styled-components'; | |
const Autocomplete = () => { | |
const handleSubmit = (e) => { | |
e.preventDefault(); | |
}; | |
return ( | |
<div> | |
<Form autoComplete="off" onSubmit={handleSubmit}> | |
<Container> | |
<Input/> | |
<SubmitButton> | |
<SearchIcon /> | |
</SubmitButton> | |
</Container> | |
</Form> | |
</div> | |
); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
The autocomplete list will be absolute-positioned relatively | |
to this div | |
*/ | |
const Container = styled.div` | |
position: relative; | |
`; | |
/* | |
A container for the autocomplete items | |
*/ | |
const List = styled.div` | |
position: absolute; | |
top: 100%; | |
left: 0; | |
right: 0; | |
height: 40vh; | |
background-color: #293241; | |
border-radius: 0 0 5px 5px; | |
overflow-y: scroll; | |
`; | |
const Item = styled.div` | |
border-left: 3px solid ${({ active }) => (active ? 'blue' : 'initial')}; | |
background-color: ${({ active }) => (active ? 'gray' : 'initial')}; | |
padding: 0 15px; | |
color: ${({ active }) => (active ? 'white' : '#f2e9e4')}; | |
&:hover { | |
background-color: gray; | |
} | |
`; | |
const Input = styled.input` | |
background-color: #293241; | |
color: #f2e9e4; | |
border: none; | |
width: 400px; | |
padding: 15px 15px; | |
border-radius: 5px 0 0 0; | |
&:focus { | |
outline: none; | |
} | |
`; | |
const Match = styled.b` | |
color: #c9ada7; | |
`; | |
const Form = styled.form` | |
width: 100vw; | |
height: 100vh; | |
background-color: #4a4e69; | |
padding-top: 10%; | |
display: flex; | |
align-items: flex-start; | |
justify-content: center; | |
`; | |
const SubmitButton = styled.button` | |
outline: none; | |
background-color: #293241; | |
padding: 15px 20px; | |
border: none; | |
color: #f2e9e4; | |
border-radius: 0 5px 0 0; | |
&:focus { | |
outline: none; | |
} | |
`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment