Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/components/Contributors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const Contributors = () => {
<Flex className="flex-wrap">
{contributorsList.map((contributor) => (
<LinkBox
as="div"
className="m-2 max-w-[132px] transform shadow transition-transform duration-100 hover:scale-[1.02] hover:rounded hover:bg-background-highlight focus:scale-[1.02] focus:rounded"
key={contributor.login}
>
Expand Down
35 changes: 16 additions & 19 deletions src/components/ui/avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,25 +151,22 @@ const Avatar = React.forwardRef<

const _ref = ref as React.ForwardedRef<HTMLDivElement>
return (
<LinkBox
// !! Inconsistent strategy, using `as` prop instead of `asChild` bool
as={Center}
ref={_ref}
className={cn(_direction, "gap-x-1 gap-y-0")}
>
<LinkOverlay
asChild
className={cn(
"peer z-overlay inline-flex items-center gap-1 p-1",
size !== "md" ? "text-xs" : "text-sm"
)}
>
<BaseLink {...commonLinkProps}>{label}</BaseLink>
</LinkOverlay>
<AvatarBase size={size}>
<AvatarImage src={src} />
<AvatarFallback>{fallbackInitials}</AvatarFallback>
</AvatarBase>
<LinkBox ref={_ref} className={cn(_direction, "gap-x-1 gap-y-0")} asChild>
<Center>
<LinkOverlay
asChild
className={cn(
"peer z-overlay inline-flex items-center gap-1 p-1",
size !== "md" ? "text-xs" : "text-sm"
)}
>
<BaseLink {...commonLinkProps}>{label}</BaseLink>
</LinkOverlay>
<AvatarBase size={size}>
<AvatarImage src={src} />
<AvatarFallback>{fallbackInitials}</AvatarFallback>
</AvatarBase>
</Center>
</LinkBox>
)
}
Expand Down
12 changes: 4 additions & 8 deletions src/components/ui/link-box.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import {
type BaseHTMLAttributes,
type ElementRef,
type ElementType,
forwardRef,
} from "react"
import { type BaseHTMLAttributes, type ElementRef, forwardRef } from "react"
import { Slot } from "@radix-ui/react-slot"

import { cn } from "@/lib/utils/cn"

type LinkBoxElement = ElementRef<"div">

type LinkBoxProps = BaseHTMLAttributes<HTMLDivElement> & { as?: ElementType }
type LinkBoxProps = BaseHTMLAttributes<HTMLDivElement> & { asChild?: boolean }

const LinkBox = forwardRef<LinkBoxElement, LinkBoxProps>(
({ as: Comp = "div", className, ...props }, ref) => {
({ asChild, className, ...props }, ref) => {
const Comp = asChild ? Slot : "div"
return (
<Comp ref={ref} className={cn("relative z-10", className)} {...props} />
)
Expand Down