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

feat: Revamp UI #58

Closed
wants to merge 1 commit into from
Closed
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
feat: Revamp UI
Mayank-Sharma17 committed Oct 7, 2023
commit 13684afe9c4bfcea42e2b4190343de002f0aea1f
191 changes: 95 additions & 96 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,112 +1,113 @@
const btn = document.getElementById('mybtn')
const rockBtn = document.getElementById('rockBtn')
const mob = document.getElementById('MobileNum')
const inputText = document.getElementById('textforWa')
const genLink = document.getElementById('genLink')
const btnCopy = document.getElementById('btn-copy')
const whatsBtn = document.getElementById('btn-WhatsLink')
const linkContainer = document.getElementById('linkContainer')
const errMsg = document.querySelector('.err-msg')

const countryCode = document.querySelector('select')

const btn = document.getElementById("mybtn");
const rockBtn = document.getElementById("rockBtn");
const mob = document.getElementById("MobileNum");
const inputText = document.getElementById("textforWa");
const genLink = document.getElementById("genLink");
const btnCopy = document.getElementById("btn-copy");
const whatsBtn = document.getElementById("btn-WhatsLink");
const linkContainer = document.getElementById("linkContainer");
const errMsg = document.querySelector(".err-msg");
const countryCode = document.querySelector("select");
const b2t = document.getElementById("back-to-top");

b2t.addEventListener("click", () => {
window.scrollTo(0, 0);
});

window.addEventListener("scroll", () => {
if (window.scrollY > 300) {
b2t.classList.add("show");
} else {
b2t.classList.remove("show");
}
});

// dark mode
const toggleButton = document.getElementById('toggleMode');
const toggleButton = document.getElementById("toggleMode");
const body = document.body;
const colorMode = localStorage.getItem('color-mode') || 'light';
const colorMode = localStorage.getItem("color-mode") || "light";

