Skip to content

Commit

Permalink
new 2 forms
Browse files Browse the repository at this point in the history
qr
voice
  • Loading branch information
ratnojitsaha committed Feb 25, 2024
1 parent f4ab0a8 commit c677c43
Show file tree
Hide file tree
Showing 6 changed files with 374 additions and 0 deletions.
37 changes: 37 additions & 0 deletions Components/Forms/QR-Code-Generator-Form/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!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="main.css">
<title>QR Code Generator Form</title>
</head>
<body>
<div class="box">
<div class="qr-header">
<h1>Generate QR Code</h1>
<input type="text" placeholder="Type your text or URL" id="qr-text">
<div>
<!---THIS LETS THE USER TO SELECT THE SIZES OF THE QR CODES-->
<label for="sizes">Select Size:</label>
<select id="sizes">
<option value="100">100x100</option>
<option value="200">200x200</option>
<option value="300">300x300</option>
<option value="400">400x400</option>
<option value="500">500x500</option>
</select>
</div>
</div>
<div class="qr-body"></div>
<div class="qr-footer">
<a href="" id="generateBtn">Generate</a>
<a href="" id="downloadBtn" download="QR_Code.png">Download</a>
</div>
</div>

<script src="script.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js"></script>
</body>
</html>
100 changes: 100 additions & 0 deletions Components/Forms/QR-Code-Generator-Form/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
:root{
background: linear-gradient(45deg, #010758, #490d61);
--primary-color: #403d84;
--border-radius: 8px;
--secondary-color: #fff;
--border-color: #7fb7c9;
}
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: sans-serif;
}

body{
width: 100%;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background-color: var(--bcg-color);
}

.box{
background-color: var(--primary-color);
padding: 30px;
width: 400px;
border-radius: var(--border-radius);
}

.qr-header h1{
font-size: 26px;
text-align: center;
color: var(--secondary-color);
margin-bottom: 24px;
text-transform: uppercase;
}

.qr-header input{
width: 100%;
margin-block: 12px;
}

.qr-header input, select{
padding: 8px;
border-radius: var(--border-radius);
font-size: 18px;
outline: none;
border: 2px solid var(--border-color);
}

.qr-header label{
color: var(--secondary-color);
font-size: 20px;
}

.qr-header div{
display: flex;
justify-content: space-between;
}

.qr-footer{
display: flex;
justify-content: center;
}
.qr-footer a{
background-color: var(--secondary-color);
text-decoration: none;
font-size: 20px;
padding: 14px 36px;
margin-inline: 2px;
color: var(--primary-color);
font-weight: 600;
border-radius: var(--border-radius);
}

.qr-body{
display: grid;
place-items: center;
padding:20px;
}

.qr-body img{
max-width: 100%;
max-height: 100%;
margin-block: 10px;
padding: 20px;
border: 0.5px solid var(--border-color);
border-radius: var(--border-radius);
}

@media screen and (max-width:520px){
.box{
width: 80%;
}
.qr-footer a{
padding: 12px;
font-size: 16px;
}
}
42 changes: 42 additions & 0 deletions Components/Forms/QR-Code-Generator-Form/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const qrText = document.getElementById('qr-text');
const sizes = document.getElementById('sizes');
const generateBtn = document.getElementById('generateBtn');
const downloadBtn = document.getElementById('downloadBtn');
const qrContainer = document.querySelector('.qr-body');

let size = sizes.value;
generateBtn.addEventListener('click',(e)=>{
e.preventDefault();
isEmptyInput();
});

sizes.addEventListener('change',(e)=>{
size = e.target.value;
isEmptyInput();
});

downloadBtn.addEventListener('click', ()=>{
let img = document.querySelector('.qr-body img');

if(img !== null){
let imgAtrr = img.getAttribute('src');
downloadBtn.setAttribute("href", imgAtrr);
}
else{
downloadBtn.setAttribute("href", `${document.querySelector('canvas').toDataURL()}`);
}
});

