Skip to content

Added helpful features to ingredient description list #126

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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 dom_manipulation/billy.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 9 additions & 9 deletions dom_manipulation/button.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<!DOCTYPE html>
<html>
<head><title>JavaScript Button Example</title></head>
<head>
<title>JavaScript Button Example</title>

<link rel="stylesheet" href="styles.css">

</head>

<body>
<button id='squeeze'>Squeeze me</button>
<img id="bill" class="billImg" src="billy.jpg" width=100% height=100%>
<button id='squeeze'>Squeeze me</button>

<script>
let button = document.getElementById("squeeze");
function shout(){
alert("... and I squeak");
}
button.addEventListener("click", shout);
</script>
<script src="script.js"></script>
</body>
</html>
26 changes: 26 additions & 0 deletions dom_manipulation/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const DECAY_RATE = 0.9
let intervalID = -1

function decay() {
let root = document.querySelector(":root");
let styleSheet = getComputedStyle(root);

let value = parseFloat(styleSheet.getPropertyValue("--billOpacity")) * DECAY_RATE;
root.style.setProperty("--billOpacity", `${value}`);
}

function goodNamesAreHard() {
let root = document.querySelector(":root")

root.style.setProperty("--billOpacity", "1")
}

function onLoad() {
let button = document.getElementById("squeeze");
button.addEventListener("click", goodNamesAreHard);

// Every 50ms
intervalID = window.setInterval(decay, 50);
}

document.addEventListener("DOMContentLoaded", onLoad);
12 changes: 12 additions & 0 deletions dom_manipulation/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
:root {
--billOpacity: 0;
}

.billImg {
opacity: var(--billOpacity);
position: fixed;
}

#squeeze {
position: absolute;
}
26 changes: 18 additions & 8 deletions html_css/styling-lists.html

Large diffs are not rendered by default.