feature/searchbar-enhance #17

Merged
ilia merged 48 commits from feature/searchbar-enhance into main 2026-01-18 14:04:53 +00:00
Showing only changes of commit ba883ef9a8 - Show all commits

View File

@@ -4,11 +4,6 @@ const isBrowser = typeof window !== 'undefined';
class MotionPreference { class MotionPreference {
// Reactive state // Reactive state
#reduced = $state(false); #reduced = $state(false);
#mediaQuery: MediaQueryList = new MediaQueryList();
private handleChange = (e: MediaQueryListEvent) => {
this.#reduced = e.matches;
};
constructor() { constructor() {
if (isBrowser) { if (isBrowser) {
@@ -17,9 +12,12 @@ class MotionPreference {
// Set initial value immediately // Set initial value immediately
this.#reduced = mediaQuery.matches; this.#reduced = mediaQuery.matches;
mediaQuery.addEventListener('change', this.handleChange); // Simple listener that updates the reactive state
const handleChange = (e: MediaQueryListEvent) => {
this.#reduced = e.matches;
};
this.#mediaQuery = mediaQuery; mediaQuery.addEventListener('change', handleChange);
} }
} }
@@ -27,10 +25,6 @@ class MotionPreference {
get reduced() { get reduced() {
return this.#reduced; return this.#reduced;
} }
destroy() {
this.#mediaQuery.removeEventListener('change', this.handleChange);
}
} }
// Export a single instance to be used everywhere // Export a single instance to be used everywhere