import Link from 'next/link' import React, { RefObject, FormEvent } from 'react' import { ChevronDown, ChevronRight } from 'react-feather' import config from '../config' import '../styl/styl.styl' interface Props { categories?: Array onQuery?: (query: string, sort?: boolean) => void onHeight?: (height: number) => void } interface States { follow?: boolean height?: number } export default class Filters extends React.Component { private input: RefObject public constructor(props: Props) { super(props) this.input = React.createRef() } public render() { return ( ) } private onKeyDown = (ev: React.KeyboardEvent) => { setTimeout(() => { this.submit() }, 1) } private onClick = () => { if (this.input.current?.value !== '') { this.submit() return } this.input.current.focus() } private onChange = (ev: React.KeyboardEvent|FormEvent) => { this.submit((ev.target as HTMLInputElement).value === 'true') } private submit = (sort?: boolean) => { if (this.props.onQuery && this.input.current?.value) { this.props.onQuery(this.input.current.value, sort) } } }