CAL-1673: Use dark/light colors from user profile settings in booker (#8905)
* CAL-1673: Use dark/light colors from user profile settings in booker * Use system theme for dynamic booking, instead of theme set by first user.
This commit is contained in:
1 parent
f20a5df322
commit
175fc4fcf3
3 files changed
+33
-10
No files matched your search
@@ -5,10 +5,9 @@ import StickyBox from "react-sticky-box";
|
|||||||
import { shallow } from "zustand/shallow";
|
import { shallow } from "zustand/shallow";
|
||||||
|
|
||||||
import classNames from "@calcom/lib/classNames";
|
import classNames from "@calcom/lib/classNames";
|
||||||
import useGetBrandingColours from "@calcom/lib/getBrandColours";
|
|
||||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||||
import useMediaQuery from "@calcom/lib/hooks/useMediaQuery";
|
import useMediaQuery from "@calcom/lib/hooks/useMediaQuery";
|
||||||
import { ToggleGroup, useCalcomTheme } from "@calcom/ui";
|
import { ToggleGroup } from "@calcom/ui";
|
||||||
import { Calendar, Columns, Grid } from "@calcom/ui/components/icon";
|
import { Calendar, Columns, Grid } from "@calcom/ui/components/icon";
|
||||||
|
|
||||||
import { AvailableTimeSlots } from "./components/AvailableTimeSlots";
|
import { AvailableTimeSlots } from "./components/AvailableTimeSlots";
|
||||||
@@ -23,20 +22,13 @@ import { fadeInLeft, getBookerSizeClassNames, useBookerResizeAnimation } from ".
|
|||||||
import { useBookerStore, useInitializeBookerStore } from "./store";
|
import { useBookerStore, useInitializeBookerStore } from "./store";
|
||||||
import type { BookerLayout, BookerProps } from "./types";
|
import type { BookerLayout, BookerProps } from "./types";
|
||||||
import { useEvent } from "./utils/event";
|
import { useEvent } from "./utils/event";
|
||||||
|
import { useBrandColors } from "./utils/use-brand-colors";
|
||||||
|
|
||||||
const PoweredBy = dynamic(() => import("@calcom/ee/components/PoweredBy"));
|
const PoweredBy = dynamic(() => import("@calcom/ee/components/PoweredBy"));
|
||||||
const DatePicker = dynamic(() => import("./components/DatePicker").then((mod) => mod.DatePicker), {
|
const DatePicker = dynamic(() => import("./components/DatePicker").then((mod) => mod.DatePicker), {
|
||||||
ssr: false,
|
ssr: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const useBrandColors = ({ brandColor, darkBrandColor }: { brandColor?: string; darkBrandColor?: string }) => {
|
|
||||||
const brandTheme = useGetBrandingColours({
|
|
||||||
lightVal: brandColor,
|
|
||||||
darkVal: darkBrandColor,
|
|
||||||
});
|
|
||||||
useCalcomTheme(brandTheme);
|
|
||||||
};
|
|
||||||
|
|
||||||
const BookerComponent = ({ username, eventSlug, month, rescheduleBooking }: BookerProps) => {
|
const BookerComponent = ({ username, eventSlug, month, rescheduleBooking }: BookerProps) => {
|
||||||
const { t } = useLocale();
|
const { t } = useLocale();
|
||||||
const isMobile = useMediaQuery("(max-width: 768px)");
|
const isMobile = useMediaQuery("(max-width: 768px)");
|
||||||
@@ -61,6 +53,7 @@ const BookerComponent = ({ username, eventSlug, month, rescheduleBooking }: Book
|
|||||||
useBrandColors({
|
useBrandColors({
|
||||||
brandColor: event.data?.profile.brandColor,
|
brandColor: event.data?.profile.brandColor,
|
||||||
darkBrandColor: event.data?.profile.darkBrandColor,
|
darkBrandColor: event.data?.profile.darkBrandColor,
|
||||||
|
theme: event.data?.profile.theme,
|
||||||
});
|
});
|
||||||
|
|
||||||
useInitializeBookerStore({
|
useInitializeBookerStore({
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import { useEffect } from "react";
|
||||||
|
|
||||||
|
import useGetBrandingColours from "@calcom/lib/getBrandColours";
|
||||||
|
import useTheme from "@calcom/lib/hooks/useTheme";
|
||||||
|
import { useCalcomTheme } from "@calcom/ui";
|
||||||
|
|
||||||
|
export const useBrandColors = ({
|
||||||
|
brandColor,
|
||||||
|
darkBrandColor,
|
||||||
|
theme,
|
||||||
|
}: {
|
||||||
|
brandColor?: string;
|
||||||
|
darkBrandColor?: string;
|
||||||
|
theme?: string | null;
|
||||||
|
}) => {
|
||||||
|
const brandTheme = useGetBrandingColours({
|
||||||
|
lightVal: brandColor,
|
||||||
|
darkVal: darkBrandColor,
|
||||||
|
});
|
||||||
|
useCalcomTheme(brandTheme);
|
||||||
|
const { setTheme } = useTheme(theme);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (theme) setTheme(theme);
|
||||||
|
}, [setTheme, theme]);
|
||||||
|
};
|
||||||
@@ -54,6 +54,7 @@ const publicEventSelect = Prisma.validator<Prisma.EventTypeSelect>()({
|
|||||||
weekStart: true,
|
weekStart: true,
|
||||||
brandColor: true,
|
brandColor: true,
|
||||||
darkBrandColor: true,
|
darkBrandColor: true,
|
||||||
|
theme: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -80,6 +81,7 @@ export const getPublicEvent = async (username: string, eventSlug: string, prisma
|
|||||||
metadata: true,
|
metadata: true,
|
||||||
brandColor: true,
|
brandColor: true,
|
||||||
darkBrandColor: true,
|
darkBrandColor: true,
|
||||||
|
theme: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -113,6 +115,7 @@ export const getPublicEvent = async (username: string, eventSlug: string, prisma
|
|||||||
image: `${WEBAPP_URL}/${users[0].username}/avatar.png`,
|
image: `${WEBAPP_URL}/${users[0].username}/avatar.png`,
|
||||||
brandColor: users[0].brandColor,
|
brandColor: users[0].brandColor,
|
||||||
darkBrandColor: users[0].darkBrandColor,
|
darkBrandColor: users[0].darkBrandColor,
|
||||||
|
theme: null,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -179,6 +182,7 @@ function getProfileFromEvent(event: Event) {
|
|||||||
logo: !team ? undefined : team.logo,
|
logo: !team ? undefined : team.logo,
|
||||||
brandColor: profile.brandColor,
|
brandColor: profile.brandColor,
|
||||||
darkBrandColor: profile.darkBrandColor,
|
darkBrandColor: profile.darkBrandColor,
|
||||||
|
theme: profile.theme,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user