mirror of
https://github.com/System-End/My-website.git
synced 2026-04-19 23:22:50 +00:00
13 lines
No EOL
573 B
JavaScript
13 lines
No EOL
573 B
JavaScript
const colorPicker = document.getElementById('theme-color-picker'); // Get the color picker element
|
|
|
|
// set intial color
|
|
const currentColor = localStorage.getItem('theme-color'); || '#3f10ad';
|
|
document.documentElement.style.setProperty('--primary-color', currentColor);
|
|
colorPicker.value = currentColor;
|
|
|
|
// update theme color and sae in local storage
|
|
colorPicker.addEventListener('input', (event) => {
|
|
const newColor = event.target.value;
|
|
document.documentElement.style.setProperty('--primary-color', newColor);
|
|
localStorage.setItem('theme-color', newColor);
|
|
}) |