Skip to content

Commit

Permalink
add demo header & add 10_Hold-Shift-and-Check-Checkboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
guahsu committed Jul 2, 2017
1 parent 70160b3 commit dcddbae
Show file tree
Hide file tree
Showing 16 changed files with 1,197 additions and 552 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.DS_Store
.DS_Store
_*
.* 
164 changes: 95 additions & 69 deletions 01_Java-Script-Drum-Kit/index-GuaHsu.html
Original file line number Diff line number Diff line change
@@ -1,81 +1,107 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<title>JS Drum Kit</title>
<link rel="stylesheet" href="style.css">
<script src="ga.js"></script>
<meta charset="UTF-8">
<title>JS Drum Kit</title>
<link rel="stylesheet" href="style.css">
<script src="ga.js"></script>
</head>

<body>
<div class="keys">
<div data-key="65" class="key">
<kbd>A</kbd>
<span class="sound">clap</span>
</div>
<div data-key="83" class="key">
<kbd>S</kbd>
<span class="sound">hihat</span>
</div>
<div data-key="68" class="key">
<kbd>D</kbd>
<span class="sound">kick</span>
</div>
<div data-key="70" class="key">
<kbd>F</kbd>
<span class="sound">openhat</span>
</div>
<div data-key="71" class="key">
<kbd>G</kbd>
<span class="sound">boom</span>
</div>
<div data-key="72" class="key">
<kbd>H</kbd>
<span class="sound">ride</span>
</div>
<div data-key="74" class="key">
<kbd>J</kbd>
<span class="sound">snare</span>
</div>
<div data-key="75" class="key">
<kbd>K</kbd>
<span class="sound">tom</span>
<style>
.GuaHsu-header {
background-color: #333;
text-align: center;
padding: 10px;
color: #7ff3cb;
font-size: 20px;
font-weight: 100;
}

.GuaHsu-header span {
margin: 0 5px;
}

.GuaHsu-header a {
text-decoration: none;
color: unset;
}
</style>
<div class="GuaHsu-header">
<span><a href="https://guahsu.io/categories/JavaScript30/" target="_blank">JavaScript30 心得</a></span>
<span>|</span>
<span><a href="https://github.com/guahsu/JavaScript30" target="_blank">GitHub</a></span>
</div>
<div data-key="76" class="key">
<kbd>L</kbd>
<span class="sound">tink</span>
<div class="keys">
<div data-key="65" class="key">
<kbd>A</kbd>
<span class="sound">clap</span>
</div>
<div data-key="83" class="key">
<kbd>S</kbd>
<span class="sound">hihat</span>
</div>
<div data-key="68" class="key">
<kbd>D</kbd>
<span class="sound">kick</span>
</div>
<div data-key="70" class="key">
<kbd>F</kbd>
<span class="sound">openhat</span>
</div>
<div data-key="71" class="key">
<kbd>G</kbd>
<span class="sound">boom</span>
</div>
<div data-key="72" class="key">
<kbd>H</kbd>
<span class="sound">ride</span>
</div>
<div data-key="74" class="key">
<kbd>J</kbd>
<span class="sound">snare</span>
</div>
<div data-key="75" class="key">
<kbd>K</kbd>
<span class="sound">tom</span>
</div>
<div data-key="76" class="key">
<kbd>L</kbd>
<span class="sound">tink</span>
</div>
</div>
</div>
<audio data-key="65" src="sounds/clap.wav"></audio>
<audio data-key="83" src="sounds/hihat.wav"></audio>
<audio data-key="68" src="sounds/kick.wav"></audio>
<audio data-key="70" src="sounds/openhat.wav"></audio>
<audio data-key="71" src="sounds/boom.wav"></audio>
<audio data-key="72" src="sounds/ride.wav"></audio>
<audio data-key="74" src="sounds/snare.wav"></audio>
<audio data-key="75" src="sounds/tom.wav"></audio>
<audio data-key="76" src="sounds/tink.wav"></audio>
<script>
function removeTransition(e) {
if (e.propertyName !== 'transform') return;
e.target.classList.remove('playing');
}
function playSound(e) {
let keyNo = e.keyCode || this.getAttribute('data-key'); //add
const audio = document.querySelector(`audio[data-key="${keyNo}"]`);
const key = document.querySelector(`div[data-key="${keyNo}"]`);
if (!audio) return;
<audio data-key="65" src="sounds/clap.wav"></audio>
<audio data-key="83" src="sounds/hihat.wav"></audio>
<audio data-key="68" src="sounds/kick.wav"></audio>
<audio data-key="70" src="sounds/openhat.wav"></audio>
<audio data-key="71" src="sounds/boom.wav"></audio>
<audio data-key="72" src="sounds/ride.wav"></audio>
<audio data-key="74" src="sounds/snare.wav"></audio>
<audio data-key="75" src="sounds/tom.wav"></audio>
<audio data-key="76" src="sounds/tink.wav"></audio>
<script>
function removeTransition(e) {
if (e.propertyName !== 'transform') return;
e.target.classList.remove('playing');
}
function playSound(e) {
let keyNo = e.keyCode || this.getAttribute('data-key'); //add
const audio = document.querySelector(`audio[data-key="${keyNo}"]`);
const key = document.querySelector(`div[data-key="${keyNo}"]`);
if (!audio) return;

key.classList.add('playing');
audio.currentTime = 0;
audio.play();
}
key.classList.add('playing');
audio.currentTime = 0;
audio.play();
}

