mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
Load up
This commit is contained in:
parent
87bb6c8437
commit
7d3e7ffdfb
4 changed files with 21 additions and 570 deletions
|
@ -25,9 +25,9 @@ export default function FileInput({ setResult }: FileInputProps) {
|
|||
return;
|
||||
}
|
||||
const file = files[0];
|
||||
const buf = await file.arrayBuffer();
|
||||
const buf = await file.text();
|
||||
try {
|
||||
const events: AllEvents = JSON.parse(new TextDecoder().decode(buf));
|
||||
const events: AllEvents = JSON.parse(buf);
|
||||
setResult({ kind: "ok", events });
|
||||
} catch (e) {
|
||||
setResult({ kind: "err", error: "Invalid checkmate file." });
|
||||
|
@ -36,18 +36,13 @@ export default function FileInput({ setResult }: FileInputProps) {
|
|||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<label htmlFor="small-file-input" className="sr-only">
|
||||
Choose file
|
||||
</label>
|
||||
<input
|
||||
type="file"
|
||||
name="small-file-input"
|
||||
id="small-file-input"
|
||||
onChange={(e) => setFile(e)}
|
||||
className="block w-full border border-gray-200 shadow-sm rounded-md text-sm
|
||||
file:bg-roc-purple-bg file:border-0 file:mr-4 file:py-2 file:px-4"
|
||||
></input>
|
||||
</div>
|
||||
<input
|
||||
type="file"
|
||||
name="small-file-input"
|
||||
id="small-file-input"
|
||||
onChange={(e) => setFile(e)}
|
||||
className="block w-full border border-gray-200 shadow-sm rounded-md text-sm
|
||||
file:bg-roc-purple-bg file:border-0 file:mr-4 file:py-2 file:px-4 cursor-pointer"
|
||||
></input>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue