-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
179 lines (172 loc) · 5.54 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Random Text Generator</title>
<!-- font awesome -->
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css"
integrity="sha512-9usAa10IRO0HhonpyAIVpjrylPvoDwiPUiKdWk5t3PyolY1cOd4DSE0Ga+ri4AuTroPR5aQvXU9xC6qOPnzFeg=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
<script
crossorigin
src="https://unpkg.com/react@17/umd/react.development.js"
></script>
<script
crossorigin
src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"
></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"
integrity="sha512-kp7YHLxuJDJcOzStgd6vtpxr4ZU9kjn77e6dBsivSz+pUuAuMlE2UTdKB7jjsWT84qbS8kdCWHPETnP/ctrFsA=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
></script>
<!-- links -->
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<div id="app"></div>
<script type="text/babel">
const buttons = {};
const quotes = [
{
text: "Genius is one percent inspiration and ninety-nine percent perspiration.",
author: "Thomas Edison",
},
{
text: "You can observe a lot just by watching.",
author: "Yogi Berra",
},
{
text: "A house divided against itself cannot stand.",
author: "Abraham Lincoln",
},
{
text: "Difficulties increase the nearer we get to the goal.",
author: "Johann Wolfgang von Goethe",
},
{
text: "Fate is in your hands and no one elses",
author: "Byron Pulsifer",
},
{
text: "Be the chief but never the lord.",
author: "Lao Tzu",
},
{
text: "Nothing happens unless first we dream.",
author: "Carl Sandburg",
},
{
text: "Well begun is half done.",
author: "Aristotle",
},
{
text: "Life is a learning experience, only if you learn.",
author: "Yogi Berra",
},
{
text: "Self-complacency is fatal to progress.",
author: "Margaret Sangster",
},
{
text: "Peace comes from within. Do not seek it without.",
author: "Buddha",
},
{
text: "What you give is what you get.",
author: "Byron Pulsifer",
},
{
text: "We can only learn to love by loving.",
author: "Iris Murdoch",
},
{
text: "Life is change. Growth is optional. Choose wisely.",
author: "Karen Clark",
},
{
text: "You'll see it when you believe it.",
author: "Wayne Dyer",
},
];
// get random quote whenever clicked
function getRandomQuote() {
const randomNumber = Math.floor(Math.random() * quotes.length);
return quotes[randomNumber];
}
// Updates HTML Data when clicked
function updateQuote() {
const quote = getRandomQuote();
const quoteText = quote.text;
const quoteAuthor = quote.author;
const quoteAuthorElement = document.getElementById("author");
const quoteTextElement = document.getElementById("text");
quoteAuthorElement.innerText = quoteAuthor;
quoteTextElement.innerText = quoteText;
}
function Button(props) {
return (
<a href={props.href} id={props.a_id}>
<button id={props.id} onClick={props.onClick}>
{props.name ? props.name : <i className={props.class}></i>}
</button>
</a>
);
}
function App() {
return (
<div className="full-height column horiz-center">
<h1>Random Text Generator</h1>
<div id="quote-box">
<div>
<p id="text" className="quote">
{/* get the value each time the quote is updated */}
{getRandomQuote().text}
</p>
<p id="author">{getRandomQuote().author}</p>
</div>
<div className="row space-between">
<div className="left">
<Button
href="https://www.linkedin.com/in/acme-gamers/"
class="fa-brands fa-linkedin"
/>
<Button
href="https://github.com/AcmeGamers"
class="fa-brands fa-github"
/>
</div>
<div className="right">
<Button
href={
"https://twitter.com/intent/tweet?text=" +
getRandomQuote().text +
" - " +
getRandomQuote().author
}
class="fa-brands fa-twitter"
a_id="tweet-quote"
/>
<Button
href="#"
id="new-quote"
name="Next Quote"
onClick={() => updateQuote()}
/>
</div>
</div>
</div>
</div>
);
}
ReactDOM.render(<App />, document.getElementById("app"));
</script>
</body>
</html>