Skip to content
Merged
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
34 changes: 34 additions & 0 deletions Fronted Projects/Advice generator app/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const btn=document.querySelector("button");
const h1=document.querySelector("h1");
const span=document.querySelector("span");

// Fetching API

let id=1;
const url="https://api.adviceslip.com/advice"
const getData=async function(){
const xhr=new XMLHttpRequest();
const response=await fetch(`${url}/${Math.floor(Math.random() * 118) + 1}`);
if(response.ok){
const data=await response.json();
return data;
}
else{
console.log("something went wrong..");
}
}


btn.addEventListener("click",()=>{

getData()
.then(data=>{
id++;
span.textContent=id;
h1.textContent=`"${data.slip.advice}"`;
})
.catch(()=>{
console.log("Check your internet connection");
})
btn.classList.toggle('rotate');
})
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions Fronted Projects/Advice generator app/images/icon-dice.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions Fronted Projects/Advice generator app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!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">
<script src="./app.js" defer></script>
<title>Advice Generator App</title>
</head>
<body>
<div class="box">
<h3>advice #<span>1</span></h3>
<h1>"Luck comes from hard work. Luck happens when hard work and timing and talent intersect."</h1>
<img src="./images/pattern-divider-desktop.svg" alt="divider image">
<button></button>
<div class="circle"></div>

</div>
</body>
</html>
101 changes: 101 additions & 0 deletions Fronted Projects/Advice generator app/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@800&display=swap');
*{
margin:0;
padding:0;
box-sizing:border-box;
}
html{
font-size:62.5%;
}
:root{
--primary-lightCyan: hsl(193, 38%, 86%);
--primary-neonGreen: hsl(150, 100%, 66%);
--neutral-grayishBlue:hsl(217, 19%, 38%);
--dark-grayishBlue: hsl(217, 19%, 24%);
--darkBlue: hsl(218, 23%, 16%);
--quote-fontWeight:800;
--fontFamily:'Manrope', sans-serif;

}

body{
height:100vh;
width:100%;
display:flex;
justify-content:center;
align-items:center;
font-family:var(--fontFamily);
background:var(--darkBlue)
}
.box{
max-width:470px;
width:90%;
height:290px;
border-radius:15px;
display:flex;
flex-direction:column;
align-items:center;
position:relative;
background:var(--dark-grayishBlue)
}
h1{
font-size:2.5em;
width:90%;
text-align:center;
color:var(--primary-lightCyan);
}
img{
width:80%;
position:absolute;
top:75%;
}
h3{
text-transform:uppercase;
letter-spacing:3px;
margin:2em 0;
color:var(--primary-neonGreen);
font-weight:var(--quote-fontWeight);
}
.circle{
width:62px;
height:60px;
border-radius:50%;
background:var(--primary-neonGreen);
position:absolute;
top:89%;
transition:all 0.5s ease;
}
button{
height: 26px;
width: 27px;
border-radius:5px;
background:url(./images/icon-dice.svg);
background-position: center;
background-size: cover;
outline:none;
border:none;
position:absolute;
top:95%;
cursor:pointer;
z-index:9;
transition: transform 0.4s ease-in-out;


}
button.rotate{
transform: rotate(360deg);
}
button:hover +.circle,
.circle:hover{
box-shadow: 0 0 20px hsl(150, 100%, 66%), 0 0 40px hsl(150, 100%, 66%);
}

/* for small devices */
@media(max-width:500px){
html{
font-size:56.25%;
}
.box{
height:300px;
}
}