Skip to content

Commit

Permalink
Merge pull request #163 from shukria-sultani/features
Browse files Browse the repository at this point in the history
Added the joke generator challenge
  • Loading branch information
AkshitGarg24 authored Oct 7, 2024
2 parents b18b5e6 + d73437a commit cc46754
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"workbench.colorCustomizations": {
"activityBar.background": "#392836",
"titleBar.activeBackground": "#50384B",
"titleBar.activeForeground": "#FBFAFB"
}
}
Binary file added 24-joke-generator/design/desktop-design.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 24-joke-generator/design/mobile-design.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions 24-joke-generator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
<title>Joke Generator</title>
</head>
<body>
<div class="container">
<span>&#128514;</span>
<p id="jokeText"></p>
<button id="btn">Generate Joke</button>
</div>

<div class="designer">
Be happy! Designed by <a href="https://github.com/shukria-sultani">Shurkia💙</a>
</div>

<script src="script.js"></script>
</body>
</html>
22 changes: 22 additions & 0 deletions 24-joke-generator/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const jokeText = document.getElementById('jokeText');
let button = document.getElementById('btn');
let url = "https://v2.jokeapi.dev/joke/Any?blacklistFlags=nsfw,religious,political,racist,explicit&type=single"

const getJoke = () => {
return new Promise((resolve, reject) => {
fetch(url)
.then(data => data.json())
.then(item => {
jokeText.textContent = item.joke;
resolve();
})
.catch(error => {
console.error('Error fetching joke:', error);
});
});
}

button.addEventListener('click', getJoke);



50 changes: 50 additions & 0 deletions 24-joke-generator/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
*{
font-family: "Montserrat", sans-serif;
}
body{
background-color: orange;
}
.container{
position: absolute;
padding: 50px , 40px;
transform: translate(-50%,-50%);
left: 50%;
top: 50%;
background-color: black;
box-shadow: 20px 15px 20px 0 #232323;
width: 80vmin;
}
.container span{
display: block;
text-align: center;
font-size: 100px;
}
.container p{
color: #fff;
text-align: center;
word-wrap: break-word;
margin: 10px 5;
font-weight: 400;
padding: 10px;
line-height: 30px;
}
.container button{
display: block;
background-color: orange;
border: none;
padding: 12px 25px;
margin: 0 auto;
margin-bottom: 10px;
font-size: 18px;
text-align: center;
border-radius: 10px;
cursor: pointer;

}
.container button:hover{
box-shadow: 3px 0px 5px 5px orange;
}
.designer{
text-align: center;
padding-top: 20px;
}
3 changes: 3 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ const projects = [
{
name: "23-Weather-App",
},
{
name: "24-joke-generator",
},
];

const list = document.getElementById("list");
Expand Down
1 change: 0 additions & 1 deletion style.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
* {

margin: 0px;
padding: 0px;
box-sizing: border-box;
Expand Down

0 comments on commit cc46754

Please sign in to comment.