-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit dc2f912
Showing
4 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" dir="ltr"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>QR Code Generator</title> | ||
<link rel="stylesheet" href="styles.css"> | ||
|
||
</head> | ||
<body> | ||
<div class="wrapper"> | ||
<header> | ||
<h1>QR Code Generator</h1> | ||
<p>Paste a URL or enter text to create QR code</p> | ||
</header> | ||
<div class="form"> | ||
<input type="text" placeholder="Enter text or url"> | ||
<button>Generate QR Code</button> | ||
</div> | ||
<div class="qr-code"> | ||
<img src="" alt="qr-code"> | ||
</div> | ||
</div> | ||
|
||
<script src="script.js"></script> | ||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const wrapper = document.querySelector(".wrapper"), | ||
qrInput = wrapper.querySelector(".form input"), | ||
generateBtn = wrapper.querySelector(".form button"), | ||
qrImg = wrapper.querySelector(".qr-code img"); | ||
|
||
generateBtn.addEventListener("click", () => { | ||
let qrValue = qrInput.value; | ||
if(!qrValue) return; | ||
generateBtn.innerText = "Generating QR Code..."; // if the input is empty then return from here | ||
// getting a QR Code of user entered value using the qrserver | ||
// api and passing the api returned img src to qrImg | ||
qrImg.src = `https://api.qrserver.com/v1/create-qr-code/?size=170x170&data=${qrValue}`; | ||
qrImg.addEventListener("load", () => { | ||
wrapper.classList.add("active"); | ||
generateBtn.innerText = "Generate QR Code"; | ||
}); | ||
}); | ||
|
||
qrInput.addEventListener("keyup", () => { | ||
if(!qrInput.value) { | ||
wrapper.classList.remove("active"); | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
@import url('https://fonts.googleapis.com/css?family=Poppins:wght@400;500;600;700&display=swap'); | ||
* { | ||
margin: 0; | ||
padding: 0; | ||
box-sizing: border-box; | ||
font-family: 'Poppins', sans-serif; | ||
} | ||
|
||
body { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
min-height: 100vh; | ||
background: #8968cd; | ||
} | ||
|
||
.wrapper { | ||
background: #fff; | ||
max-width: 410px; | ||
border-radius: 7px; | ||
padding: 16px 25px; | ||
height: 260px; | ||
transition: height 0.2s ease; | ||
} | ||
|
||
.wrapper.active { | ||
height: 570px; | ||
} | ||
|
||
header h1 { | ||
font-size: 21px; | ||
font-weight: 500; | ||
} | ||
|
||
header p { | ||
font-size: 16px; | ||
color: #474747; | ||
margin-top: 5px; | ||
} | ||
|
||
.wrapper .form { | ||
margin: 20px 0 25px; | ||
} | ||
|
||
.form :where(input, button){ | ||
width: 100%; | ||
height: 55px; | ||
border: none; | ||
outline: none; | ||
border-radius: 5px; | ||
} | ||
|
||
.form input { | ||
border: 1px solid #999; | ||
font-size: 18px; | ||
padding: 0 17px; | ||
} | ||
|
||
.form button { | ||
color: #fff; | ||
cursor: pointer; | ||
margin-top: 20px; | ||
background: #8968cd; | ||
font-size: 17px; | ||
} | ||
|
||
.wrapper .qr-code { | ||
border: 1px solid #ccc; | ||
padding: 33px 0; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
border-radius: 5px; | ||
opacity: 0; | ||
pointer-events: none; | ||
} | ||
|
||
.wrapper.active .qr-code { | ||
opacity: 1; | ||
pointer-events: auto; | ||
transition: opacity 0.5s 0.05s ease; | ||
} |