
* resolved typescript problems for success.tsx, useTheme.tsx and event.ts * remove NextRouter inferred type Co-authored-by: Alex Johansson <alexander@n1s.se> * remove router query inferred type Co-authored-by: Alex Johansson <alexander@n1s.se> * URIcomponent change ternary Co-authored-by: Alex Johansson <alexander@n1s.se> * infer types for event type * completed requested changes * Update pages/success.tsx | change context type to proper Co-authored-by: Alex Johansson <alexander@n1s.se> Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: Alex Johansson <alexander@n1s.se> Co-authored-by: Alex van Andel <me@alexvanandel.com> Co-authored-by: Bailey Pumfleet <pumfleet@hey.com>
24 lines
606 B
TypeScript
24 lines
606 B
TypeScript
import { Maybe } from "@trpc/server";
|
|
import { useEffect, useState } from "react";
|
|
|
|
// makes sure the ui doesn't flash
|
|
export default function useTheme(theme?: Maybe<string>) {
|
|
const [isReady, setIsReady] = useState(false);
|
|
useEffect(() => {
|
|
setIsReady(true);
|
|
if (!theme) {
|
|
return;
|
|
}
|
|
if (!theme && window.matchMedia("(prefers-color-scheme: dark)").matches) {
|
|
document.documentElement.classList.add("dark");
|
|
} else if (!theme) {
|
|
/** Uncovered case */
|
|
} else {
|
|
document.documentElement.classList.add(theme);
|
|
}
|
|
}, []);
|
|
|
|
return {
|
|
isReady,
|
|
};
|
|
}
|