mirror of
https://github.com/System-End/My-website.git
synced 2026-04-19 18:35:13 +00:00
20 lines
No EOL
648 B
JavaScript
20 lines
No EOL
648 B
JavaScript
import React, { useEffect } from 'react';
|
|
|
|
function ThemeToggle() {
|
|
useEffect(() => {
|
|
const colorPicker = document.getElementById('theme-color-picker');
|
|
const currentColor = localStorage.getItem('theme-color') || '#3f10ad';
|
|
document.documentElement.style.setProperty('--primary-color', currentColor);
|
|
colorPicker.value = currentColor;
|
|
|
|
colorPicker.addEventListener('input', (event) => {
|
|
const newColor = event.target.value;
|
|
document.documentElement.style.setProperty('--primary-color', newColor);
|
|
localStorage.setItem('theme-color', newColor);
|
|
});
|
|
}, []);
|
|
|
|
return null;
|
|
}
|
|
|
|
export default ThemeToggle; |