-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
105 lines (98 loc) · 3.09 KB
/
index.html
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Is It Going Up?</title>
<script src="https://unpkg.com/react@17/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/@babel/[email protected]/babel.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/chance.min.js"></script>
<script
src="https://kit.fontawesome.com/1da15c100c.js"
crossorigin="anonymous"
></script>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.9.2/css/bulma.min.css"
/>
<style type="text/css">
html,
body,
#root {
height: 100%;
}
.section {
height: 100%;
display: flex;
flex-direction: column;
}
.content {
flex-grow: 1;
}
.stock-field {
display: flex;
align-items: center;
font-size: 20px;
margin-bottom: 20px;
}
.stock-field input {
margin: 0px 8px;
}
.results {
margin-top: 10px;
}
</style>
</head>
<body>
<div id="root"></div>
<script type="text/babel">
const { useState } = React;
function App() {
const [coinFlipResult, setCoinFlipResult] = useState();
const [inputValue, setInputValue] = useState("");
const flipCoin = () => {
const dt = new Date().toISOString().slice(0, 10);
const chance = new Chance(`${dt} ${inputValue.toUpperCase()}`);
const result = chance.integer({ min: 1, max: 2 });
setCoinFlipResult(result);
};
const handleInputChange = (e) => setInputValue(e.target.value);
return (
<section className="section">
<div className="content">
<div className="stock-field">
<span>Is</span>
<input
placeholder="it all"
type="text"
onChange={handleInputChange}
className="input is-medium"
style={{ maxWidth: "150px" }}
/>
<span>going up?</span>
</div>
<button className="button is-info is-medium" onClick={flipCoin}>
<span>Flip a coin</span>
</button>
<div className="results is-size-3">
{!coinFlipResult ? null : coinFlipResult === 1 ? (
<span>Yes</span>
) : (
<span>No</span>
)}
<span className="icon">
<i className="fas fa-arrow-trend-up"></i>
</span>
</div>
</div>
<div className="has-text-centered is-size-6">
This is a joke, and not financial advice of any kind.
</div>
</section>
);
}
ReactDOM.render(<App />, document.getElementById("root"));
</script>
</body>
</html>