@ -1,14 +1,12 @@
// @flow
import React , { PureComponent } from 'react'
import styled from 'styled-components'
import { color , fontSize , space } from 'styled-system'
import fontFamily from 'styles/styled/fontFamily'
import type { LedgerScriptParams } from 'helpers/common '
import React , { PureComponent , Fragment } from 'react'
import { ff } from 'styles/ helpers'
import type { LedgerScriptParams } from 'helpers/common'
import Box from 'components/base/Box'
import Space from 'components/base/Space'
import Input from 'components/base/Input'
import Search from 'components/base/Search'
import SearchIcon from 'icons/Search'
@ -24,53 +22,13 @@ type State = {
focused : boolean ,
}
const SearchBarWrapper = styled ( Box ) . attrs ( {
horizontal : true ,
borderRadius : 4 ,
} ) `
height : 42 px ;
width : 100 % ;
margin : 0 0 20 px 0 ;
background - color : white ;
padding : 0 13 px ;
$ { p =>
p . focused
? `
border : 1 px solid # 6490 f1 ;
`
: 'border: 1px solid white;' } ;
`
const Input = styled . input . attrs ( {
ff : 'Open Sans|SemiBold' ,
color : 'dark' ,
mx : 3 ,
fontSize : 4 ,
} ) `
$ { space } ;
$ { fontFamily } ;
$ { fontSize } ;
$ { color } ;
border : 0 ;
flex : 1 ;
outline : none ;
background : transparent ;
& : : placeholder {
color : $ { p => p . theme . colors . fog } ;
$ { ( ) => ff ( 'Open Sans|Regular' ) } ;
}
`
class AppSearchBar extends PureComponent < Props , State > {
state = {
query : '' ,
focused : false ,
}
handleChange = ( e : any ) => this . setState ( { query : e . target . value } )
handleChange = ( query : string ) => this . setState ( { query } )
handleFocus = ( bool : boolean ) => ( ) => this . setState ( { focused : bool } )
@ -88,20 +46,29 @@ class AppSearchBar extends PureComponent<Props, State> {
const color = focused ? 'black' : 'grey'
return (
< Box >
< SearchBarWrapper align = "center" focused = { focused } >
< SearchIcon size = { 16 } style = { { color } } / >
< Input
innerRef = { c => ( this . input = c ) }
type = "text"
value = { query }
onChange = { this . handleChange }
onFocus = { this . handleFocus ( true ) }
onBlur = { this . handleFocus ( false ) }
placeholder = { 'Search app' }
/ >
{ ! ! query && < CrossIcon size = { 16 } cursor = "pointer" onClick = { this . reset } / > }
< / S e a r c h B a r W r a p p e r >
< Fragment >
< Input
innerRef = { c => ( this . input = c ) }
type = "text"
value = { query }
onChange = { this . handleChange }
onFocus = { this . handleFocus ( true ) }
onBlur = { this . handleFocus ( false ) }
placeholder = { 'Search app' }
renderLeft = {
< Box pl = { 3 } justify = "center" >
< SearchIcon size = { 16 } style = { { color } } / >
< / B o x >
}
renderRight = {
query ? (
< Box justify = "center" cursor = "pointer" onClick = { this . reset } px = { 3 } >
< CrossIcon size = { 16 } / >
< / B o x >
) : null
}
/ >
< Space of = { 30 } / >
< Search
fuseOptions = { {
threshold : 0.5 ,
@ -111,7 +78,7 @@ class AppSearchBar extends PureComponent<Props, State> {
items = { list }
render = { items => children ( items ) }
/ >
< / B o x >
< / F r a g m e n t >
)
}
}