From 7bceba5acb2d462c9388c525301ec954ed8103d6 Mon Sep 17 00:00:00 2001 From: Jeremy Kahn Date: Thu, 23 Nov 2023 12:26:07 -0600 Subject: [PATCH] feat(ui) [closes #160] Move transcript scrollbar to content window edge (#212) * feat(ui): [closes #160] move transcript scrollbar to edge of container * feat(ui): prevent controls from obscuring transcript * feat(ui): hide unnecessary hide controls button --- .../ChatTranscript/ChatTranscript.tsx | 23 ++++++++++++++----- src/components/Room/Room.tsx | 17 +++++++------- src/components/Shell/ShellAppBar.tsx | 8 +++++-- 3 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/components/ChatTranscript/ChatTranscript.tsx b/src/components/ChatTranscript/ChatTranscript.tsx index 10587b7..6b7327c 100644 --- a/src/components/ChatTranscript/ChatTranscript.tsx +++ b/src/components/ChatTranscript/ChatTranscript.tsx @@ -1,9 +1,11 @@ -import { HTMLAttributes, useRef, useEffect, useState } from 'react' +import { HTMLAttributes, useRef, useEffect, useState, useContext } from 'react' import cx from 'classnames' import Box from '@mui/material/Box' +import useTheme from '@mui/material/styles/useTheme' import { Message as IMessage, InlineMedia } from 'models/chat' import { Message } from 'components/Message' +import { ShellContext } from 'contexts/ShellContext' export interface ChatTranscriptProps extends HTMLAttributes { messageLog: Array @@ -15,6 +17,8 @@ export const ChatTranscript = ({ messageLog, userId, }: ChatTranscriptProps) => { + const { showRoomControls } = useContext(ShellContext) + const theme = useTheme() const boxRef = useRef(null) const [previousMessageLogLength, setPreviousMessageLogLength] = useState(0) @@ -53,18 +57,25 @@ export const ChatTranscript = ({ setPreviousMessageLogLength(messageLog.length) }, [messageLog.length]) + const transcriptMaxWidth = theme.breakpoints.values.md + const transcriptPaddingX = `(50% - ${ + transcriptMaxWidth / 2 + }px) - ${theme.spacing(1)}` + const transcriptMinPadding = theme.spacing(1) + return ( ({ + sx={{ display: 'flex', flexDirection: 'column', - mx: 'auto', - paddingY: theme.spacing(1), + py: transcriptMinPadding, + pt: showRoomControls ? theme.spacing(10) : theme.spacing(2), + px: `max(${transcriptPaddingX}, ${transcriptMinPadding})`, + transition: `padding-top ${theme.transitions.duration.short}ms ${theme.transitions.easing.easeInOut}`, width: '100%', - maxWidth: theme.breakpoints.values.md, - })} + }} > {messageLog.map((message, idx) => { const previousMessage = messageLog[idx - 1] diff --git a/src/components/Room/Room.tsx b/src/components/Room/Room.tsx index 0d385fc..23a6986 100644 --- a/src/components/Room/Room.tsx +++ b/src/components/Room/Room.tsx @@ -1,9 +1,9 @@ import { useContext } from 'react' import { useWindowSize } from '@react-hook/window-size' -import Collapse from '@mui/material/Collapse' import Zoom from '@mui/material/Zoom' import Box from '@mui/material/Box' import Divider from '@mui/material/Divider' +import useTheme from '@mui/material/styles/useTheme' import { v4 as uuid } from 'uuid' import { rtcConfig } from 'config/rtcConfig' @@ -22,7 +22,6 @@ import { RoomScreenShareControls } from './RoomScreenShareControls' import { RoomFileUploadControls } from './RoomFileUploadControls' import { RoomVideoDisplay } from './RoomVideoDisplay' import { RoomShowMessagesControls } from './RoomShowMessagesControls' -import { RoomHideRoomControls } from './RoomHideRoomControls' import { TypingStatusBar } from './TypingStatusBar' export interface RoomProps { @@ -40,6 +39,7 @@ export function Room({ password, userId, }: RoomProps) { + const theme = useTheme() const settingsContext = useContext(SettingsContext) const { showActiveTypingStatus } = settingsContext.getUserSettings() const { @@ -96,14 +96,16 @@ export function Room({ overflow: 'auto', }} > - + @@ -118,9 +120,8 @@ export function Room({ - - + diff --git a/src/components/Shell/ShellAppBar.tsx b/src/components/Shell/ShellAppBar.tsx index 2c3f8f1..f0b74b2 100644 --- a/src/components/Shell/ShellAppBar.tsx +++ b/src/components/Shell/ShellAppBar.tsx @@ -85,7 +85,7 @@ export const ShellAppBar = ({ isFullscreen, setIsFullscreen, }: ShellAppBarProps) => { - const { peerList, isEmbedded } = useContext(ShellContext) + const { peerList, isEmbedded, showRoomControls } = useContext(ShellContext) const handleQRCodeClick = () => setIsQRCodeDialogOpen(true) const onClickFullscreen = () => setIsFullscreen(!isFullscreen) @@ -149,7 +149,11 @@ export const ShellAppBar = ({ )} - +