This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="controls"> | |
<select name="toppers"> | |
<option value="⭐">⭐</option> | |
<option value="👼">👼</option> | |
</select> | |
</div> | |
... | |
<script> | |
const topSelector = document.querySelector('select'); | |
const topper = document.querySelector('.topper'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:root { | |
--primary-colour: #ff0000; | |
--secondary-colour: #DAA520; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<circle cx="106" fill="var(--primary-colour)" cy="136" r="16"></circle> | |
<circle cx="346" fill="var(--secondary-colour)" cy="136" r="16"></circle> | |
<circle cx="74" fill="var(--secondary-colour)" cy="226" r="16"></circle> | |
<circle cx="376" fill="var(--primary-colour)" cy="226" r="16"></circle> | |
<circle cx="46" fill="var(--primary-colour)" cy="331" r="16"></circle> | |
<circle cx="406" fill="var(--secondary-colour)" cy="331" r="16"></circle> | |
<circle cx="16" fill="var(--secondary-colour)" cy="451" r="16"></circle> | |
<circle cx="436" fill="var(--primary-colour)" cy="451" r="16"></circle> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const colourPickers = document.querySelectorAll('.colour-picker'); | |
function changeColour() { | |
document.documentElement.style.setProperty(`--${this.name}`, this.value); | |
} | |
colourPickers.forEach(picker => picker.addEventListener('change', changeColour)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const decSelector = document.querySelector('.decorations'); | |
const tree = document.querySelector('.tree-container'); | |
function placeDecoration(e) { | |
if (decSelector.value !== "") { | |
const decoration = document.createElement('div'); | |
decoration.textContent = decSelector.value; | |
decoration.classList.add('decoration'); | |
// minus 15 to account for the decorations’ size of 30px | |
decoration.setAttribute("style", `top: ${e.clientY}px; left: ${e.clientX - 15}px;`); | |
tree.appendChild(decoration); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function twinkle() { | |
if (lightsContainer.hasChildNodes()) { | |
Array.from(lightsContainer.querySelectorAll('circle')).forEach(light => { | |
light.setAttribute('r', `${Math.random()+1}`); | |
}); | |
} | |
} | |
setInterval(twinkle, 500); | |
twinkle(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const snowButton = document.getElementById('snow-button'); | |
const stopButton = document.getElementById('stop-button'); | |
const snowContainer = document.querySelector('.snow-container'); | |
let snowing = null; | |
function letItSnow() { | |
stopButton.classList.remove("hidden-button"); | |
snowButton.classList.add("hidden-button"); | |
function createFlake() { | |
let flake = document.createElement('div'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let startX = 0; | |
let startY = 0; | |
const mainTree = document.querySelector(".main-tree"); | |
function startTinsel(e) { | |
if (decSelector.value === "tinsel") { | |
startX = e.clientX - 58; | |
startY = e.clientY - 82; | |
} | |
} | |
function endTinsel(e) { |
OlderNewer