Skip to content

Commit 3af75b5

Browse files
committed
Added new index.html files
1 parent 508e476 commit 3af75b5

File tree

23 files changed

+1844
-67
lines changed

23 files changed

+1844
-67
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>JS Drum Kit</title>
6+
<link rel="stylesheet" href="style.css">
7+
</head>
8+
<body>
9+
10+
11+
<div class="keys">
12+
<div data-key="65" class="key">
13+
<kbd>A</kbd>
14+
<span class="sound">clap</span>
15+
</div>
16+
<div data-key="83" class="key">
17+
<kbd>S</kbd>
18+
<span class="sound">hihat</span>
19+
</div>
20+
<div data-key="68" class="key">
21+
<kbd>D</kbd>
22+
<span class="sound">kick</span>
23+
</div>
24+
<div data-key="70" class="key">
25+
<kbd>F</kbd>
26+
<span class="sound">openhat</span>
27+
</div>
28+
<div data-key="71" class="key">
29+
<kbd>G</kbd>
30+
<span class="sound">boom</span>
31+
</div>
32+
<div data-key="72" class="key">
33+
<kbd>H</kbd>
34+
<span class="sound">ride</span>
35+
</div>
36+
<div data-key="74" class="key">
37+
<kbd>J</kbd>
38+
<span class="sound">snare</span>
39+
</div>
40+
<div data-key="75" class="key">
41+
<kbd>K</kbd>
42+
<span class="sound">tom</span>
43+
</div>
44+
<div data-key="76" class="key">
45+
<kbd>L</kbd>
46+
<span class="sound">tink</span>
47+
</div>
48+
</div>
49+
50+
<audio data-key="65" src="sounds/clap.wav"></audio>
51+
<audio data-key="83" src="sounds/hihat.wav"></audio>
52+
<audio data-key="68" src="sounds/kick.wav"></audio>
53+
<audio data-key="70" src="sounds/openhat.wav"></audio>
54+
<audio data-key="71" src="sounds/boom.wav"></audio>
55+
<audio data-key="72" src="sounds/ride.wav"></audio>
56+
<audio data-key="74" src="sounds/snare.wav"></audio>
57+
<audio data-key="75" src="sounds/tom.wav"></audio>
58+
<audio data-key="76" src="sounds/tink.wav"></audio>
59+
60+
<script>
61+
62+
function playsound (e){
63+
const audio = document.querySelector(`audio[data-key="${e.keyCode}"]`);
64+
const key = document.querySelector(`.key[data-key="${e.keyCode}"]`);
65+
if (!audio) return; //stop the function from running all together
66+
audio.currentTime = 0;
67+
audio.play();
68+
key.classList.add('playing')
69+
70+
//console.log(key);
71+
//console.log(audio);
72+
}
73+
74+
function removeTransition(e){
75+
if(e.propertyName !== 'transform') return; //avoids selecting all other transitions
76+
this.classList.remove('playing');
77+
}
78+
79+
const keys = document.querySelectorAll('.key');
80+
keys.forEach(key => key.addEventListener('transitionend', removeTransition));
81+
82+
window.addEventListener('keydown', playsound);
83+
84+
85+
</script>
86+
87+
88+
</body>
89+
</html>

