Skip to content

Commit

Permalink
completed dad jokes
Browse files Browse the repository at this point in the history
  • Loading branch information
tsr-kairi committed Jul 1, 2021
1 parent d9fa82d commit 26197f2
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Day 10 - Dad Jokes/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Block Elements and Variables
const jokeEl = document.getElementById("joke");
const jokeBtn = document.getElementById("jokeBtn");

jokeBtn.addEventListener("click", generateJoke);

generateJoke();


// Functions 1....async/await
async function generateJoke() {
const config = {
headers: {
Accept: "application/json",
},
};

const res = await fetch("https://icanhazdadjoke.com", config);

const data = await res.json();

jokeEl.innerHTML = data.joke;
}

// Functions 2.... using.then();
// function generateJoke() {
// const config = {
// headers: {
// Accept: "application/json",
// },
// };

// fetch("https://icanhazdadjoke.com", config)
// .then((res) => res.json())
// .then((data) => {
// jokeEl.innerHTML = data.joke;
// });
// }
19 changes: 19 additions & 0 deletions Day 10 - Dad Jokes/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!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" />
<link rel="stylesheet" href="./style.css" />
<title>Dad | Jokes</title>
</head>
<body>
<div class="container">
<h3>Don't Lough Challenge!</h3>
<div id="joke" class="joke">// Joke gose here</div>
<button id="jokeBtn" class="btn">Get Another Joke</button>
</div>

<script src="./app.js"></script>
</body>
</html>
65 changes: 65 additions & 0 deletions Day 10 - Dad Jokes/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
@import url("https://fonts.googleapis.com/css2?family=Roboto&family=Pattaya&display=swap");

*::after,
*::before {
box-sizing: border-box;
margin: 0;
padding: 0;
}

body {
background-color: #686de0;
font-family: "Roboto", sans-serif;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
height: 100vh;
overflow: hidden;
margin: 0;
padding: 20px;
}

.container {
background-color: #fff;
border-radius: 10px;
box-shadow: 0 0 10px 20px rgba(0, 0, 0, 0.2), 0 6px 6px rgba(0, 0, 0, 0.2);
padding: 30px 5px;
text-align: center;
max-width: 100%;
width: 600px;
}

h3 {
margin: 0;
opacity: 0.5;
letter-spacing: 2px;
}

.joke {
font-size: 25px;
letter-spacing: 1px;
line-height: 40px;
margin: 50px auto;
min-width: 400px;
}

.btn {
background-color: #9f68e0;
color: #fff;
border: 0;
border-radius: 10px;
box-shadow: 0 0 5px 15px rgba(0, 0, 0, 0.1), 0 6px 6px rgba(0, 0, 0, 0.1);
padding: 14px 40px;
font-size: 1rem;
cursor: pointer;
}

.btn:active {
transform: scale(0.98);
}

.btn:focus {
outline: 0;
}

0 comments on commit 26197f2

Please sign in to comment.