Skip to content
Open
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
18 changes: 14 additions & 4 deletions packages/core/src/components/ListItemAvatar/ListItemAvatar.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, { forwardRef, useRef } from "react";
import cx from "classnames";
import useMergeRef from "../../hooks/useMergeRef";
import { VibeComponent, VibeComponentProps, withStaticProps } from "../../types";
import Avatar from "../Avatar/Avatar";
import { VibeComponent, withStaticProps } from "../../types";
import Avatar, { AvatarProps } from "../Avatar/Avatar";
import { ListItemComponentType } from "../ListItem/ListItemConstants";
import styles from "./ListItemAvatar.module.scss";

export interface ListItemAvatarProps extends VibeComponentProps {
export interface ListItemAvatarProps extends AvatarProps {
/**
* the ListItem component [li, div, a]
*/
Expand All @@ -16,7 +16,16 @@ export interface ListItemAvatarProps extends VibeComponentProps {
}

const ListItemAvatar: VibeComponent<ListItemAvatarProps> & { components?: typeof ListItemComponentType } = forwardRef(
({ className, id, src, avatarClassName, component: Component = ListItemAvatar.components.DIV }, ref) => {
(props, ref) => {
const {
className,
id,
src,
avatarClassName,
component: Component = ListItemAvatar.components.DIV,
...avatarProps
} = props;

const componentRef = useRef(null);
const mergedRef = useMergeRef(ref, componentRef);

Expand All @@ -27,6 +36,7 @@ const ListItemAvatar: VibeComponent<ListItemAvatarProps> & { components?: typeof
type={Avatar.types.IMG}
size={Avatar.sizes.SMALL}
className={cx(styles.avatar, avatarClassName)}
{...avatarProps}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should I omit className and id as they're applied to the Component?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are already omitted while spreading the props so no need

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you're absolutely right, my bad 🤦

/>
</Component>
);
Expand Down