Refactor dark mode handling and update UI components

Extract dark mode logic into a reusable helper function to improve code clarity and maintainability. Updated the UI layout for better structure and styling, including replacing placeholder logos and enhancing card design.
This commit is contained in:
2025-02-08 00:22:20 +01:00
parent 9b45752d1a
commit 7b1c4c27fe
3 changed files with 54 additions and 55 deletions

View File

@@ -0,0 +1,25 @@
export function handleDarkMode(): () => void {
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
// Function to update dark mode for Syncfusion controls
const updateDarkMode = (e: MediaQueryList | MediaQueryListEvent) => {
if (e.matches) {
// If the system is in dark mode, add the class
document.body.classList.add("e-dark-mode");
} else {
// Otherwise, remove it
document.body.classList.remove("e-dark-mode");
}
};
// Set initial mode based on system preference:
updateDarkMode(mediaQuery); // Pass the initial `mediaQuery` directly
// Listen for changes in system preference:
mediaQuery.addEventListener("change", updateDarkMode);
// Cleanup function to remove the event listener
return () => {
mediaQuery.removeEventListener("change", updateDarkMode);
};
}