Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

first commit #214

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Random Quote Generator -- Simple API</title>
<link href="https://fonts.googleapis.com/css2?family=Rubik:wght@400;600&display=swap" rel="stylesheet" />
<link rel="stylesheet" href="style.css" />
</head>

<body>
<h1> Random Quote Generator </h1>
<div class="wrapper">
<div class="container">
<p id="quote">
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Voluptas,
magni.
</p>
<h3 id="author">Lorem, ipsum.</h3>
<button id="btn">Get Quote</button>
</div>
</div>
<script src="main.js"></script>
</body>

</html>
17 changes: 17 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
let quote = document.getElementById("quote");
let author = document.getElementById("author");
let btn = document.getElementById("btn");

const url = "https://api.quotable.io/random";

let getQuote = () => {
fetch(url)
.then((data) => data.json())
.then((item) => {
quote.innerText = item.content;
author.innerText = item.author;
});
};

window.addEventListener("load", getQuote);
btn.addEventListener("click", getQuote);
56 changes: 56 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
* {
padding: 0;
margin: 0;
box-sizing: border-box;
font-family: "Rubik", sans-serif;
}
body {
background-color: #8135f4;
}

body h1 {
text-align: center;
justify-content: center;
padding-top: 25px;
font-size: 40px;
color: #ffffff;
}
.wrapper {
width: 400px;
position: absolute;
transform: translate(-50%, -50%);
top: 50%;
left: 50%;
}
.container {
width: 100%;
background-color: #8135f4;
padding: 50px 40px;
box-shadow: 0 20px 65px rgba(84, 18, 147, 0.463);
position: relative;
border-radius: 8px;
text-align: center;
}

.container p {
color: #ffffff;
line-height: 2;
font-size: 24px;
}
.container h3 {
color: #ffffff;
margin: 20px 0 60px 0;
font-weight: 600;
font-size: 24px;
text-transform: capitalize;
}
.container button {
background-color: #ffffff;
border: none;
padding: 15px 45px;
border-radius: 5px;
font-size: 28px;
font-weight: 600;
color: #8135f4;
cursor: pointer;
}