if(localStorage.getItem('color-mode') === 'dark'){
body.classList.add('dark-mode');
if (localStorage.getItem("color-mode") === "dark") {
body.classList.add("dark-mode");
}

function toggleColorMode(){
let colorMode = localStorage.getItem('color-mode')
function toggleColorMode() {
let colorMode = localStorage.getItem("color-mode");

if (colorMode !== 'dark' || colorMode === null) {
body.classList.add('dark-mode');
localStorage.setItem('color-mode', 'dark');
} else {
body.classList.remove('dark-mode');
localStorage.setItem('color-mode', 'light');
if (colorMode !== "dark" || colorMode === null) {
body.classList.add("dark-mode");
localStorage.setItem("color-mode", "dark");
} else {
body.classList.remove("dark-mode");
localStorage.setItem("color-mode", "light");
}
}


toggleButton.addEventListener('click', toggleColorMode);


toggleButton.addEventListener("click", toggleColorMode);

// Magic (text on phone)
let numPhone = document.getElementById('magic-num')
let textPhone = document.getElementById('magic-text')
let numPhone = document.getElementById("magic-num");
let textPhone = document.getElementById("magic-text");

inputText.addEventListener('keyup', (e) => {
textPhone.innerText = e.target.value
})
inputText.addEventListener("keyup", (e) => {
textPhone.innerText = e.target.value;
});

mob.addEventListener('keyup', (e) => {
numPhone.innerText = e.target.value
})
mob.addEventListener("keyup", (e) => {
numPhone.innerText = e.target.value;
});

const textStr = inputText.value
const textStr = inputText.value;

// Rock Btn smooth scroll
rockBtn.addEventListener('click', () => {
window.scrollTo(0, 400)
rockBtn.addEventListener("click", () => {
window.scrollTo(0, 400);
});

let arrayOfStrings = inputText.value.split(" ");
let linkText = arrayOfStrings.join("%20");
let linkform = `I dont care`;

mob.addEventListener("input", (e) => {
mob.classList.remove("input-error");
errMsg.style.display = "none";

const value = e.target.value;

let arrayOfStrings = inputText.value.split(' ')
let linkText = arrayOfStrings.join('%20')
let linkform = `I dont care`


mob.addEventListener('input', (e) => {
mob.classList.remove('input-error');
errMsg.style.display = 'none';
if (e.inputType === "deleteContentBackward") return;

const value = e.target.value;
// can input only digits

if (e.inputType === 'deleteContentBackward') return;

// can input only digits

if (parseInt(e.data) !== 0 && !parseInt(e.data)) {
console.log(e.data)
mob.value = value.substring(0, value.length - 1);
}
})

btn.addEventListener('click', (e) => {
e.preventDefault()

// if mobilenum is empty then don't submit
if (!mob.value) {
mob.classList.add('input-error');
errMsg.style.display = 'block';
return;
}
if (parseInt(e.data) !== 0 && !parseInt(e.data)) {
console.log(e.data);
mob.value = value.substring(0, value.length - 1);
}
});

arrayOfStrings = inputText.value.split(' ')
linkText = arrayOfStrings.join('%20')
linkform = `https://api.whatsapp.com/send?phone=${countryCode.value}${mob.value}&text=${linkText}&lang=en`
btn.addEventListener("click", (e) => {
e.preventDefault();

const whatsShareLink = `api.whatsapp.com/send?phone=91${mob.value}&text=${linkText}&lang=en`
// if mobilenum is empty then don't submit
if (!mob.value) {
mob.classList.add("input-error");
errMsg.style.display = "block";
return;
}

console.log(inputText.value)
genLink.innerText = linkform
arrayOfStrings = inputText.value.split(" ");
linkText = arrayOfStrings.join("%20");
linkform = `https://api.whatsapp.com/send?phone=${countryCode.value}${mob.value}&text=${linkText}&lang=en`;

whatsBtn.setAttribute("href", `http://${whatsShareLink}/`)
whatsBtn.classList.remove('wbtn')
const whatsShareLink = `api.whatsapp.com/send?phone=91${mob.value}&text=${linkText}&lang=en`;

window.scrollTo(0, 700)
})
console.log(inputText.value);
genLink.innerText = linkform;

whatsBtn.setAttribute("href", `http://${whatsShareLink}/`);
whatsBtn.classList.remove("wbtn");

window.scrollTo(0, 700);
});

// Whatsapp share btn
// Create anchor element.
@@ -127,24 +128,22 @@ btn.addEventListener('click', (e) => {

// Copy Text

new ClipboardJS('#btn-copy');
btnCopy.addEventListener('click', (e) => {

e.preventDefault()
btnCopy.innerText = 'Copied'
setTimeout(() => {
btnCopy.innerText = 'Copy'
}, 2000);

})
new ClipboardJS("#btn-copy");
btnCopy.addEventListener("click", (e) => {
e.preventDefault();
btnCopy.innerText = "Copied";
setTimeout(() => {
btnCopy.innerText = "Copy";
}, 2000);
});

new EmojiPicker({
trigger: [
{
selector: '.emoji-btn',
insertInto: ['.one']
}
],
closeButton: true,
//specialButtons: green
});
trigger: [
{
selector: ".emoji-btn",
insertInto: [".one"],
},
],
closeButton: true,
//specialButtons: green
});
1,190 changes: 830 additions & 360 deletions index.html

Large diffs are not rendered by default.

146 changes: 116 additions & 30 deletions style.css
Original file line number Diff line number Diff line change
@@ -1,21 +1,43 @@
@import url("https://fonts.googleapis.com/css2?family=Dancing+Script:wght@700&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700;800&display=swap");

body{
position: relative;
body {
padding: 0;
margin: 0;
height: 100vh;
box-sizing: border-box;
font-family: "Inter", sans-serif;
font-weight: 600;
}

h1 {
color: #fff;
font-size: 3.5rem;
font-weight: 700;
}

h2 {
font-size: 1.85rem;
font-weight: 600;
}

.navbar-brand {
font-family: "Dancing Script";
font-weight: bolder;
font-size: 30px;
font-family: "Inter", sans-serif;
font-weight: 800;
font-size: 2rem;
background-image: linear-gradient(to right top, #008793, #00bf72, #a8eb12);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}

.navbar-toggler {
border: none;
padding: 0;
}

section.hero {
background-image: linear-gradient(to right top, #008793, #00bf72);
overflow: hidden;
padding-top: 4.5rem;
padding-bottom: 4.5rem;
}

input.input-error {
@@ -34,24 +56,38 @@ input.input-error {
gap: 4px;
}

.hero button,
.link-button,
.copy-btn {
border: 2px solid #fff;
color: #fff;
font-weight: 600;
}

.hero button:hover,
.link-button:hover,
.copy-btn:hover {
appearance: none;
border: 2px solid #ffc107;
color: #ffc107;
}

.hero-image {
width: 30%;
margin-left: 800px;
width: 500px;
}

.form-control {
padding: 10px;
}

.form-control:focus {
border-color: #13c703;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px #13c703;
border-color: #e5e5e5;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px #ffc107;
}

/* Link */

#genLink {
border: 3px solid greenyellow;
border: 2px solid #00bf72;
padding: 10px;
border-radius: 5px;
word-wrap: break-word;
@@ -80,37 +116,87 @@ input.input-error {
color: black;
}

#back-to-top{
background-color: #13c703;
position: fixed;
bottom: 10px;
right: 10px;
width: 50px;
height: 50px;
border-radius: 50px;
color: white;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
transition: transform .5s ;
transform: translateX(200px);
#back-to-top {
background-color: #212529;
position: fixed;
bottom: 20px;
right: 20px;
width: 40px;
height: 40px;
border-radius: 50px;
color: white;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
transition: transform 0.5s;
transform: translateX(200px);
}

#back-to-top.show{
transform: translateX(0px);
#back-to-top.show {
transform: translateX(0px);
}

/* Footer */
.footer {
background-image: linear-gradient(to right top, #008793, #00bf72);
}

.foot-text {
font-size: 1.4rem;
font-weight: 600;
}

.foot-button {
color: #fff;
font-weight: 600;
border: 2px solid white;
}

.foot-button:hover {
background-color: transparent;
color: #ffc107;
border: 2px solid #ffc107;
}

.fa-brands {
color: #fff;
padding-right: 15px;
transition: all 0.2s ease;
}

.fa-brands:hover {
transform: scale(1.15);
color: #ffc107;
}

/* Default (Light) Mode */
body.light-mode {
background-color: #fff;
color: #333;
}

.light-mode .info-icon {
color: #000;
}

/* Dark Mode */
body.dark-mode {
background-color: #333;
color: #fff;
}

.navbar-dark .navbar-nav .nav-link {
color: #00bf72;
}

@media (max-width: 990px) {
.hero-main {
flex-direction: column;
}

.hero-image {
margin-top: 2rem;
width: 400px;
}
}