Skip to content
Closed
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
94 changes: 94 additions & 0 deletions apps/frontend/components/ui/avatar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
"use client";

import * as React from "react";
import * as AvatarPrimitive from "@radix-ui/react-avatar";
import { CodeComponentMeta } from "@plasmicapp/loader-nextjs";

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

type AvatarProps = React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>;

const Avatar = React.forwardRef<
React.ElementRef<typeof AvatarPrimitive.Root>,
AvatarProps
>(({ className, ...props }, ref) => (
<AvatarPrimitive.Root
ref={ref}
className={cn(
"relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
className,
)}
{...props}
/>
));
Avatar.displayName = AvatarPrimitive.Root.displayName;

const AvatarMeta: CodeComponentMeta<AvatarProps> = {
name: "Avatar",
description: "shadcn/ui Avatar component",
props: {
children: "slot",
},
};

type AvatarImageProps = React.ComponentPropsWithoutRef<
typeof AvatarPrimitive.Image
>;

const AvatarImage = React.forwardRef<
React.ElementRef<typeof AvatarPrimitive.Image>,
AvatarImageProps
>(({ className, ...props }, ref) => (
<AvatarPrimitive.Image
ref={ref}
className={cn("aspect-square h-full w-full", className)}
{...props}
/>
));
AvatarImage.displayName = AvatarPrimitive.Image.displayName;

const AvatarImageMeta: CodeComponentMeta<AvatarImageProps> = {
name: "AvatarImage",
description: "shadcn/ui AvatarImage component",
props: {
src: "string",
alt: "string",
},
};

type AvatarFallbackProps = React.ComponentPropsWithoutRef<
typeof AvatarPrimitive.Fallback
>;

const AvatarFallback = React.forwardRef<
React.ElementRef<typeof AvatarPrimitive.Fallback>,
AvatarFallbackProps
>(({ className, ...props }, ref) => (
<AvatarPrimitive.Fallback
ref={ref}
className={cn(
"flex h-full w-full items-center justify-center rounded-full bg-muted",
className,
)}
{...props}
/>
));
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;

const AvatarFallbackMeta: CodeComponentMeta<AvatarFallbackProps> = {
name: "AvatarFallback",
description: "shadcn/ui AvatarFallback component",
props: {
children: "slot",
},
};

export {
Avatar,
AvatarImage,
AvatarFallback,
// Meta
AvatarMeta,
AvatarImageMeta,
AvatarFallbackMeta,
};
12 changes: 12 additions & 0 deletions apps/frontend/components/ui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,21 @@ import {
CardDescriptionMeta,
CardContentMeta,
} from "@/components/ui/card";
import {
Avatar,
AvatarFallback,
AvatarFallbackMeta,
AvatarImage,
AvatarImageMeta,
AvatarMeta,
} from "@/components/ui/avatar";


export function registerAllUi(PLASMIC: NextJsPlasmicComponentLoader) {
// shadcn/ui
PLASMIC.registerComponent(Avatar, AvatarMeta);
PLASMIC.registerComponent(AvatarImage, AvatarImageMeta);
PLASMIC.registerComponent(AvatarFallback, AvatarFallbackMeta);
PLASMIC.registerComponent(Skeleton, SkeletonMeta);
PLASMIC.registerComponent(Button, ButtonMeta);
PLASMIC.registerComponent(Breadcrumb, BreadcrumbMeta);
Expand Down
1 change: 1 addition & 0 deletions apps/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"@opensource-observer/utils": "workspace:*",
"@plasmicapp/loader-nextjs": "^1.0.435",
"@posthog/nextjs-config": "^1.2.0",
"@radix-ui/react-avatar": "^1.1.10",
"@radix-ui/react-collapsible": "^1.1.12",
"@radix-ui/react-context-menu": "^2.2.16",
"@radix-ui/react-dialog": "^1.1.15",
Expand Down
Loading
Loading