Skip to content

Commit 593b44c

Browse files
committed
add dad jokes
1 parent f97581f commit 593b44c

File tree

4 files changed

+105
-1
lines changed

4 files changed

+105
-1
lines changed

Diff for: 08-form wave animation/style.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ body {
5050
}
5151

5252
.btn:active {
53-
transform: scaleX(0.98);
53+
transform: scale(0.98);
5454
}
5555

5656
.text {

Diff for: 10-dad jokes/index.html

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<!-- <link
7+
rel="stylesheet"
8+
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css"
9+
integrity="sha512-+4zCK9k+qNFUR5X+cKL9EIR+ZOhtIloNl9GIKS57V1MyNsYpYcUrUeQc9vNfzsWfV28IaLL3i96P9sdNyeRssA=="
10+
crossorigin="anonymous"
11+
/> -->
12+
<link rel="stylesheet" href="style.css" />
13+
<title>Dad Jokes</title>
14+
</head>
15+
<body>
16+
<div class="container">
17+
<h3>Don't Laugh Challenge</h3>
18+
<div id="joke" class="joke">// Joke goes here</div>
19+
<button id="jokeBtn" class="btn">Get Another Joke</button>
20+
</div>
21+
<script src="script.js"></script>
22+
</body>
23+
</html>

Diff for: 10-dad jokes/script.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const jokeEl = document.getElementById("joke");
2+
const jokeBtn = document.getElementById("jokeBtn");
3+
4+
const generateJoke = async () => {
5+
const config = {
6+
headers: { Accept: "application/json" },
7+
};
8+
const res = await fetch("https://icanhazdadjoke.com/", config);
9+
const data = await res.json();
10+
jokeEl.innerHTML = data.joke;
11+
12+
// Fetching with .then()
13+
// fetch("https://icanhazdadjoke.com/", config)
14+
// .then((res) => res.json())
15+
// .then((data) => (jokeEl.innerHTML = data.joke));
16+
};
17+
18+
generateJoke();
19+
20+
jokeBtn.addEventListener("click", () => generateJoke());

Diff for: 10-dad jokes/style.css

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
@import url("https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap");
2+
3+
* {
4+
box-sizing: border-box;
5+
}
6+
7+
body {
8+
background-color: #686de0;
9+
font-family: "Roboto", sans-serif;
10+
display: flex;
11+
flex-direction: column;
12+
align-items: center;
13+
justify-content: center;
14+
height: 100vh;
15+
overflow: hidden;
16+
margin: 0;
17+
padding: 20px;
18+
}
19+
20+
.container {
21+
background-color: #fff;
22+
border-radius: 10px;
23+
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1), 0 6px 6px rgba(0, 0, 0, 0.1);
24+
padding: 50px 20px;
25+
text-align: center;
26+
max-width: 100%;
27+
width: 800px;
28+
}
29+
30+
h3 {
31+
margin: 0;
32+
opacity: 0.5;
33+
letter-spacing: 2px;
34+
}
35+
36+
.joke {
37+
font-size: 30px;
38+
letter-spacing: 1px;
39+
line-height: 40px;
40+
margin: 50px auto;
41+
max-width: 600px;
42+
}
43+
44+
.btn {
45+
background-color: #9f68e0;
46+
color: #fff;
47+
border: 0;
48+
border-radius: 10px;
49+
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1), 0 6px 6px rgba(0, 0, 0, 0.1);
50+
padding: 14px 40px;
51+
font-size: 16px;
52+
cursor: pointer;
53+
}
54+
55+
.btn:active {
56+
transform: scale(0.98);
57+
}
58+
59+
.btn:focus {
60+
outline: 0;
61+
}

0 commit comments

Comments
 (0)