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

Add Digital-Analog Neumorphism Clock #292

Closed
wants to merge 3 commits into from
Closed
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
Binary file added Analog-Digital-Neumorphism-Clock/clock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
114 changes: 114 additions & 0 deletions Analog-Digital-Neumorphism-Clock/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<!-- Made by Nitin Kushwaha -->

<!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">
<title>Clock</title>
</head>
<body class="theme-dark">
<div class="flip-card">
<div class="flip-card-inner">
<div class="flip-card-front">
<div id="clock-a">
<div id="hr">
<div id="h"></div>
</div>
<div id="min">
<div id="m"></div>
</div>
<div id="sec">
<div id="s"></div>
</div>
</div>
</div>
<div class="flip-card-back">
<div id="clock-d"></div>
</div>
</div>
</div>
<div id="change">Digital</div>
<div id="theme">Light</div>
<div class="settingapp">
<div id="setting-icon">&#x2699;</div>
<div id="setting-window">
<div id="setting-nav" class="setting-container">
<h3>SETTINGS</h3>
<ul>
<li><a href="#Hsize">Size</a></li>
<li><a href="#Hbackground">Background</a></li>
<li><a href="#Hshadow">Shadow</a></li>
<li><a href="#Hhandcolor">Hand Color</a></li>
<li><a href="#Hborder">Border</a></li>
</ul>
</div>
<div id="settings" class="setting-container">
<div class="box">
<h3 id="Hsize">Size</h3>
<div class="inner-box">
<input type="range" name="" id="size" min="0.5" max="1.5" step="0.1" value="1">
<label for="size">1</label>
</div>
</div>
<div class="box">
<h3 id="Hbackground">Background</h3>
<div class="inner-box">
<input type="color" name="" id="background" value="#202020">
<!-- <input type="text" name="" id="background-text"> -->
</div>
</div>
<div class="box">
<h3 id="Hshadow">Shadow</h3>
<div class="inner-box">
<div class="inner-container">
<label for="shadow-blur">Blur</label>
<input type="number" name="" id="shadow-blur" min="0" max="100" value="100">
</div>
<div class="inner-container">
<label for="shadow-blur">Color</label>
<input type="color" name="" id="shadow-color" value="#00ffff">
<!-- <input type="text" name="" id="shadow-color-text"> -->
</div>
</div>
</div>
<div class="box">
<h3 id="Hhandcolor">Hand color</h3>
<div class="inner-box">
<div class="inner-container">
<label for="hr-color">Hour</label>
<input type="color" name="" id="hr-color" value="#e623c8">
<!-- <input type="text" name="" id="hr-color-text"> -->
</div>
<div class="inner-container">
<label for="min-color">Minute</label>
<input type="color" name="" id="min-color" value="#003cff">
<!-- <input type="text" name="" id="min-color-text"> -->
</div>
<div class="inner-container">
<label for="sec-color">Second</label>
<input type="color" name="" id="sec-color" value="#ffffff">
<!-- <input type="text" name="" id="sec-color-text"> -->
</div>
</div>
</div>
<div class="box">
<h3 id="Hborder">Border</h3>
<div class="inner-box">
<div class="inner-container">
<label for="border-width">Width</label>
<input type="number" name="" id="border-width" min="0" max="15" value="5">
</div>
<div class="inner-container">
<label for="border-color">Color</label>
<input type="color" name="" id="border-color" value="#000000">
</div>
</div>
</div>
</div>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
213 changes: 213 additions & 0 deletions Analog-Digital-Neumorphism-Clock/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
// Made by Nitin Kushwaha

const hr = document.querySelector("#hr");
const min = document.querySelector("#min");
const sec = document.querySelector("#sec");
const clockd = document.getElementById("clock-d");
const clocka = document.getElementById("clock-a");
let h,m,s;
let d;

setInterval(() => {
const day = new Date();
h = day.getHours();
m = day.getMinutes();
s = day.getSeconds();

hr.style.transform = `rotate(${h*30 + m/2}deg)`;
min.style.transform = `rotate(${m*6 + s/10}deg)`;
sec.style.transform = `rotate(${s*6}deg)`;

setday();
addzero();
clockd.textContent = h + ":" + m + ":" + s + " " + d ;

if(window.innerHeight==screen.height){
change.style.display="none";
theme.style.display="none";
}
else{
change.style.display="block";
theme.style.display="block";
}
},100);

function addzero(){
if(h<10){
h = "0" + h;
}
if(m<10){
m = "0" + m;
}
if(s<10){
s = "0" + s;
}
}

function setday(){
if(h>12){
h = h - 12;
d = "PM";
}
else{
if(h==0){
h=12;
}
d = "AM";
}
}

const change = document.querySelector("#change");

