feat: add theming options to teams (#6807)
This commit is contained in:
1 parent
5b165e6ebf
commit
7ee5967075
10 files changed
+251
-116
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { GetServerSidePropsContext } from "next";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
|
||||
import ThemeLabel from "@calcom/features/settings/ThemeLabel";
|
||||
import { getLayout } from "@calcom/features/settings/layouts/SettingsLayout";
|
||||
import { APP_NAME } from "@calcom/lib/constants";
|
||||
import { useHasPaidPlan } from "@calcom/lib/hooks/useHasPaidPlan";
|
||||
@@ -225,36 +226,3 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
|
||||
};
|
||||
|
||||
export default AppearanceView;
|
||||
interface ThemeLabelProps {
|
||||
variant: "light" | "dark" | "system";
|
||||
value?: "light" | "dark" | null;
|
||||
label: string;
|
||||
defaultChecked?: boolean;
|
||||
register: any;
|
||||
}
|
||||
|
||||
const ThemeLabel = ({ variant, label, value, defaultChecked, register }: ThemeLabelProps) => {
|
||||
return (
|
||||
<label
|
||||
className="relative mb-4 flex-1 cursor-pointer text-center last:mb-0 last:mr-0 sm:mr-4 sm:mb-0"
|
||||
htmlFor={`theme-${variant}`}>
|
||||
<input
|
||||
className="peer absolute top-8 left-8"
|
||||
type="radio"
|
||||
value={value}
|
||||
id={`theme-${variant}`}
|
||||
defaultChecked={defaultChecked}
|
||||
{...register("theme")}
|
||||
/>
|
||||
<div className="relative z-10 rounded-lg ring-black transition-all peer-checked:ring-2">
|
||||
<img
|
||||
aria-hidden="true"
|
||||
className="cover w-full rounded-lg"
|
||||
src={`/theme-${variant}.svg`}
|
||||
alt={`theme ${variant}`}
|
||||
/>
|
||||
</div>
|
||||
<p className="mt-2 text-sm font-medium text-gray-600 peer-checked:text-gray-900">{label}</p>
|
||||
</label>
|
||||
);
|
||||
};
|
||||
@@ -27,7 +27,7 @@ const md = new MarkdownIt("default", { html: true, breaks: true, linkify: true }
|
||||
|
||||
export type TeamPageProps = inferSSRProps<typeof getServerSideProps>;
|
||||
function TeamPage({ team }: TeamPageProps) {
|
||||
useTheme();
|
||||
useTheme(team.theme);
|
||||
const showMembers = useToggleQuery("members");
|
||||
const { t } = useLocale();
|
||||
const isEmbed = useIsEmbed();
|
||||
|
||||
@@ -43,6 +43,9 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
|
||||
slug: true,
|
||||
logo: true,
|
||||
hideBranding: true,
|
||||
brandColor: true,
|
||||
darkBrandColor: true,
|
||||
theme: true,
|
||||
eventTypes: {
|
||||
where: {
|
||||
slug: typeParam,
|
||||
@@ -68,6 +71,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
title: true,
|
||||
availability: true,
|
||||
description: true,
|
||||
@@ -150,10 +154,10 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
|
||||
name: team.name || team.slug,
|
||||
slug: team.slug,
|
||||
image: team.logo,
|
||||
theme: null as string | null,
|
||||
theme: team.theme,
|
||||
weekStart: "Sunday",
|
||||
brandColor: "" /* TODO: Add a way to set a brand color for Teams */,
|
||||
darkBrandColor: "" /* TODO: Add a way to set a brand color for Teams */,
|
||||
brandColor: team.brandColor,
|
||||
darkBrandColor: team.darkBrandColor,
|
||||
},
|
||||
date: dateParam,
|
||||
eventType: eventTypeObject,
|
||||
|
||||
@@ -67,6 +67,9 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
slug: true,
|
||||
name: true,
|
||||
logo: true,
|
||||
theme: true,
|
||||
brandColor: true,
|
||||
darkBrandColor: true,
|
||||
},
|
||||
},
|
||||
users: {
|
||||
@@ -128,9 +131,6 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
// FIXME: This slug is used as username on success page which is wrong. This is correctly set as username for user booking.
|
||||
slug: "team/" + eventTypeObject.slug,
|
||||
image: eventTypeObject.team?.logo || null,
|
||||
theme: null as string | null /* Teams don't have a theme, and `BookingPage` uses it */,
|
||||
brandColor: null /* Teams don't have a brandColor, and `BookingPage` uses it */,
|
||||
darkBrandColor: null /* Teams don't have a darkBrandColor, and `BookingPage` uses it */,
|
||||
eventName: null,
|
||||
},
|
||||
eventType: eventTypeObject,
|
||||
|
||||
Reference in new issue
Block a user