mirror of
https://github.com/Xevion/xevion.dev.git
synced 2025-12-10 12:09:15 -06:00
Make client hoverable methods SSR compatible for NextJS
This commit is contained in:
@@ -2,8 +2,16 @@ export function classNames(...classes: (string | null | undefined)[]) {
|
||||
return classes.filter(Boolean).join(" ");
|
||||
}
|
||||
|
||||
const hoverableQuery = window.matchMedia('(hover: hover) and (pointer: fine)');
|
||||
const isClient = (): boolean => {
|
||||
return typeof window !== "undefined";
|
||||
}
|
||||
|
||||
const isServer = (): boolean => {
|
||||
return !isClient();
|
||||
}
|
||||
|
||||
const hoverableQuery: MediaQueryList | null = isClient() ? window.matchMedia('(hover: hover) and (pointer: fine)') : null;
|
||||
|
||||
export function isHoverable() {
|
||||
return hoverableQuery.matches;
|
||||
return hoverableQuery?.matches;
|
||||
}
|
||||
Reference in New Issue
Block a user