01 - JavaScript Drum Kit/style.css

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ html {
66
body,html {
77
margin: 0;
88
padding: 0;
9-
font-family: sans-serif;
9+
font-family: "noto sans", sans-serif;
1010
}
1111

1212
.keys {
@@ -23,7 +23,7 @@ body,html {
2323
margin: 1rem;
2424
font-size: 1.5rem;
2525
padding: 1rem .5rem;
26-
transition: all .07s ease;
26+
transition: all .05s ease;
2727
width: 10rem;
2828
text-align: center;
2929
color: white;
@@ -33,8 +33,8 @@ body,html {
3333

3434
.playing {
3535
transform: scale(1.1);
36-
border-color: #ffc600;
37-
box-shadow: 0 0 1rem #ffc600;
36+
border-color: #0095ff;
37+
box-shadow: 0 0 0.5rem #ffc600;
3838
}
3939

4040
kbd {
@@ -46,5 +46,5 @@ kbd {
4646
font-size: 1.2rem;
4747
text-transform: uppercase;
4848
letter-spacing: .1rem;
49-
color: #ffc600;
49+
color: #0095ff;
5050
}

02 - JS and CSS Clock/index.html

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>JS + CSS Clock</title>
6+
</head>
7+
<body>
8+
9+
10+
<div class="clock">
11+
<div class="clock-face">
12+
<div class="hand hour-hand"></div>
13+
<div class="hand min-hand"></div>
14+
<div class="hand second-hand"></div>
15+
</div>
16+
</div>
17+
18+
19+
<style>
20+
html {
21+
background:#018DED url(http://unsplash.it/1500/1000?image=881&blur=50);
22+
background-size:cover;
23+
font-family:'helvetica neue';
24+
text-align: center;
25+
font-size: 10px;
26+
}
27+
28+
body {
29+
margin: 0;
30+
font-size: 2rem;
31+
display:flex;
32+
flex:1;
33+
min-height: 100vh;
34+
align-items: center;
35+
}
36+
37+
.clock {
38+
width: 30rem;
39+
height: 30rem;
40+
border:20px solid white;
41+
border-radius:50%;
42+
margin:50px auto;
43+
position: relative;
44+
padding:2rem;
45+
box-shadow:
46+
0 0 0 4px rgba(0,0,0,0.1),
47+
inset 0 0 0 3px #EFEFEF,
48+
inset 0 0 10px black,
49+
0 0 10px rgba(0,0,0,0.2);
50+
}
51+
52+
.clock-face {
53+
position: relative;
54+
width: 100%;
55+
height: 100%;
56+
transform: translateY(-3px); /* account for the height of the clock hands */
57+
}
58+
59+
.hand {
60+
width:50%;
61+
height:6px;
62+
background:black;
63+
position: absolute;
64+
top:50%;
65+
transform-origin: 100%;
66+
transform: rotate(90deg);
67+
transition: all 0.5s;
68+
transition-timing-function: cubic-bezier(0, 0, 0, 1);
69+
}
70+
71+
</style>
72+
73+
<script>
74+
75+
const hourHand = document.querySelector('.hour-hand');
76+
const minHand = document.querySelector('.min-hand');
77+
const secondHand = document.querySelector('.second-hand');
78+
79+
function setDate(){
80+
const now = new Date()
81+
82+
const hours = now.getHours();
83+
const hoursDegrees = ((hours / 12) * 360) + 90;
84+
hourHand.style.transform = `rotate(${hoursDegrees}deg)`;
85+
86+
const minutes = now.getMinutes();
87+
const minutesDegrees = ((minutes / 60) * 360) + 90;
88+
minHand.style.transform = `rotate(${minutesDegrees}deg)`;
89+
90+
const seconds = now.getSeconds();
91+
const secondsDegrees = ((seconds / 60) * 360) + 90;
92+
secondHand.style.transform = `rotate(${secondsDegrees}deg)`;
93+
94+
console.log("time " + hours + " : " + minutes + " : " + seconds);
95+
}
96+
97+
setInterval(setDate, 1000);
98+
99+
</script>
100+
</body>
101+
</html>

03 - CSS Variables/index.html

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Scoped CSS Variables and JS</title>
6+
</head>
7+
8+
<body>
9+
<h2>Update CSS Variables with <span class='hl'>JS</span></h2>
10+
11+
<div class="controls">
12+
<label for="spacing">Spacing:</label>
13+
<input id="spacing" type="range" name="spacing" min="10" max="200" value="10" data-sizing="px">
14+
15+
<label for="blur">Blur:</label>
16+
<input id="blur" type="range" name="blur" min="0" max="25" value="10" data-sizing="px">
17+
18+
<label for="base">Base Color</label>
19+
<input id="base" type="color" name="base" value="#ffc600">
20+
</div>
21+
22+
<img src="https://source.unsplash.com/7bwQXzbF6KE/800x500">
23+
24+
<style>
25+
26+
:root{
27+
--base:#ffc600;
28+
--spacing: 10px;
29+
--blur: 10px;
30+
}
31+
32+
img{
33+
padding: var(--spacing);
34+
background: var(--base);
35+
filter: blur(var(--blur));
36+
}
37+
38+
h2{
39+
font-size: 48px;
40+
}
41+
42+
.hl{
43+
color: var(--base);
44+
}
45+
46+
/* misc styles, nothing to do with CSS variables */
47+
48+
body {
49+
text-align: center;
50+
background: #193549;
51+
color: white;
52+
font-family: 'helvetica neue', sans-serif;
53+
font-weight: 100;
54+
font-size: 24px;
55+
}
56+
57+
.controls {
58+
margin-bottom: 50px;
59+
}
60+
61+
input {
62+
width:100px;
63+
}
64+
</style>
65+
66+
<script>
67+
68+
const inputs = document.querySelectorAll('.controls input');
69+
70+
function handleUpdate(){
71+
const suffix = this.dataset.sizing || '';
72+
document.documentElement.style.setProperty(`--${this.name}`, this.value + suffix);
73+
74+
//console.log(this.name);
75+
//console.log(suffix);
76+
//console.log(this.value);
77+
}
78+
79+
inputs.forEach(input => input.addEventListener('change', handleUpdate));
80+
inputs.forEach(input => input.addEventListener('mousemove', handleUpdate));
81+
82+
</script>
83+
84+
</body>
85+
86+
</html>

0 commit comments

Comments
 (0)