const keys = Array.from(document.querySelectorAll('.key'));
const listenTarget = ['window', 'click']
keys.forEach(key => key.addEventListener('transitionend', removeTransition));
window.addEventListener('keydown', playSound);
keys.forEach(key => key.addEventListener('click', playSound)); //add
</script>
const keys = Array.from(document.querySelectorAll('.key'));
const listenTarget = ['window', 'click']
keys.forEach(key => key.addEventListener('transitionend', removeTransition));
window.addEventListener('keydown', playSound);
keys.forEach(key => key.addEventListener('click', playSound)); //add
</script>


</body>
Expand Down
23 changes: 22 additions & 1 deletion 02_JS-and-CSS-Clock/index-GuaHsu.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,28 @@
</head>

<body>

<style>
.GuaHsu-header {
background-color: #333;
text-align: center;
padding: 10px;
color: #7ff3cb;
font-size: 20px;
font-weight: 100;
}
.GuaHsu-header span{
margin: 0 5px;
}
.GuaHsu-header a{
text-decoration: none;
color: unset;
}
</style>
<div class="GuaHsu-header">
<span><a href="https://guahsu.io/categories/JavaScript30/" target="_blank">JavaScript30 心得</a></span>
<span>|</span>
<span><a href="https://github.com/guahsu/JavaScript30" target="_blank">GitHub</a></span>
</div>

<div class="clock">
<div class="clock-face">
Expand Down
172 changes: 99 additions & 73 deletions 03_CSS-Variables/index-GuaHsu.html
Original file line number Diff line number Diff line change
@@ -1,81 +1,107 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<title>Scoped CSS Variables and JS</title>
<script src="ga.js"></script>
<meta charset="UTF-8">
<title>Scoped CSS Variables and JS</title>
<script src="ga.js"></script>
</head>
<body>
<h2>Update CSS Variables with <span class='hl'>JS</span></h2>

<div class="controls">
<label for="spacing">Spacing:</label>
<input id="spacing" type="range" name="spacing" min="10" max="200" value="10" data-sizing="px">

<label for="blur">Blur:</label>
<input id="blur" type="range" name="blur" min="0" max="25" value="0" data-sizing="px">

<label for="grayscale">grayscale:</label>
<input id="grayscale" type="range" name="grayscale" min="0" max="100" value="0" data-sizing="%">

<label for="base">Base Color</label>
<input id="base" type="color" name="base" value="#ffc600">
</div>

<img src="https://source.unsplash.com/7bwQXzbF6KE/800x500">

<style>
:root {
--base: #ffc600;
--spacing: 10px;
--blur: 10px;
--grayscale: 0%;
}

img {
padding: var(--spacing);
background: var(--base);
filter: blur(var(--blur)) grayscale(var(--grayscale));
}

.hl {
color: var(--base);
}

/*
misc styles, nothing to do with CSS variables
*/

body {
text-align: center;
background: #193549;
color: white;
font-family: 'helvetica neue', sans-serif;
font-weight: 100;
font-size: 50px;
}

.controls {
margin-bottom: 50px;
}

input {
width:100px;
}
</style>

<script>
const inputs = document.querySelectorAll('.controls input');

function handleUpdate() {
const suffix = this.dataset.sizing || '';
document.documentElement.style.setProperty(`--${this.name}`, this.value + suffix);
}

inputs.forEach(input => input.addEventListener('change', handleUpdate));
inputs.forEach(input => input.addEventListener('mousemove', handleUpdate));
</script>
<body>
<style>
.GuaHsu-header {
background-color: #333;
text-align: center;
padding: 10px;
color: #7ff3cb;
font-size: 20px;
font-weight: 100;
}

.GuaHsu-header span {
margin: 0 5px;
}

.GuaHsu-header a {
text-decoration: none;
color: unset;
}
</style>
<div class="GuaHsu-header">
<span><a href="https://guahsu.io/categories/JavaScript30/" target="_blank">JavaScript30 心得</a></span>
<span>|</span>
<span><a href="https://github.com/guahsu/JavaScript30" target="_blank">GitHub</a></span>
</div>
<h2>Update CSS Variables with <span class='hl'>JS</span></h2>

<div class="controls">
<label for="spacing">Spacing:</label>
<input id="spacing" type="range" name="spacing" min="10" max="200" value="10" data-sizing="px">

<label for="blur">Blur:</label>
<input id="blur" type="range" name="blur" min="0" max="25" value="0" data-sizing="px">

<label for="grayscale">grayscale:</label>
<input id="grayscale" type="range" name="grayscale" min="0" max="100" value="0" data-sizing="%">

<label for="base">Base Color</label>
<input id="base" type="color" name="base" value="#ffc600">
</div>

<img src="https://source.unsplash.com/7bwQXzbF6KE/800x500">

<style>
:root {
--base: #ffc600;
--spacing: 10px;
--blur: 10px;
--grayscale: 0%;
}

img {
padding: var(--spacing);
background: var(--base);
filter: blur(var(--blur)) grayscale(var(--grayscale));
}

.hl {
color: var(--base);
}
/*
misc styles, nothing to do with CSS variables
*/

body {
text-align: center;
background: #193549;
color: white;
font-family: 'helvetica neue', sans-serif;
font-weight: 100;
font-size: 50px;
}

.controls {
margin-bottom: 50px;
}

input {
width: 100px;
}
</style>

<script>
const inputs = document.querySelectorAll('.controls input');

function handleUpdate() {
const suffix = this.dataset.sizing || '';
document.documentElement.style.setProperty(`--${this.name}`, this.value + suffix);
}

inputs.forEach(input => input.addEventListener('change', handleUpdate));
inputs.forEach(input => input.addEventListener('mousemove', handleUpdate));
</script>


</body>
</html>

</html>
Loading

0 comments on commit dcddbae

Please sign in to comment.