Merge branch 'main' into 11321-limit-future-bookings

pull/11686/head
Khushal Majoka 2023-10-13 16:47:53 +05:30 committed by GitHub
commit 066fa0352f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 5 deletions

View File

@ -268,9 +268,11 @@ function EventTypeSingleLayout({
</Skeleton> </Skeleton>
)} )}
<Tooltip <Tooltip
sideOffset={4}
content={ content={
formMethods.watch("hidden") ? t("show_eventtype_on_profile") : t("hide_from_profile") formMethods.watch("hidden") ? t("show_eventtype_on_profile") : t("hide_from_profile")
}> }
side="bottom">
<div className="self-center rounded-md p-2"> <div className="self-center rounded-md p-2">
<Switch <Switch
id="hiddenSwitch" id="hiddenSwitch"
@ -291,7 +293,7 @@ function EventTypeSingleLayout({
{!isManagedEventType && ( {!isManagedEventType && (
<> <>
{/* We have to warp this in tooltip as it has a href which disabels the tooltip on buttons */} {/* We have to warp this in tooltip as it has a href which disabels the tooltip on buttons */}
<Tooltip content={t("preview")}> <Tooltip content={t("preview")} side="bottom" sideOffset={4}>
<Button <Button
color="secondary" color="secondary"
data-testid="preview-button" data-testid="preview-button"
@ -308,6 +310,8 @@ function EventTypeSingleLayout({
variant="icon" variant="icon"
StartIcon={LinkIcon} StartIcon={LinkIcon}
tooltip={t("copy_link")} tooltip={t("copy_link")}
tooltipSide="bottom"
tooltipOffset={4}
onClick={() => { onClick={() => {
navigator.clipboard.writeText(permalink); navigator.clipboard.writeText(permalink);
showToast("Link copied!", "success"); showToast("Link copied!", "success");
@ -319,6 +323,8 @@ function EventTypeSingleLayout({
color="secondary" color="secondary"
variant="icon" variant="icon"
tooltip={t("embed")} tooltip={t("embed")}
tooltipSide="bottom"
tooltipOffset={4}
eventId={eventType.id} eventId={eventType.id}
/> />
</> </>
@ -329,6 +335,8 @@ function EventTypeSingleLayout({
variant="icon" variant="icon"
StartIcon={Trash} StartIcon={Trash}
tooltip={t("delete")} tooltip={t("delete")}
tooltipSide="bottom"
tooltipOffset={4}
disabled={!hasPermsToDelete} disabled={!hasPermsToDelete}
onClick={() => setDeleteDialogOpen(true)} onClick={() => setDeleteDialogOpen(true)}
/> />

View File

@ -23,6 +23,8 @@ export type ButtonBaseProps = {
shallow?: boolean; shallow?: boolean;
/**Tool tip used when icon size is set to small */ /**Tool tip used when icon size is set to small */
tooltip?: string; tooltip?: string;
tooltipSide?: "top" | "right" | "bottom" | "left";
tooltipOffset?: number;
disabled?: boolean; disabled?: boolean;
flex?: boolean; flex?: boolean;
} & Omit<InferredVariantProps, "color"> & { } & Omit<InferredVariantProps, "color"> & {
@ -123,6 +125,8 @@ export const Button = forwardRef<HTMLAnchorElement | HTMLButtonElement, ButtonPr
size, size,
variant = "button", variant = "button",
type = "button", type = "button",
tooltipSide = "top",
tooltipOffset = 4,
StartIcon, StartIcon,
EndIcon, EndIcon,
shallow, shallow,
@ -213,19 +217,33 @@ export const Button = forwardRef<HTMLAnchorElement | HTMLButtonElement, ButtonPr
{element} {element}
</Link> </Link>
) : ( ) : (
<Wrapper data-testid="wrapper" tooltip={props.tooltip}> <Wrapper
data-testid="wrapper"
tooltip={props.tooltip}
tooltipSide={tooltipSide}
tooltipOffset={tooltipOffset}>
{element} {element}
</Wrapper> </Wrapper>
); );
}); });
const Wrapper = ({ children, tooltip }: { tooltip?: string; children: React.ReactNode }) => { const Wrapper = ({
children,
tooltip,
tooltipSide,
tooltipOffset,
}: {
tooltip?: string;
children: React.ReactNode;
tooltipSide?: "top" | "right" | "bottom" | "left";
tooltipOffset?: number;
}) => {
if (!tooltip) { if (!tooltip) {
return <>{children}</>; return <>{children}</>;
} }
return ( return (
<Tooltip data-testid="tooltip" content={tooltip}> <Tooltip data-testid="tooltip" content={tooltip} side={tooltipSide} sideOffset={tooltipOffset}>
{children} {children}
</Tooltip> </Tooltip>
); );