-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathheader.js
More file actions
64 lines (62 loc) · 1.61 KB
/
Copy pathheader.js
File metadata and controls
64 lines (62 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import React, { useState } from "react";
// eslint-disable-next-line import/no-extraneous-dependencies
import PropTypes from "prop-types";
import { CgSoftwareDownload, CgMathPlus } from "react-icons/cg";
import {
HeaderContainer,
NoteEditContainer,
NoteTitle,
DownloadNoteBook,
AddNoteInput,
AddNoteLabel,
} from "./header.style";
export default function Header({ download, load }) {
const [noteName, setNoteName] = useState("untitled.json");
const onNoteTitleChange = (e) => {
setNoteName(e);
};
return (
<HeaderContainer>
<div></div>
<NoteEditContainer>
<NoteTitle
onChange={(e) => onNoteTitleChange(e.target.value)}
type="text"
value={noteName}
/>
<div>
<AddNoteLabel htmlFor="import-notebook-file">
{" "}
<CgMathPlus
style={{
fontSize: "24px",
}}
/>
</AddNoteLabel>
<AddNoteInput
type="file"
id="import-notebook-file"
onChange={() => {
const fileName = load();
const name = `${fileName.split(".")[0]}.ipynb`;
onNoteTitleChange(name);
}}
/>
</div>
</NoteEditContainer>
<DownloadNoteBook onClick={() => download(noteName)}>
{" "}
<CgSoftwareDownload
style={{
fontSize: "20px",
}}
/>{" "}
Download Notebook
</DownloadNoteBook>
</HeaderContainer>
);
}
Header.propTypes = {
load: PropTypes.func.isRequired,
download: PropTypes.func.isRequired,
};