diff --git a/components/booking/pages/AvailabilityPage.tsx b/components/booking/pages/AvailabilityPage.tsx
index 5e0ad180..de70765e 100644
--- a/components/booking/pages/AvailabilityPage.tsx
+++ b/components/booking/pages/AvailabilityPage.tsx
@@ -35,7 +35,7 @@ type Props = AvailabilityTeamPageProps | AvailabilityPageProps;
const AvailabilityPage = ({ profile, eventType, workingHours }: Props) => {
const router = useRouter();
const { rescheduleUid } = router.query;
- const { isReady } = useTheme(profile.theme);
+ const { isReady, Theme } = useTheme(profile.theme);
const { t } = useLocale();
const { contracts } = useContracts();
@@ -99,6 +99,7 @@ const AvailabilityPage = ({ profile, eventType, workingHours }: Props) => {
return (
<>
+
{
});
const rescheduleUid = router.query.rescheduleUid as string;
- const { isReady } = useTheme(props.profile.theme);
+ const { isReady, Theme } = useTheme(props.profile.theme);
const date = asStringOrNull(router.query.date);
const timeFormat = asStringOrNull(router.query.clock) === "24h" ? "H:mm" : "h:mma";
@@ -275,6 +275,7 @@ const BookingPage = (props: BookingPageProps) => {
return (
+
{rescheduleUid
diff --git a/ee/components/stripe/PaymentPage.tsx b/ee/components/stripe/PaymentPage.tsx
index 7614d52d..0587031c 100644
--- a/ee/components/stripe/PaymentPage.tsx
+++ b/ee/components/stripe/PaymentPage.tsx
@@ -23,7 +23,7 @@ const PaymentPage: FC = (props) => {
const { t } = useLocale();
const [is24h, setIs24h] = useState(false);
const [date, setDate] = useState(dayjs.utc(props.booking.startTime));
- const { isReady } = useTheme(props.profile.theme);
+ const { isReady, Theme } = useTheme(props.profile.theme);
useEffect(() => {
setDate(date.tz(localStorage.getItem("timeOption.preferredTimeZone") || dayjs.tz.guess()));
@@ -34,6 +34,7 @@ const PaymentPage: FC = (props) => {
return isReady ? (
+
{t("payment")} | {eventName} | Cal.com
diff --git a/lib/hooks/useTheme.tsx b/lib/hooks/useTheme.tsx
index ec56b322..2b9ff7e5 100644
--- a/lib/hooks/useTheme.tsx
+++ b/lib/hooks/useTheme.tsx
@@ -1,24 +1,36 @@
-import { useLayoutEffect, useState } from "react";
+import Head from "next/head";
+import { useEffect, useState } from "react";
import { Maybe } from "@trpc/server";
// makes sure the ui doesn't flash
export default function useTheme(theme?: Maybe) {
const [isReady, setIsReady] = useState(false);
-
- useLayoutEffect(() => {
- 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);
- }
-
+ useEffect(() => {
setIsReady(true);
- }, [theme]);
+ }, []);
+ function Theme() {
+ const themeString = theme ? `"${theme}"` : null;
+ return (
+
+
+
+ );
+ }
return {
isReady,
+ Theme,
};
}
diff --git a/pages/[user].tsx b/pages/[user].tsx
index 193f2818..2abdbc76 100644
--- a/pages/[user].tsx
+++ b/pages/[user].tsx
@@ -26,7 +26,7 @@ interface EvtsToVerify {
}
export default function User(props: inferSSRProps) {
- const { isReady } = useTheme(props.user.theme);
+ const { isReady, Theme } = useTheme(props.user.theme);
const { user, eventTypes } = props;
const { t } = useLocale();
const router = useRouter();
@@ -38,6 +38,7 @@ export default function User(props: inferSSRProps) {
return (
<>
+
)
const [is24h, setIs24h] = useState(false);
const [date, setDate] = useState(dayjs.utc(asStringOrThrow(router.query.date)));
- const { isReady } = useTheme(props.profile.theme);
+ const { isReady, Theme } = useTheme(props.profile.theme);
useEffect(() => {
setDate(date.tz(localStorage.getItem("timeOption.preferredTimeZone") || dayjs.tz.guess()));
@@ -90,6 +90,7 @@ export default function Success(props: inferSSRProps)
return (
(isReady && (
+
;
function TeamPage({ team }: TeamPageProps) {
- const { isReady } = useTheme();
+ const { isReady, Theme } = useTheme();
const showMembers = useToggleQuery("members");
const { t } = useLocale();
@@ -63,6 +63,7 @@ function TeamPage({ team }: TeamPageProps) {
return (
isReady && (