Feature/booking filters (#6099)
* EventTypeFilter UI working * Tidy + fix avatar + fix overflow * Component store * WIP - switchin to query filtering instead of state * Push working * Checkbox approach - weird conditional toggle for all bookings * WIP * the master query hook :O * useTypedQuery * Working typed query * Typed query hook * Add optional keys * safeParse query params * Add use callback * Fix re-renders * Remove local version of local query and use util branch * Working team filters! * working people filter! * Tidy up * NIT Co-authored-by: zomars <[email protected]>
This commit is contained in:
1 parent
83b60de640
commit
cefcb1eaf8
20 files changed
+556
-51
No files matched your search
@@ -9,48 +9,56 @@ import { Maybe } from "@trpc/server";
|
||||
|
||||
export type AvatarProps = {
|
||||
className?: string;
|
||||
size: "sm" | "md" | "mdLg" | "lg";
|
||||
size: "xs" | "sm" | "md" | "mdLg" | "lg";
|
||||
imageSrc?: Maybe<string>;
|
||||
title?: string;
|
||||
alt: string;
|
||||
gravatarFallbackMd5?: string;
|
||||
fallback?: React.ReactNode;
|
||||
accepted?: boolean;
|
||||
asChild?: boolean; // Added to ignore the outer span on the fallback component - messes up styling
|
||||
};
|
||||
|
||||
const sizesPropsBySize = {
|
||||
sm: "w-6", // 24px
|
||||
md: "w-8", // 32px
|
||||
mdLg: "w-10", //40px
|
||||
lg: "w-16", // 64px
|
||||
xs: "w-4 h-4", // 16px
|
||||
sm: "w-6 h-6", // 24px
|
||||
md: "w-8 h-8", // 32px
|
||||
mdLg: "w-10 h-10", //40px
|
||||
lg: "w-16 h-16", // 64px
|
||||
} as const;
|
||||
|
||||
export function Avatar(props: AvatarProps) {
|
||||
const { imageSrc, gravatarFallbackMd5, size, alt, title } = props;
|
||||
const sizeClassname = sizesPropsBySize[size];
|
||||
const rootClass = classNames("rounded-full aspect-square", sizeClassname, "h-auto");
|
||||
const rootClass = classNames("rounded-full aspect-square ", sizeClassname);
|
||||
const avatar = (
|
||||
<AvatarPrimitive.Root
|
||||
className={classNames(
|
||||
sizeClassname,
|
||||
"dark:bg-darkgray-300 relative inline-block aspect-square overflow-hidden rounded-full"
|
||||
"dark:bg-darkgray-300 item-center relative inline-flex aspect-square justify-center overflow-hidden rounded-full"
|
||||
)}>
|
||||
<AvatarPrimitive.Image src={imageSrc ?? undefined} alt={alt} className={rootClass} />
|
||||
<AvatarPrimitive.Fallback delayMs={600}>
|
||||
{gravatarFallbackMd5 && (
|
||||
<img src={defaultAvatarSrc({ md5: gravatarFallbackMd5 })} alt={alt} className={rootClass} />
|
||||
)}
|
||||
</AvatarPrimitive.Fallback>
|
||||
{props.accepted && (
|
||||
<div
|
||||
className={classNames(
|
||||
"absolute bottom-0 right-0 block rounded-full bg-green-400 text-white ring-2 ring-white",
|
||||
size === "lg" ? "h-5 w-5" : "h-2 w-2"
|
||||
)}>
|
||||
<div className="flex h-full items-center justify-center p-[2px]">
|
||||
{size === "lg" && <Icon.FiCheck className="" />}
|
||||
<>
|
||||
<AvatarPrimitive.Image src={imageSrc ?? undefined} alt={alt} className={rootClass} />
|
||||
<AvatarPrimitive.Fallback delayMs={600} asChild={props.asChild}>
|
||||
<>
|
||||
{props.fallback && !gravatarFallbackMd5 && props.fallback}
|
||||
{gravatarFallbackMd5 && (
|
||||
<img src={defaultAvatarSrc({ md5: gravatarFallbackMd5 })} alt={alt} className={rootClass} />
|
||||
)}
|
||||
</>
|
||||
</AvatarPrimitive.Fallback>
|
||||
{props.accepted && (
|
||||
<div
|
||||
className={classNames(
|
||||
"absolute bottom-0 right-0 block rounded-full bg-green-400 text-white ring-2 ring-white",
|
||||
size === "lg" ? "h-5 w-5" : "h-2 w-2"
|
||||
)}>
|
||||
<div className="flex h-full items-center justify-center p-[2px]">
|
||||
{size === "lg" && <Icon.FiCheck />}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
)}
|
||||
</>
|
||||
</AvatarPrimitive.Root>
|
||||
);
|
||||
|
||||
|
||||
Reference in new issue
Block a user