-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
68 lines (60 loc) · 1.66 KB
/
Copy pathApp.js
File metadata and controls
68 lines (60 loc) · 1.66 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
65
66
67
68
import React, { useState } from "react";
// eslint-disable-next-line
import { GitHubReadmeButton } from "./components/GitHubReadmeButton/GitHubReadmeButton";
import "./App.scss";
function App() {
const [repoName, setRepoName] = useState("");
const [searchRepo, setSearchRepo] = useState(
"seapagan/react-github-readme-button"
// "seapagan/fastapi-template"
// ""
);
const apply = e => {
e.preventDefault();
if (!repoName) return;
setSearchRepo(repoName.toLowerCase());
};
const handlePreDisplayHook = e => {
console.log("Pre-display Hook Fired!!");
};
const handlePostDisplayHook = e => {
console.log("Post-display Hook Fired!!");
};
return (
<div className="app">
<form autoComplete="off">
<input
autoComplete="false"
name="hidden"
type="text"
style={{ display: "none" }}
/>
<input
type="text"
autoFocus={true}
placeholder="Enter username/repository"
value={repoName}
style={{ cursor: "text" }}
onChange={e => setRepoName(e.target.value)}
/>
<button type="submit" onClick={apply}>
Set
</button>
</form>
<p className="current-repo">
Repository: <span className="repo-name">{searchRepo}</span>
</p>
<div className="click-message">
Click this to{" "}
<GitHubReadmeButton
className="button-style"
repo={searchRepo}
preDisplayHook={handlePreDisplayHook}
postDisplayHook={handlePostDisplayHook}
/>{" "}
(ESC Closes the popup)
</div>
</div>
);
}
export default App;