* dumb components for calendar settings * shadcn switch * update exports * update packages * add calendar settings atom to examples app * init calendar settings atom * refactors * fix import path * export type for calendar switch props * invalidate queries on deleting calendar credentials * replace calendars list with calendar settings wrapper * cleanup * update styling * refactors * cleanup * fix: missing key prop CalendarSettingsPlatformWrapper * Label as client components * Address client component build errors * Move QueryCell out of packages/lib * PR feedback * more feedback --------- Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com> Co-authored-by: Morgan Vernay <morgan@cal.com> Co-authored-by: Joe Au-Yeung <j.auyeung419@gmail.com>
31 lines
880 B
TypeScript
31 lines
880 B
TypeScript
"use client";
|
|
|
|
import { useEffect } from "react";
|
|
|
|
type CssVariables = Record<string, string>;
|
|
|
|
// Sets up CSS Variables based on brand colours
|
|
const useCalcomTheme = (theme: Record<string, CssVariables>) => {
|
|
useEffect(() => {
|
|
Object.entries(theme).forEach(([key, value]) => {
|
|
if (key === "root") {
|
|
const root = document.documentElement;
|
|
Object.entries(value).forEach(([key, value]) => {
|
|
root.style.setProperty(`--${key}`, value);
|
|
});
|
|
return;
|
|
}
|
|
|
|
const elements = document.querySelectorAll(`.${key}`);
|
|
const nestedEntries = Object.entries(value);
|
|
nestedEntries.forEach(([nestedKey, nestedValue]) => {
|
|
elements.forEach((element) => {
|
|
(element as HTMLElement).style.setProperty(`--${nestedKey}`, nestedValue);
|
|
});
|
|
});
|
|
});
|
|
}, [theme]);
|
|
};
|
|
|
|
export { useCalcomTheme };
|