Skip to content
Open
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
5 changes: 5 additions & 0 deletions .changeset/cruel-owls-arrive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/fuselage': minor
---

feat(fuselage): accept all `objectFit` css properties on `Avatar` component
20 changes: 19 additions & 1 deletion packages/fuselage/src/components/Avatar/Avatar.styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,25 @@ $sizes: 16, 18, 20, 24, 28, 32, 36, 40, 48, 124, 200, 332;
}

&--object-fit {
object-fit: contain;
&--contain {
object-fit: contain;
}

&--cover {
object-fit: cover;
}

&--fill {
object-fit: fill;
}

&--none {
object-fit: none;
}

&--scale-down {
object-fit: scale-down;
}
}

&--rounded {
Expand Down
8 changes: 4 additions & 4 deletions packages/fuselage/src/components/Avatar/Avatar.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import type { AllHTMLAttributes } from 'react';
import type { AllHTMLAttributes, CSSProperties } from 'react';

import AvatarContainer, { type AvatarContainerProps } from './AvatarContainer';

export type AvatarProps = AvatarContainerProps & {
rounded?: boolean;
objectFit?: boolean;
objectFit?: CSSProperties['objectFit'];
url: string;
} & Omit<AllHTMLAttributes<HTMLImageElement>, 'size'>;

const Avatar = ({
size = 'x36',
rounded = false,
objectFit = false,
objectFit,
url,
className,
alt,
...props
}: AvatarProps) => {
const innerClass = [
'rcx-avatar__element',
objectFit && 'rcx-avatar__element--object-fit',
size && `rcx-avatar__element--${size}`,
rounded && 'rcx-avatar__element--rounded',
objectFit && `rcx-avatar__element--object-fit--${objectFit}`,
]
.filter(Boolean)
.join(' ');
Expand Down
Loading