refactor: event type settings improvements (#11615)
This commit is contained in:
1 parent
4f942e1a13
commit
226ac889c7
12 files changed
+97
-64
No files matched your search
@@ -107,12 +107,12 @@ export const FormBuilder = function FormBuilder({
|
||||
return (
|
||||
<div>
|
||||
<div>
|
||||
<div className="text-default text-sm font-semibold ltr:mr-1 rtl:ml-1">
|
||||
<div className="text-default text-sm font-semibold leading-none ltr:mr-1 rtl:ml-1">
|
||||
{title}
|
||||
{LockedIcon}
|
||||
</div>
|
||||
<p className="text-subtle max-w-[280px] break-words py-1 text-sm sm:max-w-[500px]">{description}</p>
|
||||
<ul ref={parent} className="border-subtle divide-subtle mt-2 divide-y rounded-md border">
|
||||
<p className="text-subtle mt-0.5 max-w-[280px] break-words text-sm sm:max-w-[500px]">{description}</p>
|
||||
<ul ref={parent} className="border-subtle divide-subtle mt-4 divide-y rounded-md border">
|
||||
{fields.map((field, index) => {
|
||||
const options = field.options
|
||||
? field.options
|
||||
|
||||
@@ -34,6 +34,7 @@ type BookerLayoutSelectorProps = {
|
||||
isDark?: boolean;
|
||||
|
||||
isDisabled?: boolean;
|
||||
isOuterBorder?: boolean;
|
||||
};
|
||||
|
||||
const defaultFieldName = "metadata.bookerLayouts";
|
||||
@@ -45,6 +46,7 @@ export const BookerLayoutSelector = ({
|
||||
fallbackToUserSettings,
|
||||
isDark,
|
||||
isDisabled = false,
|
||||
isOuterBorder = false,
|
||||
}: BookerLayoutSelectorProps) => {
|
||||
const { control, getValues } = useFormContext();
|
||||
const { t } = useLocale();
|
||||
@@ -55,10 +57,12 @@ export const BookerLayoutSelector = ({
|
||||
if (flags["booker-layouts"] !== true) return null;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="border-subtle rounded-t-xl border p-6">
|
||||
<Label className="mb-0 text-base font-semibold">{title ? title : t("layout")}</Label>
|
||||
<p className="text-subtle max-w-full break-words py-1 text-sm">
|
||||
<div className={classNames(isOuterBorder && "border-subtle rounded-lg border p-6")}>
|
||||
<div className={classNames(isOuterBorder ? "pb-5" : "border-subtle rounded-t-xl border p-6")}>
|
||||
<Label className={classNames("mb-1 font-semibold", isOuterBorder ? "text-sm" : "text-base")}>
|
||||
{title ? title : t("layout")}
|
||||
</Label>
|
||||
<p className="text-subtle max-w-full break-words text-sm leading-tight">
|
||||
{description ? description : t("bookerlayout_description")}
|
||||
</p>
|
||||
</div>
|
||||
@@ -75,12 +79,15 @@ export const BookerLayoutSelector = ({
|
||||
settings={value}
|
||||
onChange={onChange}
|
||||
isDark={isDark}
|
||||
isOuterBorder={isOuterBorder}
|
||||
/>
|
||||
<SectionBottomActions align="end">
|
||||
<Button type="submit" disabled={isDisabled} color="primary">
|
||||
{t("update")}
|
||||
</Button>
|
||||
</SectionBottomActions>
|
||||
{!isOuterBorder && (
|
||||
<SectionBottomActions align="end">
|
||||
<Button type="submit" disabled={isDisabled} color="primary">
|
||||
{t("update")}
|
||||
</Button>
|
||||
</SectionBottomActions>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
/>
|
||||
@@ -93,11 +100,18 @@ type BookerLayoutFieldsProps = {
|
||||
onChange: (settings: BookerLayoutSettings) => void;
|
||||
showUserSettings: boolean;
|
||||
isDark?: boolean;
|
||||
isOuterBorder?: boolean;
|
||||
};
|
||||
|
||||
type BookerLayoutState = { [key in BookerLayouts]: boolean };
|
||||
|
||||
const BookerLayoutFields = ({ settings, onChange, showUserSettings, isDark }: BookerLayoutFieldsProps) => {
|
||||
const BookerLayoutFields = ({
|
||||
settings,
|
||||
onChange,
|
||||
showUserSettings,
|
||||
isDark,
|
||||
isOuterBorder,
|
||||
}: BookerLayoutFieldsProps) => {
|
||||
const { t } = useLocale();
|
||||
const { isLoading: isUserLoading, data: user } = useMeQuery();
|
||||
const [isOverridingSettings, setIsOverridingSettings] = useState(false);
|
||||
@@ -153,9 +167,8 @@ const BookerLayoutFields = ({ settings, onChange, showUserSettings, isDark }: Bo
|
||||
// Sent default layout settings to form, otherwise it would still have 'null' as it's value.
|
||||
if (user?.defaultBookerLayouts) onChange(user.defaultBookerLayouts);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="border-subtle space-y-5 border-x px-6 py-8">
|
||||
<div className={classNames("space-y-5", !isOuterBorder && "border-subtle border-x px-6 py-8")}>
|
||||
<div
|
||||
className={classNames(
|
||||
"flex flex-col gap-5 transition-opacity sm:flex-row sm:gap-3",
|
||||
@@ -191,7 +204,7 @@ const BookerLayoutFields = ({ settings, onChange, showUserSettings, isDark }: Bo
|
||||
<Label>{t("bookerlayout_default_title")}</Label>
|
||||
<RadioGroup.Root
|
||||
key={defaultLayout}
|
||||
className="border-default flex w-full gap-2 rounded-md border p-1"
|
||||
className="border-subtle flex w-full gap-2 rounded-md border p-1"
|
||||
defaultValue={defaultLayout}
|
||||
onValueChange={(layout: BookerLayouts) => onDefaultLayoutChange(layout)}>
|
||||
{bookerLayoutOptions.map((layout) => (
|
||||
@@ -209,18 +222,18 @@ const BookerLayoutFields = ({ settings, onChange, showUserSettings, isDark }: Bo
|
||||
{disableFields && (
|
||||
<p className="text-sm">
|
||||
<Trans i18nKey="bookerlayout_override_global_settings">
|
||||
You can manage this for all your event types in{" "}
|
||||
You can manage this for all your event types in Settings {"-> "}
|
||||
<Link href="/settings/my-account/appearance" className="underline">
|
||||
settings / appearance
|
||||
Appearance
|
||||
</Link>{" "}
|
||||
or{" "}
|
||||
<Button
|
||||
onClick={onOverrideSettings}
|
||||
color="minimal"
|
||||
className="p-0 font-normal underline hover:bg-transparent focus-visible:bg-transparent">
|
||||
override for this event only
|
||||
</Button>
|
||||
.
|
||||
className="h-fit p-0 font-normal underline hover:bg-transparent focus-visible:bg-transparent">
|
||||
Override
|
||||
</Button>{" "}
|
||||
for this event only.
|
||||
</Trans>
|
||||
</p>
|
||||
)}
|
||||
|
||||
@@ -10,13 +10,13 @@ export function ArrowButton(props: ArrowButtonProps) {
|
||||
<>
|
||||
{props.arrowDirection === "up" ? (
|
||||
<button
|
||||
className="bg-default text-muted hover:text-emphasis border-default hover:border-emphasis invisible absolute left-[5px] -ml-4 -mt-4 mb-4 hidden h-6 w-6 scale-0 items-center justify-center rounded-md border p-1 transition-all group-hover:visible group-hover:scale-100 sm:ml-0 sm:flex lg:left-[12px]"
|
||||
className="bg-default text-muted hover:text-emphasis border-default hover:border-emphasis invisible absolute left-0 -ml-4 -mt-4 mb-4 hidden h-6 w-6 scale-0 items-center justify-center rounded-md border p-1 transition-all group-hover:visible group-hover:scale-100 sm:ml-0 sm:flex lg:left-3"
|
||||
onClick={props.onClick}>
|
||||
<ArrowUp className="h-5 w-5" />
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
className="bg-default text-muted border-default hover:text-emphasis hover:border-emphasis invisible absolute left-[5px] -ml-4 mt-8 hidden h-6 w-6 scale-0 items-center justify-center rounded-md border p-1 transition-all group-hover:visible group-hover:scale-100 sm:ml-0 sm:flex lg:left-[12px]"
|
||||
className="bg-default text-muted border-default hover:text-emphasis hover:border-emphasis invisible absolute left-0 -ml-4 mt-8 hidden h-6 w-6 scale-0 items-center justify-center rounded-md border p-1 transition-all group-hover:visible group-hover:scale-100 sm:ml-0 sm:flex lg:left-3"
|
||||
onClick={props.onClick}>
|
||||
<ArrowDown className="h-5 w-5" />
|
||||
</button>
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { classNames } from "@calcom/lib";
|
||||
|
||||
export function Label(props: JSX.IntrinsicElements["label"]) {
|
||||
const { className, ...restProps } = props;
|
||||
return (
|
||||
<label
|
||||
{...props}
|
||||
className={classNames("text-default text-emphasis mb-2 block text-sm font-medium", props.className)}>
|
||||
className={classNames("text-default text-emphasis mb-2 block text-sm font-medium", className)}
|
||||
{...restProps}>
|
||||
{props.children}
|
||||
</label>
|
||||
);
|
||||
|
||||
@@ -20,6 +20,7 @@ type Props = {
|
||||
toggleSwitchAtTheEnd?: boolean;
|
||||
childrenClassName?: string;
|
||||
switchContainerClassName?: string;
|
||||
labelClassName?: string;
|
||||
};
|
||||
|
||||
function SettingsToggle({
|
||||
@@ -35,6 +36,7 @@ function SettingsToggle({
|
||||
toggleSwitchAtTheEnd = false,
|
||||
childrenClassName,
|
||||
switchContainerClassName,
|
||||
labelClassName,
|
||||
...rest
|
||||
}: Props) {
|
||||
const [animateRef] = useAutoAnimate<HTMLDivElement>();
|
||||
@@ -47,7 +49,8 @@ function SettingsToggle({
|
||||
<div className={classNames("flex justify-between space-x-3", switchContainerClassName)}>
|
||||
<div>
|
||||
<div className="flex items-center">
|
||||
<Label className="text-emphasis text-base font-semibold leading-none">
|
||||
<Label
|
||||
className={classNames("mt-0.5 text-base font-semibold leading-none", labelClassName)}>
|
||||
{title}
|
||||
{LockedIcon}
|
||||
</Label>
|
||||
|
||||
Reference in new issue
Block a user