🚸(frontend) enhance side panel UX

Implement smooth animations and DOM persistence for sidepanel.
Side panel state should be kept alive, to match initial LiveKit team
intent.

Temporarily, remove chat component. Chat functionality will be absent
until next commits. It will be reintegrated in the side panel.
This commit is contained in:
lebaudantoine
2024-10-13 21:39:07 +02:00
committed by aleb_the_flash
parent 54d4330a97
commit 2a12715673
4 changed files with 79 additions and 38 deletions

View File

@@ -15,6 +15,7 @@ type StyledSidePanelProps = {
title: string
children: ReactNode
onClose: () => void
isClosed: boolean
closeButtonTooltip: string
}
@@ -22,11 +23,11 @@ const StyledSidePanel = ({
title,
children,
onClose,
isClosed,
closeButtonTooltip,
}: StyledSidePanelProps) => (
<Box
size="sm"
minWidth="360px"
className={css({
overflow: 'hidden',
display: 'flex',
@@ -34,7 +35,16 @@ const StyledSidePanel = ({
margin: '1.5rem 1.5rem 1.5rem 0',
padding: 0,
gap: 0,
right: 0,
top: 0,
bottom: '80px',
width: '360px',
position: 'absolute',
transition: '.5s cubic-bezier(.4,0,.2,1) 5ms',
})}
style={{
transform: isClosed ? 'translateX(calc(360px + 1.5rem))' : 'none',
}}
>
<Heading
slot="title"
@@ -43,11 +53,19 @@ const StyledSidePanel = ({
style={{
paddingLeft: '1.5rem',
paddingTop: '1rem',
display: isClosed ? 'none' : undefined,
}}
>
{title}
</Heading>
<Div position="absolute" top="5" right="5">
<Div
position="absolute"
top="5"
right="5"
style={{
display: isClosed ? 'none' : undefined,
}}
>
<Button
invisible
size="xs"
@@ -62,6 +80,17 @@ const StyledSidePanel = ({
</Box>
)
type PanelProps = {
isOpen: boolean;
children: React.ReactNode;
};
const Panel = ({ isOpen, children }: PanelProps) => (
<div style={{ display: isOpen ? 'block' : 'none' }}>
{children}
</div>
)
export const SidePanel = () => {
const layoutSnap = useSnapshot(layoutStore)
const sidePanel = layoutSnap.sidePanel
@@ -69,10 +98,6 @@ export const SidePanel = () => {
const { isParticipantsOpen, isEffectsOpen } = useWidgetInteraction()
const { t } = useTranslation('rooms', { keyPrefix: 'sidePanel' })
if (!sidePanel) {
return
}
return (
<StyledSidePanel
title={t(`heading.${sidePanel}`)}
@@ -80,9 +105,18 @@ export const SidePanel = () => {
closeButtonTooltip={t('closeButton', {
content: t(`content.${sidePanel}`),
})}
isClosed={!sidePanel}
>
{isParticipantsOpen && <ParticipantsList />}
{isEffectsOpen && <Effects />}
<Panel
isOpen={isParticipantsOpen}
>
<ParticipantsList />
</Panel>
<Panel
isOpen={isEffectsOpen}
>
<Effects />
</Panel>
</StyledSidePanel>
)
}