function toggleClock(e){
let target = e.target;

if(target.textContent == "Digital"){
document.querySelector(".flip-card-inner").classList.add("flip");
target.textContent = "Analog";
}
else{
document.querySelector(".flip-card-inner").classList.remove("flip");
target.textContent = "Digital";
}
}

change.addEventListener("click",toggleClock);

const theme = document.querySelector("#theme");

function toggleTheme(e){
let target = e.target;

reset(e);

if(target.textContent == "Light"){
target.textContent = "Dark";
document.body.classList.remove("theme-dark");
document.body.classList.add("theme-light");
}
else{
target.textContent = "Light";
document.body.classList.remove("theme-light");
document.body.classList.add("theme-dark");
}

}

theme.addEventListener("click",toggleTheme);

/*-------------settings--------------*/

/*------gear------*/
const settingWindow = document.querySelector("#setting-window")
const setting = document.querySelector("#setting-icon");

setting.addEventListener("click", function(){
setting.classList.toggle("rotate");
settingWindow.classList.toggle("show");
});

/*------setting window------*/

const setSize = document.querySelector("#size");
const sizeLabel = document.querySelector("label")

const setBackground = document.querySelector("#background");

const setShadowBlur = document.querySelector("#shadow-blur");
const setShadowColor = document.querySelector("#shadow-color");

const setHrHandColor = document.querySelector("#hr-color");
// const setHrHandColorText = document.querySelector("#hr-color-text");
const setMinHandColor = document.querySelector("#min-color");
// const setMinHandColorText = document.querySelector("#min-color-text");
const setSecHandColor = document.querySelector("#sec-color");
// const setSecHandColorText = document.querySelector("#sec-color-text");

const setBorderWidth = document.querySelector("#border-width");
const setBorderColor = document.querySelector("#border-color");

/*------size------*/
// let caSize = document.querySelector("#clock-a").clientHeight;

//size
setSize.addEventListener("input",()=>{
clocka.style.transform = `scale(${setSize.value})`;
clockd.style.transform = `scale(${setSize.value})`;
sizeLabel.textContent = setSize.value;
});

//backgroundcolor
setBackground.addEventListener("input",()=>{
document.querySelector(".flip-card-front").style.backgroundColor =
document.querySelector(".flip-card-back").style.backgroundColor =
clockd.style.backgroundColor =
document.body.style.backgroundColor =
setBackground.value;
});

//shadow
setshadow=()=>{
clocka.style.boxShadow = `-8px -8px 15px rgba(255,255,255,0.05),
inset -8px -8px 15px rgba(255,255,255,0.05),
20px 20px 20px rgba(0, 0, 0, 0.3),
inset 20px 20px 20px rgba(0, 0, 0, 0.3),
0px 0px ${setShadowBlur.value}px ${setShadowColor.value}`;

clockd.style.boxShadow = `-8px -8px 15px rgba(255,255,255,0.05),
inset -8px -8px 15px rgba(255,255,255,0.05),
20px 20px 20px rgba(0, 0, 0, 0.3),
inset 20px 20px 20px rgba(0, 0, 0, 0.3),
0px 0px ${setShadowBlur.value}px ${setShadowColor.value}`;
}

setShadowBlur.addEventListener("input",setshadow);
setShadowColor.addEventListener("input",setshadow);

//Hand color
setHrHandColor.addEventListener("input",()=>{
document.querySelector("#h").style.backgroundColor = setHrHandColor.value;
});

setMinHandColor.addEventListener("input",()=>{
document.querySelector("#m").style.backgroundColor = setMinHandColor.value;
});

setSecHandColor.addEventListener("input",()=>{
document.querySelector("#s").style.backgroundColor = setSecHandColor.value;
});

//Border
setborder=()=>{
clocka.style.border = `${setBorderWidth.value}px solid ${setBorderColor.value}`;
clockd.style.border = `${setBorderWidth.value}px solid ${setBorderColor.value}`;
}

setBorderWidth.addEventListener("input",setborder);
setBorderColor.addEventListener("input",setborder);

//reset
function reset(e){
if(e.target.textContent == "Light"){
document.querySelector(".flip-card-front").style.backgroundColor =
document.querySelector(".flip-card-back").style.backgroundColor =
clockd.style.backgroundColor =
document.body.style.backgroundColor = "#d1dae3";
}
else{
document.querySelector(".flip-card-front").style.backgroundColor =
document.querySelector(".flip-card-back").style.backgroundColor =
clockd.style.backgroundColor =
document.body.style.backgroundColor = "#202020";
}

clocka.style.boxShadow ="";
clockd.style.boxShadow ="";

document.querySelector("#h").style.backgroundColor = "";
document.querySelector("#m").style.backgroundColor = "";
document.querySelector("#s").style.backgroundColor = "";

clocka.style.border = "";
clockd.style.border = "";
}
Loading