diff --git a/packages/fuselage/src/components/Avatar/Avatar.spec.tsx b/packages/fuselage/src/components/Avatar/Avatar.spec.tsx
index 7db3d41065..f531679254 100644
--- a/packages/fuselage/src/components/Avatar/Avatar.spec.tsx
+++ b/packages/fuselage/src/components/Avatar/Avatar.spec.tsx
@@ -1,5 +1,5 @@
import { composeStories } from '@storybook/testing-react';
-import { render } from '@testing-library/react';
+import { render, screen } from '@testing-library/react';
import React from 'react';
import * as stories from './Avatar.stories';
@@ -10,4 +10,10 @@ describe('[Avatar Component]', () => {
it('renders without crashing', () => {
render();
});
+
+ it('should render emoji avatar', () => {
+ render();
+
+ expect(screen.getAllByText('😄').length).toBeGreaterThanOrEqual(1);
+ });
});
diff --git a/packages/fuselage/src/components/Avatar/Avatar.stories.tsx b/packages/fuselage/src/components/Avatar/Avatar.stories.tsx
index 4bd9622e52..f44afe8744 100644
--- a/packages/fuselage/src/components/Avatar/Avatar.stories.tsx
+++ b/packages/fuselage/src/components/Avatar/Avatar.stories.tsx
@@ -23,11 +23,19 @@ const sizes: (
| 'x332'
)[] = ['x16', 'x18', 'x28', 'x32', 'x36', 'x48', 'x124', 'x200', 'x332'];
+const wrapChildren = (children: React.ReactNode, size: number) =>
+ children ?
{children}
: null;
+
const Template: ComponentStory = (args) => (
{sizes.map((size, i) => (
-
+
))}
@@ -47,14 +55,35 @@ Rounded.args = {
rounded: true,
};
+export const Emoji = Template.bind({});
+Emoji.args = {
+ children: '😀',
+ rounded: true,
+};
+
const StackTemplate: ComponentStory = (args) => (
{sizes.map((size, i) => (
-
-
-
+
+
+
))}
@@ -71,3 +100,10 @@ StackRounded.args = {
url: imgUrl,
rounded: true,
};
+
+export const StackWithEmoji = StackTemplate.bind({});
+StackWithEmoji.args = {
+ children: '😀',
+
+ rounded: true,
+};
diff --git a/packages/fuselage/src/components/Avatar/Avatar.tsx b/packages/fuselage/src/components/Avatar/Avatar.tsx
index 111262e6e2..3fc565e03c 100644
--- a/packages/fuselage/src/components/Avatar/Avatar.tsx
+++ b/packages/fuselage/src/components/Avatar/Avatar.tsx
@@ -1,4 +1,4 @@
-import type { DetailedHTMLProps, HTMLAttributes } from 'react';
+import type { DetailedHTMLProps, HTMLAttributes, ReactNode } from 'react';
import React from 'react';
import flattenChildren from 'react-keyed-flatten-children';
@@ -21,6 +21,9 @@ export type AvatarProps = {
rounded?: boolean;
objectFit?: boolean;
url: string;
+ children?: ReactNode;
+ image?: string;
+ emojiClassname?: string;
} & HTMLAttributes;
export const Avatar = ({
@@ -29,6 +32,9 @@ export const Avatar = ({
rounded = false,
objectFit = false,
url,
+ children,
+ image,
+ emojiClassname,
...props
}: AvatarProps) => {
props.className = prependClassName(
@@ -37,18 +43,30 @@ export const Avatar = ({
.filter(Boolean)
.join(' ')
);
- const innerClass = [
- 'rcx-avatar__element',
- objectFit && 'rcx-avatar__element--object-fit',
- size && `rcx-avatar__element--${size}`,
- rounded && 'rcx-avatar__element--rounded',
- ]
- .filter(Boolean)
- .join(' ');
+ const innerClass = prependClassName(
+ emojiClassname,
+ [
+ 'rcx-avatar__element',
+ objectFit && 'rcx-avatar__element--object-fit',
+ size && `rcx-avatar__element--${size}`,
+ rounded && 'rcx-avatar__element--rounded',
+ ]
+ .filter(Boolean)
+ .join(' ')
+ );
return (
);
};