function isEmptyInput(){
qrText.value.length > 0 ? generateQRCode() : alert("Enter the text or URL to generate your QR code");;
}
function generateQRCode(){
qrContainer.innerHTML = "";
new QRCode(qrContainer, {
text:qrText.value,
height:size,
width:size,
colorLight:"#fff",
colorDark:"#000",
});
}
31 changes: 31 additions & 0 deletions Components/Forms/Text-To-Voice-Form/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<!-- Coding By CodingNepal - youtube.com/codingnepal -->
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Text To Voice Form</title>
<link rel="stylesheet" href="style.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div class="wrapper">
<header>Text To Voice</header>
<form action="#">
<div class="row">
<label>Enter Text</label>
<textarea></textarea>
</div>
<div class="row">
<label>Select Voice</label>
<div class="outer">
<select></select>
</div>
</div>
<button>Convert To Voice</button>
</form>
</div>

<script src="main.js"></script>

</body>
</html>
57 changes: 57 additions & 0 deletions Components/Forms/Text-To-Voice-Form/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
const textarea = document.querySelector("textarea"),
voiceList = document.querySelector("select"),
speechBtn = document.querySelector("button");

let synth = speechSynthesis,
isSpeaking = true;

voices();

function voices(){
for(let voice of synth.getVoices()){
let selected = voice.name === "Google US English" ? "selected" : "";
let option = `<option value="${voice.name}" ${selected}>${voice.name} (${voice.lang})</option>`;
voiceList.insertAdjacentHTML("beforeend", option);
}
}

synth.addEventListener("voiceschanged", voices);

function textToSpeech(text){
let utterance = new SpeechSynthesisUtterance(text);
for(let voice of synth.getVoices()){
if(voice.name === voiceList.value){
utterance.voice = voice;
}
}
synth.speak(utterance);
}

speechBtn.addEventListener("click", e =>{
e.preventDefault();
if(textarea.value !== ""){
if(!synth.speaking){
textToSpeech(textarea.value);
}
if(textarea.value.length > 80){
setInterval(()=>{
if(!synth.speaking && !isSpeaking){
isSpeaking = true;
speechBtn.innerText = "Convert To Speech";
}else{
}
}, 500);
if(isSpeaking){
synth.resume();
isSpeaking = false;
speechBtn.innerText = "Pause Speech";
}else{
synth.pause();
isSpeaking = true;
speechBtn.innerText = "Resume Speech";
}
}else{
speechBtn.innerText = "Convert To Speech";
}
}
});
107 changes: 107 additions & 0 deletions Components/Forms/Text-To-Voice-Form/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/* Import Google Font - Poppins */
@import url('https://fonts.googleapis.com/css2?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: linear-gradient(45deg, #010758, #490d61);
}
::selection{
color: #fff;
background: #5256AD;
}

.wrapper{
width: 370px;
padding: 25px 30px;
border-radius: 7px;
background: #fff;
box-shadow: 7px 7px 30px rgba(209, 203, 203, 0.745)
}
.wrapper header{
font-size: 28px;
font-weight: 500;
text-align: center;
}
.wrapper form{
margin: 35px 0 20px;
}
form .row{
display: flex;
margin-bottom: 20px;
flex-direction: column;
}
form .row label{
font-size: 18px;
margin-bottom: 5px;
}
form .row:nth-child(2) label{
font-size: 17px;
}
form :where(textarea, select, button){
outline: none;
width: 100%;
height: 100%;
border: none;
border-radius: 5px;
}
form .row textarea{
resize: none;
height: 110px;
font-size: 15px;
padding: 8px 10px;
border: 1px solid #999;
}
form .row textarea::-webkit-scrollbar{
width: 0px;
}
form .row .outer{
height: 47px;
display: flex;
padding: 0 10px;
align-items: center;
border-radius: 5px;
justify-content: center;
border: 1px solid #999;
}
form .row select{
font-size: 14px;
background: none;
}
form .row select::-webkit-scrollbar{
width: 8px;
}
form .row select::-webkit-scrollbar-track{
background: #fff;
}
form .row select::-webkit-scrollbar-thumb{
background: #888;
border-radius: 8px;
border-right: 2px solid #ffffff;
}
form button{
height: 52px;
color: #fff;
font-size: 17px;
cursor: pointer;
margin-top: 10px;
background: #675AFE;
transition: 0.3s ease;
}
form button:hover{
background: #4534fe;
}

@media(max-width: 400px){
.wrapper{
max-width: 345px;
width: 100%;
}
}

0 comments on commit c677c43

Please sign in to comment.