Created
January 28, 2019 02:21
-
-
Save thomasJang/9ee6986cdd6775fa31e1202c1fc3dc03 to your computer and use it in GitHub Desktop.
Filter.tsx
This file contains 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 * as React from "react"; | |
import styled from "styled-components"; | |
import { Input, Icon } from "antd"; | |
const Container = styled.div` | |
margin: 10px auto; | |
padding: 0 10px; | |
`; | |
export interface IFilterProps { | |
filter?: string; | |
width?: number; | |
onChange?: (filter: string) => void; | |
} | |
export default class Filter extends React.Component<IFilterProps> { | |
render() { | |
const { filter, width, onChange } = this.props; | |
return ( | |
<Container style={{ width }}> | |
<Input | |
defaultValue={filter} | |
suffix={ | |
filter ? ( | |
<Icon | |
type="close" | |
onClick={() => { | |
onChange(""); | |
}} | |
/> | |
) : null | |
} | |
onChange={e => { | |
onChange(e.target.value); | |
}} | |
/> | |
</Container> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment