seach improvement

This commit is contained in:
Jan Prochazka
2020-05-10 21:17:15 +02:00
parent c82f332c42
commit 125ba3b0c8
6 changed files with 82 additions and 65 deletions

View File

@@ -0,0 +1,26 @@
import React from 'react';
import styled from 'styled-components';
import keycodes from '../utility/keycodes';
const StyledInput = styled.input`
flex: 1;
min-width: 90px;
`;
export default function SearchInput({ placeholder, filter, setFilter }) {
const handleKeyDown = (ev) => {
if (ev.keyCode == keycodes.escape) {
setFilter('');
}
};
return (
<StyledInput
type="text"
placeholder={placeholder}
value={filter}
onChange={(e) => setFilter(e.target.value)}
onFocus={(e) => e.target.select()}
onKeyDown={handleKeyDown}
/>
);
}