Skip to content
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
84 changes: 0 additions & 84 deletions 01 - JavaScript Drum Kit/index-FINISHED.html

This file was deleted.

21 changes: 20 additions & 1 deletion 01 - JavaScript Drum Kit/index-START.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,27 @@

<script>

function playSound(e) {
const audio = document.querySelector(`audio[data-key="${e.keyCode}"]`)
const key = document.querySelector(`.key[data-key="${e.keyCode}"]`)

if (!audio) return;

audio.currentTime = 0;
audio.play();

key.classList.add('playing');

setTimeout((
() => {
key.classList.remove('playing');
}
), 100)
}

window.addEventListener('keydown', playSound);
</script>


</body>
</html>
</html>
153 changes: 89 additions & 64 deletions 02 - JS and CSS Clock/index-START.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,73 +3,98 @@
<head>
<meta charset="UTF-8">
<title>JS + CSS Clock</title>
<link rel="icon" href="https://fav.farm/🔥" />
</head>
<body>

<div class="clock">
<div class="clock-face">
<div class="hand hour-hand"></div>
<div class="hand min-hand"></div>
<div class="hand second-hand"></div>
</div>
</div>

<style>
html {
background: #018DED;
background-size: cover;
font-family: Arial;
font-size: 10px;
}

body {
margin: 0;
display: flex;
min-height: 100vh;
align-items: center;
justify-content: center;
}

.clock {
width: 30rem;
height: 30rem;
border: 20px solid white;
border-radius: 50%;
position: relative;
padding: 2rem;
}

.clock-face {
position: relative;
width: 100%;
height: 100%;
}

.hand {
position: absolute;
top: 50%;
right: 50%;
transform-origin: 100%;
transform: rotate(90deg);
background: black;
}

.hour-hand {
width: 35%;
height: 8px;
}

.min-hand {
width: 45%;
height: 6px;
}

.second-hand {
width: 50%;
height: 3px;
background: red;
}
</style>

<script>
const secHand = document.querySelector('.second-hand');
const minHand = document.querySelector('.min-hand');
const hourHand = document.querySelector('.hour-hand');

function setDate() {
const now = new Date();

const seconds = now.getSeconds();
const minutes = now.getMinutes();
const hours = now.getHours();

const secondsDegrees = seconds * 6 + 90;
const minutesDegrees = minutes * 6 + seconds * 0.1 + 90;
const hoursDegrees = hours * 30 + minutes * 0.5 + 90;

secHand.style.transform = `rotate(${secondsDegrees}deg)`;
minHand.style.transform = `rotate(${minutesDegrees}deg)`;
hourHand.style.transform = `rotate(${hoursDegrees}deg)`;
}

setInterval(setDate, 1000);
setDate();
</script>

<div class="clock">
<div class="clock-face">
<div class="hand hour-hand"></div>
<div class="hand min-hand"></div>
<div class="hand second-hand"></div>
</div>
</div>


<style>
html {
background: #018DED url(https://unsplash.it/1500/1000?image=881&blur=5);
background-size: cover;
font-family: 'helvetica neue';
text-align: center;
font-size: 10px;
}

body {
margin: 0;
font-size: 2rem;
display: flex;
flex: 1;
min-height: 100vh;
align-items: center;
}

.clock {
width: 30rem;
height: 30rem;
border: 20px solid white;
border-radius: 50%;
margin: 50px auto;
position: relative;
padding: 2rem;
box-shadow:
0 0 0 4px rgba(0,0,0,0.1),
inset 0 0 0 3px #EFEFEF,
inset 0 0 10px black,
0 0 10px rgba(0,0,0,0.2);
}

.clock-face {
position: relative;
width: 100%;
height: 100%;
transform: translateY(-3px); /* account for the height of the clock hands */
}

.hand {
width: 50%;
height: 6px;
background: black;
position: absolute;
top: 50%;
}

</style>

<script>


</script>
</body>
</html>