Created
February 28, 2025 12:21
-
-
Save bjulius/03dc31ba83bf52d4eb2d7ee1417e48ba to your computer and use it in GitHub Desktop.
Html for React Slider Component
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Moving Average Slider</title> | |
<style> | |
.slider-container { | |
display: flex; | |
align-items: center; | |
margin-bottom: 1rem; | |
} | |
.label { | |
margin-right: 0.5rem; | |
font-weight: 500; | |
} | |
.slider { | |
margin-right: 0.5rem; | |
} | |
.value-display { | |
font-weight: 700; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="slider-container"> | |
<span class="label">Moving Average Window:</span> | |
<input | |
type="range" | |
min="2" | |
max="14" | |
value="7" | |
id="windowSizeSlider" | |
class="slider" | |
/> | |
<span class="value-display" id="windowSizeValue">7 days</span> | |
</div> | |
<script> | |
// Get DOM elements | |
const windowSizeSlider = document.getElementById('windowSizeSlider'); | |
const windowSizeValue = document.getElementById('windowSizeValue'); | |
// Initialize with default value | |
let windowSize = 7; | |
windowSizeValue.textContent = `${windowSize} days`; | |
// Add event listener for slider changes | |
windowSizeSlider.addEventListener('input', function(e) { | |
windowSize = parseInt(e.target.value); | |
windowSizeValue.textContent = `${windowSize} days`; | |
// You can add your visualization update logic here | |
updateVisualization(windowSize); | |
}); | |
// Placeholder function for updating your visualization | |
function updateVisualization(windowSize) { | |
// Replace this with your actual visualization update code | |
console.log(`Updating visualization with window size: ${windowSize}`); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment