Loëck Vézien
7 years ago
committed by
GitHub
7 changed files with 144 additions and 26 deletions
@ -0,0 +1,41 @@ |
|||
// @flow
|
|||
|
|||
import React, { PureComponent } from 'react' |
|||
import styled from 'styled-components' |
|||
|
|||
import Box from 'components/base/Box' |
|||
import Icon from 'components/base/Icon' |
|||
|
|||
const Input = styled.input` |
|||
border: none; |
|||
background: transparent; |
|||
outline: none; |
|||
flex-grow: 1; |
|||
|
|||
&::placeholder { |
|||
color: ${p => p.theme.colors.warmGrey}; |
|||
} |
|||
` |
|||
|
|||
class GlobalSearch extends PureComponent { |
|||
_input = null |
|||
|
|||
focusInput = () => { |
|||
if (this._input) { |
|||
this._input.focus() |
|||
} |
|||
} |
|||
|
|||
render() { |
|||
return ( |
|||
<Box grow horizontal> |
|||
<Box justify="center" onClick={this.focusInput} pr={2}> |
|||
<Icon name="search" /> |
|||
</Box> |
|||
<Input placeholder="Search" innerRef={input => (this._input = input)} /> |
|||
</Box> |
|||
) |
|||
} |
|||
} |
|||
|
|||
export default GlobalSearch |
@ -0,0 +1,38 @@ |
|||
// @flow
|
|||
|
|||
import React from 'react' |
|||
|
|||
import Text from 'components/base/Text' |
|||
import Box from 'components/base/Box' |
|||
|
|||
type Props = { |
|||
boldWeight?: string | number, |
|||
normalWeight?: string | number, |
|||
isBold: boolean, |
|||
children: any, |
|||
} |
|||
|
|||
function BoldToggle(props: Props) { |
|||
const { boldWeight, normalWeight, isBold, children, ...p } = props |
|||
return ( |
|||
<Box relative> |
|||
<Text fontWeight={boldWeight} style={{ opacity: isBold ? 1 : 0 }} {...p}> |
|||
{children} |
|||
</Text> |
|||
{!isBold && ( |
|||
<Box sticky align="center" justify="center"> |
|||
<Text fontWeight={normalWeight} {...p}> |
|||
{children} |
|||
</Text> |
|||
</Box> |
|||
)} |
|||
</Box> |
|||
) |
|||
} |
|||
|
|||
BoldToggle.defaultProps = { |
|||
boldWeight: 600, |
|||
normalWeight: 400, |
|||
} |
|||
|
|||
export default BoldToggle |
Loading…
Reference in new issue