Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): Fix Avatar styling #9645

Merged
merged 1 commit into from
Oct 17, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,55 @@ export const WithImage: Story = {
args: {
src: "https://avatars.githubusercontent.com/u/10656202?v=4",
fallback: "J",
size: "base",
},
}

export const WithFallback: Story = {
args: {
fallback: "J",
size: "large",
},
}

export const TwoXSmall: Story = {
args: {
fallback: "J",
size: "2xsmall",
},
}

export const XSmall: Story = {
args: {
fallback: "J",
size: "xsmall",
},
}

export const Small: Story = {
args: {
fallback: "J",
size: "small",
},
}

export const Base: Story = {
args: {
fallback: "J",
size: "base",
},
}

export const Large: Story = {
args: {
fallback: "J",
size: "large",
},
}

export const XLarge: Story = {
args: {
fallback: "J",
size: "xlarge",
},
}
27 changes: 13 additions & 14 deletions packages/design-system/ui/src/components/avatar/avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as React from "react"
import { clx } from "@/utils/clx"

const avatarVariants = cva({
base: "border-ui-border-strong flex shrink-0 items-center justify-center overflow-hidden border",
base: "flex shrink-0 items-center justify-center overflow-hidden shadow-borders-base bg-ui-bg-base",
variants: {
variant: {
squared: "",
Expand All @@ -26,7 +26,7 @@ const avatarVariants = cva({
{
variant: "squared",
size: "2xsmall",
className: "rounded-md",
className: "rounded",
},
{
variant: "squared",
Expand Down Expand Up @@ -68,12 +68,12 @@ const innerVariants = cva({
rounded: "rounded-full",
},
size: {
"2xsmall": "txt-compact-xsmall-plus h-4 w-4",
xsmall: "txt-compact-xsmall-plus h-5 w-5",
small: "txt-compact-small-plus h-6 w-6",
base: "txt-compact-small-plus h-7 w-7",
large: "txt-compact-medium-plus h-9 w-9",
xlarge: "txt-compact-large-plus h-11 w-11",
"2xsmall": "txt-compact-xsmall-plus size-4",
xsmall: "txt-compact-xsmall-plus size-5",
small: "txt-compact-small-plus size-6",
base: "txt-compact-small-plus size-7",
large: "txt-compact-medium-plus size-9",
xlarge: "txt-compact-large-plus size-11",
},
},
compoundVariants: [
Expand All @@ -85,17 +85,17 @@ const innerVariants = cva({
{
variant: "squared",
size: "xsmall",
className: "rounded-sm",
className: "rounded",
},
{
variant: "squared",
size: "small",
className: "rounded-[4px]",
className: "rounded",
},
{
variant: "squared",
size: "base",
className: "rounded-[4px]",
className: "rounded",
},
{
variant: "squared",
Expand Down Expand Up @@ -158,8 +158,7 @@ const Avatar = React.forwardRef<
<Primitives.Root
ref={ref}
{...props}
className={clx(
"rounded-x",
className={clx(
avatarVariants({ variant, size }),
className
)}
Expand All @@ -173,7 +172,7 @@ const Avatar = React.forwardRef<
<Primitives.Fallback
className={clx(
innerVariants({ variant, size }),
"bg-ui-bg-component text-ui-fg-subtle pointer-events-none flex select-none items-center justify-center"
"bg-ui-bg-component-hover text-ui-fg-subtle pointer-events-none flex select-none items-center justify-center"
)}
>
{fallback}
Expand Down
Loading