Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
💄 Add bordered variant to Avatar and hide border when SpaceIcon has image
Luke Vellacffbed8c91f2
diff --git a/apps/web/src/features/space/components/space-icon.tsx b/apps/web/src/features/space/components/space-icon.tsxindex 6c3345214..e5d889e41 100644--- a/apps/web/src/features/space/components/space-icon.tsx+++ b/apps/web/src/features/space/components/space-icon.tsx@@ -4,6 +4,7 @@ import { cn } from "@rallly/ui";import { Avatar, AvatarFallback } from "@rallly/ui/avatar";import Image from "next/image";import * as React from "react";+import { resolveStorageUrl } from "@/utils/storage";type SpaceIconProps = {name: string;@@ -20,16 +21,18 @@ export function SpaceIcon({}: SpaceIconProps) {const [erroredSrc, setErroredSrc] = React.useState<string | null>(null);const hasError = src !== undefined && erroredSrc === src;+ const hasImage = Boolean(src) && !hasError;return (<AvatarclassName={cn("overflow-hidden", className)}size={size}shape="square"+ bordered={!hasImage}>{src && !hasError ? (<Image- src={`/api/storage/${src}`}+ src={resolveStorageUrl(src)}width={128}height={128}alt={name}diff --git a/packages/ui/src/avatar.tsx b/packages/ui/src/avatar.tsxindex 26934d06c..ac54daaff 100644--- a/packages/ui/src/avatar.tsx+++ b/packages/ui/src/avatar.tsx@@ -7,38 +7,41 @@ import type * as React from "react";import { cn } from "./lib/utils";-const avatarVariants = cva(- "group/avatar relative flex shrink-0 select-none after:absolute after:inset-0 after:rounded-[inherit] after:border after:border-border after:mix-blend-darken dark:after:mix-blend-lighten",- {- variants: {- size: {- sm: "size-6",- default: "size-8",- lg: "size-10",- xl: "size-12",- },- shape: {- circle: "rounded-full",- square: "",- },+const avatarVariants = cva("group/avatar relative flex shrink-0 select-none", {+ variants: {+ size: {+ sm: "size-6",+ default: "size-8",+ lg: "size-10",+ xl: "size-12",},- compoundVariants: [- { shape: "square", size: "sm", className: "rounded-md" },- { shape: "square", size: "default", className: "rounded-md" },- { shape: "square", size: "lg", className: "rounded-lg" },- { shape: "square", size: "xl", className: "rounded-lg" },- ],- defaultVariants: {- size: "default",- shape: "circle",+ shape: {+ circle: "rounded-full",+ square: "",},+ bordered: {+ true: "after:absolute after:inset-0 after:rounded-[inherit] after:border after:border-border after:mix-blend-darken dark:after:mix-blend-lighten",+ false: "",+ },+ },+ compoundVariants: [+ { shape: "square", size: "sm", className: "rounded-md" },+ { shape: "square", size: "default", className: "rounded-md" },+ { shape: "square", size: "lg", className: "rounded-lg" },+ { shape: "square", size: "xl", className: "rounded-lg" },+ ],+ defaultVariants: {+ size: "default",+ shape: "circle",+ bordered: true,},-);+});function Avatar({className,size = "default",shape = "circle",+ bordered = true,...props}: AvatarPrimitive.Root.Props & VariantProps<typeof avatarVariants>) {return (@@ -46,7 +49,7 @@ function Avatar({data-slot="avatar"data-size={size}data-shape={shape}- className={cn(avatarVariants({ size, shape }), className)}+ className={cn(avatarVariants({ size, shape, bordered }), className)}{...props}/>);@@ -73,7 +76,7 @@ function AvatarFallback({<AvatarPrimitive.Fallbackdata-slot="avatar-fallback"className={cn(- "flex size-full items-center justify-center rounded-[inherit] bg-muted text-muted-foreground text-xs group-data-[size=sm]/avatar:text-[0.625rem]",+ "flex size-full items-center justify-center rounded-[inherit] bg-muted text-muted-foreground text-xs group-data-[size=lg]/avatar:text-sm group-data-[size=sm]/avatar:text-[0.625rem] group-data-[size=xl]/avatar:text-base",className,)}{...props}