Skip to content

Commit

Permalink
Merge pull request #11 from cloudmix-dev/feat/avatar-skeleton
Browse files Browse the repository at this point in the history
Avatar.Skeleton component
  • Loading branch information
samlaycock authored Dec 30, 2023
2 parents 9c59fd4 + 194723f commit cc0cefb
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/popular-pianos-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cloudmix-dev/react": patch
---

Add Skeleton for Avatar component
17 changes: 17 additions & 0 deletions packages/react/src/components/avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,21 @@ Avatar.Group = function AvatarGroup({ children, className }: AvatarGroupProps) {
// @ts-expect-error
Avatar.Group.displayName = "Avatar.Group";

export interface AvatarSkeletonProps
extends VariantProps<typeof avatarVariants> {
className?: string;
}

Avatar.Skeleton = function AvatarSkeleton({
className,
size,
}: AvatarSkeletonProps) {
return (
<div className={cn("animate-pulse", avatarVariants({ size, className }))} />
);
};

// @ts-expect-error
Avatar.Skeleton.displayName = "Avatar.Skeleton";

export { Avatar };
9 changes: 9 additions & 0 deletions www/storybook/src/stories/avatar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,12 @@ export const Group: AvatarGroupStory = {
</Avatar.Group>
),
};

type SkeletonStory = StoryObj<typeof Avatar.Skeleton>;

export const Skeleton: SkeletonStory = {
render: (props) => <Avatar.Skeleton {...props} />,
args: {
size: "default",
},
};

0 comments on commit cc0cefb

Please sign in to comment.