Open source video conferencing app powered by LiveKit. Built with Django and React.
✨(frontend) add participant color gradient when camera is off
Cyril9b9e6578ee86
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex ac67ced1..8722bdad 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -11,6 +11,7 @@ and this project adheres to### Added- ✨(backend) allow searching the recording admin table by owner email+- ✨(frontend) add participant color gradient when camera is off #1490### Changeddiff --git a/src/frontend/src/features/rooms/livekit/components/ParticipantPlaceholder.tsx b/src/frontend/src/features/rooms/livekit/components/ParticipantPlaceholder.tsxindex 13947f58..8338aa9a 100644--- a/src/frontend/src/features/rooms/livekit/components/ParticipantPlaceholder.tsx+++ b/src/frontend/src/features/rooms/livekit/components/ParticipantPlaceholder.tsx@@ -2,6 +2,7 @@ import type { Participant } from 'livekit-client'import { styled } from '@/styled-system/jsx'import { Avatar } from '@/components/Avatar'import { useIsSpeaking } from '@livekit/components-react'+import { getParticipantBackgroundGradient } from '@/features/rooms/utils/getParticipantBackgroundGradient'import { getParticipantColor } from '@/features/rooms/utils/getParticipantColor'import { useSize } from '@/features/rooms/livekit/hooks/useResizeObserver'import { useMemo, useRef } from 'react'@@ -10,7 +11,6 @@ const StyledParticipantPlaceHolder = styled('div', {base: {width: '100%',height: '100%',- backgroundColor: 'primaryDark.100',display: 'flex',justifyContent: 'center',alignItems: 'center',@@ -26,6 +26,10 @@ export const ParticipantPlaceholder = ({}: ParticipantPlaceholderProps) => {const isSpeaking = useIsSpeaking(participant)const participantColor = getParticipantColor(participant)+ const backgroundGradient = useMemo(+ () => getParticipantBackgroundGradient(participantColor),+ [participantColor]+ )const placeholderEl = useRef<HTMLDivElement>(null)const { width, height } = useSize(placeholderEl)@@ -39,7 +43,13 @@ export const ParticipantPlaceholder = ({const initialSize = useMemo(() => Math.round(avatarSize * 0.3), [avatarSize])return (- <StyledParticipantPlaceHolder ref={placeholderEl}>+ <StyledParticipantPlaceHolder+ ref={placeholderEl}+ style={{+ backgroundColor: participantColor,+ backgroundImage: backgroundGradient,+ }}+ ><divstyle={{borderRadius: '50%',diff --git a/src/frontend/src/features/rooms/utils/getParticipantBackgroundGradient.ts b/src/frontend/src/features/rooms/utils/getParticipantBackgroundGradient.tsnew file mode 100644index 00000000..b2cfe7ef--- /dev/null+++ b/src/frontend/src/features/rooms/utils/getParticipantBackgroundGradient.ts@@ -0,0 +1,12 @@+/**+ * Builds a radial gradient from the participant's avatar color:+ * brighter in the center (where the avatar sits), darker at the edges.+ * Mixed in oklch so the color stays vivid as it darkens instead of greying out.+ */+export const getParticipantBackgroundGradient = (color: string): string =>+ `radial-gradient(circle at 50% 45%,+ color-mix(in oklch, ${color} 82%, white) 0%,+ color-mix(in oklch, ${color} 90%, white) 8%,+ ${color} 35%,+ color-mix(in oklch, ${color} 85%, black) 65%,+ color-mix(in oklch, ${color} 65%, black) 100%)`