/
StyledSearchBox.js
45 lines (40 loc) · 957 Bytes
/
StyledSearchBox.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import styled, { css } from 'styled-components';
import SearchBox from './SearchBox';
const open = css`
width: 10em;
background: ${({ theme }) => theme.background};
cursor: text;
margin-left: -1.6em;
padding-left: 1.6em;
`;
const closed = css`
width: 0;
background: transparent;
cursor: pointer;
margin-left: -1em;
padding-left: 1em;
`;
export default styled(SearchBox)`
display: flex;
flex-direction: row-reverse;
align-items: center;
margin-bottom: 0;
.SearchInput {
outline: none;
border: ${({ hasFocus }) => (hasFocus ? 'auto' : 'none')};
font-size: 1em;
transition: 100ms;
border-radius: 2px;
color: ${({ theme }) => theme.foreground};
::placeholder {
color: ${({ theme }) => theme.faded};
}
${({ hasFocus }) => (hasFocus ? open : closed)}
}
.SearchIcon {
width: 1em;
margin: 0.3em;
color: ${({ theme }) => theme.foreground};
pointer-events: none;
}
`;