Feature/cal 677 brand color in settingsprofile (#1158)

* added CSS variable --brand-color

* added CustomBranding component

* prisma update for brand color

* added brandcolor to user context in viewer.me

* conflict resolution

* added brandColor input and mutation

* custom brand color to availability

* brandColor added to BookingPage

* fixed availability, booking for team and added customBranding to success

* brandColor added to cancel/uid

* requested changes

* lint fix

* further changes

* lint fix
This commit is contained in:
Syed Ali Shahbaz authored and GitHub committed 2021-11-16 14:21:46 +05:30
1 parent 11e7779a58
commit 4e01b13133
16 files changed
+94 -29

No files matched your search

+2
View File
@@ -70,6 +70,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
weekStart: true,
availability: true,
hideBranding: true,
brandColor: true,
theme: true,
plan: true,
eventTypes: {
@@ -192,6 +193,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
slug: user.username,
theme: user.theme,
weekStart: user.weekStart,
brandColor: user.brandColor,
},
date: dateParam,
eventType: eventTypeObject,
+2
View File
@@ -34,6 +34,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
bio: true,
avatar: true,
theme: true,
brandColor: true,
},
});
@@ -108,6 +109,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
name: user.name,
image: user.avatar,
theme: user.theme,
brandColor: user.brandColor,
},
eventType: eventTypeObject,
booking,
+3
View File
@@ -9,6 +9,7 @@ import { useLocale } from "@lib/hooks/useLocale";
import prisma from "@lib/prisma";
import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@lib/telemetry";
import CustomBranding from "@components/CustomBranding";
import { HeadSeo } from "@components/seo/head-seo";
import { Button } from "@components/ui/Button";
@@ -64,6 +65,7 @@ export default function Type(props) {
title={`${t("cancel")} ${props.booking && props.booking.title} | ${props.profile.name}`}
description={`${t("cancel")} ${props.booking && props.booking.title} | ${props.profile.name}`}
/>
<CustomBranding val={props.profile.brandColor} />
<main className="max-w-3xl mx-auto my-24">
<div className="fixed inset-0 z-50 overflow-y-auto">
<div className="flex items-end justify-center min-h-screen px-4 pt-4 pb-20 text-center sm:block sm:p-0">
@@ -159,6 +161,7 @@ export async function getServerSideProps(context) {
id: true,
username: true,
name: true,
brandColor: true,
},
},
eventType: {
+22
View File
@@ -136,6 +136,8 @@ function SettingsView(props: ComponentProps<typeof Settings> & { localeProp: str
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const avatarRef = useRef<HTMLInputElement>(null!);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const brandColorRef = useRef<HTMLInputElement>(null!);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const hideBrandingRef = useRef<HTMLInputElement>(null!);
const [selectedTheme, setSelectedTheme] = useState<OptionTypeBase>();
const [selectedTimeZone, setSelectedTimeZone] = useState<ITimezone>(props.user.timeZone);
@@ -166,6 +168,7 @@ function SettingsView(props: ComponentProps<typeof Settings> & { localeProp: str
const enteredName = nameRef.current.value;
const enteredDescription = descriptionRef.current.value;
const enteredAvatar = avatarRef.current.value;
const enteredBrandColor = brandColorRef.current.value;
const enteredTimeZone = typeof selectedTimeZone === "string" ? selectedTimeZone : selectedTimeZone.value;
const enteredWeekStartDay = selectedWeekStartDay.value;
const enteredHideBranding = hideBrandingRef.current.checked;
@@ -182,6 +185,7 @@ function SettingsView(props: ComponentProps<typeof Settings> & { localeProp: str
weekStart: asStringOrUndefined(enteredWeekStartDay),
hideBranding: enteredHideBranding,
theme: asStringOrNull(selectedTheme?.value),
brandColor: enteredBrandColor,
locale: enteredLanguage,
});
}
@@ -370,6 +374,23 @@ function SettingsView(props: ComponentProps<typeof Settings> & { localeProp: str
</div>
</div>
</div>
<div>
<label htmlFor="brandColor" className="block text-sm font-medium text-gray-700">
{t("brand_color")}
</label>
<div className="flex mt-1">
<input
ref={brandColorRef}
type="text"
name="brandColor"
id="brandColor"
placeholder="#hex-code"
className="block w-full px-3 py-2 mt-1 border border-gray-300 rounded-sm shadow-sm focus:outline-none focus:ring-neutral-500 focus:border-neutral-500 sm:text-sm"
defaultValue={props.user.brandColor}
/>
</div>
<hr className="mt-6" />
</div>
<div>
<div className="relative flex items-start">
<div className="flex items-center h-5">
@@ -434,6 +455,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
hideBranding: true,
theme: true,
plan: true,
brandColor: true,
},
});
+5
View File
@@ -18,6 +18,7 @@ import { isBrandingHidden } from "@lib/isBrandingHidden";
import prisma from "@lib/prisma";
import { inferSSRProps } from "@lib/types/inferSSRProps";
import CustomBranding from "@components/CustomBranding";
import { HeadSeo } from "@components/seo/head-seo";
import Button from "@components/ui/Button";
@@ -89,6 +90,7 @@ export default function Success(props: inferSSRProps<typeof getServerSideProps>)
title={needsConfirmation ? t("booking_submitted") : t("booking_confirmed")}
description={needsConfirmation ? t("booking_submitted") : t("booking_confirmed")}
/>
<CustomBranding val={props.profile.brandColor} />
<main className="max-w-3xl py-24 mx-auto">
<div className="fixed inset-0 z-50 overflow-y-auto">
<div className="flex items-end justify-center min-h-screen px-4 pt-4 pb-20 text-center sm:block sm:p-0">
@@ -303,6 +305,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
hideBranding: true,
plan: true,
theme: true,
brandColor: true,
},
},
team: {
@@ -330,6 +333,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
hideBranding: true,
plan: true,
theme: true,
brandColor: true,
},
});
if (user) {
@@ -346,6 +350,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
const profile = {
name: eventType.team?.name || eventType.users[0]?.name || null,
theme: (!eventType.team?.name && eventType.users[0]?.theme) || null,
brandColor: eventType.team ? null : eventType.users[0].brandColor,
};
return {