Anki/react/src/ui/BrowseSearchInput.tsx
Damien Elmes 82f0db7583 add a web UI proof of concept
See react/README
2020-01-06 14:28:07 +10:00

30 lines
632 B
TypeScript

import React from "react";
interface BrowseSearchInputProps {
onSearchChanged: (txt: string) => void;
}
export const BrowseSearchInput = ({
onSearchChanged
}: BrowseSearchInputProps) => {
let currentInput = "";
function onInput(e: React.FormEvent<HTMLFormElement>) {
e.preventDefault();
onSearchChanged(currentInput);
}
function onInputChange(e: React.FormEvent<HTMLInputElement>) {
currentInput = (e.target as any).value;
}
return (
<form onSubmit={onInput}>
<input
onChange={onInputChange}
autoFocus
placeholder="Hit enter to search"
/>
</form>
);
};