Scheduling infrastructure for absolutely everyone.
add "reset to default" color option for ColorPicker (#8643)
Praneeth Bhogaraju371e7b024a0b
diff --git a/apps/web/pages/settings/my-account/appearance.tsx b/apps/web/pages/settings/my-account/appearance.tsxindex 8403619d68b..cff2e5901d1 100644--- a/apps/web/pages/settings/my-account/appearance.tsx+++ b/apps/web/pages/settings/my-account/appearance.tsx@@ -146,6 +146,7 @@ const AppearanceView = () => {<p className="text-default mb-2 block text-sm font-medium">{t("light_brand_color")}</p><ColorPickerdefaultValue={user.brandColor}+ resetDefaultValue="#292929"onChange={(value) => {if (!checkWCAGContrastColor("#ffffff", value)) {setLightModeError(true);@@ -167,6 +168,7 @@ const AppearanceView = () => {<p className="text-default mb-2 block text-sm font-medium">{t("dark_brand_color")}</p><ColorPickerdefaultValue={user.darkBrandColor}+ resetDefaultValue="#fafafa"onChange={(value) => {if (!checkWCAGContrastColor("#101010", value)) {setDarkModeError(true);diff --git a/packages/features/ee/teams/pages/team-appearance-view.tsx b/packages/features/ee/teams/pages/team-appearance-view.tsxindex 031352762fe..cb46c96b415 100644--- a/packages/features/ee/teams/pages/team-appearance-view.tsx+++ b/packages/features/ee/teams/pages/team-appearance-view.tsx@@ -151,6 +151,7 @@ const ProfileView = () => {<p className="text-emphasis mb-2 block text-sm font-medium">{t("light_brand_color")}</p><ColorPickerdefaultValue={team.brandColor}+ resetDefaultValue="#292929"onChange={(value) => form.setValue("brandColor", value, { shouldDirty: true })}/></div>@@ -165,6 +166,7 @@ const ProfileView = () => {<p className="text-emphasis mb-2 block text-sm font-medium">{t("dark_brand_color")}</p><ColorPickerdefaultValue={team.darkBrandColor}+ resetDefaultValue="#fafafa"onChange={(value) => form.setValue("darkBrandColor", value, { shouldDirty: true })}/></div>diff --git a/packages/ui/components/form/color-picker/colorpicker.tsx b/packages/ui/components/form/color-picker/colorpicker.tsxindex 99630c28401..6cdfe3752fc 100644--- a/packages/ui/components/form/color-picker/colorpicker.tsx+++ b/packages/ui/components/form/color-picker/colorpicker.tsx@@ -4,6 +4,8 @@ import { HexColorInput, HexColorPicker } from "react-colorful";import cx from "@calcom/lib/classNames";import { fallBackHex, isValidHexCode } from "@calcom/lib/getBrandColours";+import { Button } from "@calcom/ui";+import { RotateCcw } from "@calcom/ui/components/icon";export type ColorPickerProps = {defaultValue: string;@@ -11,12 +13,18 @@ export type ColorPickerProps = {container?: HTMLElement;popoverAlign?: React.ComponentProps<typeof Popover.Content>["align"];className?: string;+ resetDefaultValue?: string;};const ColorPicker = (props: ColorPickerProps) => {const init = !isValidHexCode(props.defaultValue)? fallBackHex(props.defaultValue, false): props.defaultValue;+ const resetDefaultValue =+ props.resetDefaultValue &&+ (!isValidHexCode(props.resetDefaultValue)+ ? fallBackHex(props.resetDefaultValue, false)+ : props.resetDefaultValue);const [color, setColor] = useState(init);return (@@ -57,6 +65,22 @@ const ColorPicker = (props: ColorPickerProps) => {}}type="text"/>+ {resetDefaultValue && color != resetDefaultValue && (+ <div className="px-1">+ <Button+ color={resetDefaultValue == "#292929" ? "primary" : "secondary"}+ target="_blank"+ variant="icon"+ rel="noreferrer"+ StartIcon={RotateCcw}+ tooltip="Reset to default"+ onClick={() => {+ setColor(fallBackHex(resetDefaultValue, false));+ props.onChange(resetDefaultValue);+ }}+ />+ </div>+ )}</div>);};