Skip to content

Commit

Permalink
feat: add avatar
Browse files Browse the repository at this point in the history
  • Loading branch information
nahoc committed Apr 3, 2024
1 parent 7a2fcdc commit a86c2c2
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

bun run typecheck
bun run check
bun run bump:version
git add package.json
40 changes: 40 additions & 0 deletions avatar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"use client";

import * as AvatarPrimitive from "@radix-ui/react-avatar";
import { type ComponentPropsWithoutRef, type ElementRef, forwardRef } from "react";
import cn from "./cn";

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

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

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

Avatar.displayName = AvatarPrimitive.Root.displayName;
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
AvatarImage.displayName = AvatarPrimitive.Image.displayName;

export { Avatar, AvatarImage, AvatarFallback };
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
{
"name": "@risc0/ui",
"version": "0.0.29",
"version": "0.0.30",
"sideEffects": false,
"type": "module",
"scripts": {
"bump:version": "bunx changelogen --bump --no-output",
"check": "bunx @biomejs/biome check . --apply-unsafe",
"check": "tsc && bunx @biomejs/biome check . --apply-unsafe",
"prepare": "npx husky",
"sort-package": "bunx sort-package-json 'package.json'",
"test": "bun test spec",
"typecheck": "tsc",
"update-deps": "bunx npm-check-updates --root --format group -i"
"test": "bun test spec"
},
"dependencies": {
"@radix-ui/react-avatar": "1.0.4",
"@radix-ui/react-checkbox": "1.0.4",
"@radix-ui/react-dialog": "1.0.5",
"@radix-ui/react-dropdown-menu": "2.0.6",
Expand All @@ -34,7 +33,7 @@
"cmdk": "1.0.0",
"geist": "1.3.0",
"lodash-es": "4.17.21",
"lucide-react": "0.363.0",
"lucide-react": "0.364.0",
"next-themes": "0.3.0",
"nprogress": "0.2.0",
"react-hook-form": "7.51.2",
Expand Down

0 comments on commit a86c2c2

Please sign in to comment.