diff --git a/src/frontend/src/components/Avatar.tsx b/src/frontend/src/components/Avatar.tsx new file mode 100644 index 00000000..0b42105a --- /dev/null +++ b/src/frontend/src/components/Avatar.tsx @@ -0,0 +1,41 @@ +import { css } from '@/styled-system/css' +import React from 'react' + +export type AvatarProps = React.HTMLAttributes & { + name: string + size?: number + bgColor?: string + textColor?: string +} + +export const Avatar = ({ + name, + size = 32, + bgColor = '#3498db', + textColor = 'white', +}: AvatarProps) => { + const initial = name?.trim()?.charAt(0).toUpperCase() || '*' // fixme use a proper fallback + return ( +
+ {initial} +
+ ) +} diff --git a/src/frontend/src/features/rooms/livekit/components/controls/Participants/ParticipantsList.tsx b/src/frontend/src/features/rooms/livekit/components/controls/Participants/ParticipantsList.tsx index 6a04b768..541a02d5 100644 --- a/src/frontend/src/features/rooms/livekit/components/controls/Participants/ParticipantsList.tsx +++ b/src/frontend/src/features/rooms/livekit/components/controls/Participants/ParticipantsList.tsx @@ -1,5 +1,4 @@ import { css } from '@/styled-system/css' -import * as React from 'react' import { useParticipants } from '@livekit/components-react' import { Heading } from 'react-aria-components' @@ -11,32 +10,7 @@ import { capitalize } from '@/utils/capitalize' import { participantsStore } from '@/stores/participants' import { useTranslation } from 'react-i18next' import { allParticipantRoomEvents } from '@/features/rooms/livekit/constants/events' - -export type AvatarProps = React.HTMLAttributes & { - name: string - size?: number -} - -// TODO - extract inline styling in a centralized styling file, and avoid magic numbers -export const Avatar = ({ name, size = 32 }: AvatarProps) => ( -
- {name?.trim()?.charAt(0).toUpperCase()} -
-) +import { Avatar } from '@/components/Avatar' // TODO: Optimize rendering performance, especially for longer participant lists, even though they are generally short. export const ParticipantsList = () => {