♻️(frontend) refactor Chat toggle
This commit refactor the default chat toggle to enhance few details: - styling (e.g. button's size, icon's style, etc) - accessibility (e.g. tooltip, aria label, keyboard controls) - notifications (enhanced contrast on the red dot, feedback from Arnaud)
This commit is contained in:
committed by
aleb_the_flash
parent
16321b3cb0
commit
47e2d85471
@@ -0,0 +1,50 @@
|
|||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { RiChat1Line } from '@remixicon/react'
|
||||||
|
import { Button } from '@/primitives'
|
||||||
|
import { css } from '@/styled-system/css'
|
||||||
|
import { useLayoutContext } from '@livekit/components-react'
|
||||||
|
|
||||||
|
export const ChatToggle = () => {
|
||||||
|
const { t } = useTranslation('rooms')
|
||||||
|
|
||||||
|
const { dispatch, state } = useLayoutContext().widget
|
||||||
|
const tooltipLabel = state?.showChat ? 'open' : 'closed'
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={css({
|
||||||
|
position: 'relative',
|
||||||
|
display: 'inline-block',
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
toggle
|
||||||
|
square
|
||||||
|
legacyStyle
|
||||||
|
aria-label={t(`controls.chat.${tooltipLabel}`)}
|
||||||
|
tooltip={t(`controls.chat.${tooltipLabel}`)}
|
||||||
|
isSelected={state?.showChat}
|
||||||
|
onPress={() => {
|
||||||
|
if (dispatch) dispatch({ msg: 'toggle_chat' })
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<RiChat1Line />
|
||||||
|
</Button>
|
||||||
|
{!!state?.unreadMessages && (
|
||||||
|
<div
|
||||||
|
className={css({
|
||||||
|
position: 'absolute',
|
||||||
|
top: '-.25rem',
|
||||||
|
right: '-.25rem',
|
||||||
|
width: '1rem',
|
||||||
|
height: '1rem',
|
||||||
|
backgroundColor: 'red',
|
||||||
|
borderRadius: '50%',
|
||||||
|
zIndex: 1,
|
||||||
|
border: '2px solid #d1d5db',
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -4,8 +4,6 @@ import * as React from 'react'
|
|||||||
import { supportsScreenSharing } from '@livekit/components-core'
|
import { supportsScreenSharing } from '@livekit/components-core'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ChatIcon,
|
|
||||||
ChatToggle,
|
|
||||||
DisconnectButton,
|
DisconnectButton,
|
||||||
LeaveIcon,
|
LeaveIcon,
|
||||||
MediaDeviceMenu,
|
MediaDeviceMenu,
|
||||||
@@ -19,7 +17,8 @@ import { StartMediaButton } from '../components/controls/StartMediaButton'
|
|||||||
import { useMediaQuery } from '../hooks/useMediaQuery'
|
import { useMediaQuery } from '../hooks/useMediaQuery'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { OptionsButton } from '../components/controls/Options/OptionsButton'
|
import { OptionsButton } from '../components/controls/Options/OptionsButton'
|
||||||
import { ParticipantsToggle } from '@/features/rooms/livekit/components/controls/Participants/ParticipantsToggle.tsx'
|
import { ParticipantsToggle } from '@/features/rooms/livekit/components/controls/Participants/ParticipantsToggle'
|
||||||
|
import { ChatToggle } from '@/features/rooms/livekit/components/controls/ChatToggle'
|
||||||
|
|
||||||
/** @public */
|
/** @public */
|
||||||
export type ControlBarControls = {
|
export type ControlBarControls = {
|
||||||
@@ -184,10 +183,7 @@ export function ControlBar({
|
|||||||
)}
|
)}
|
||||||
</TrackToggle>
|
</TrackToggle>
|
||||||
)}
|
)}
|
||||||
<ChatToggle>
|
<ChatToggle />
|
||||||
{showIcon && <ChatIcon />}
|
|
||||||
{showText && t('controls.chat')}
|
|
||||||
</ChatToggle>
|
|
||||||
<ParticipantsToggle />
|
<ParticipantsToggle />
|
||||||
<OptionsButton />
|
<OptionsButton />
|
||||||
<DisconnectButton>
|
<DisconnectButton>
|
||||||
|
|||||||
@@ -28,7 +28,10 @@
|
|||||||
"camera": "",
|
"camera": "",
|
||||||
"shareScreen": "",
|
"shareScreen": "",
|
||||||
"stopScreenShare": "",
|
"stopScreenShare": "",
|
||||||
"chat": "",
|
"chat": {
|
||||||
|
"open": "",
|
||||||
|
"closed": ""
|
||||||
|
},
|
||||||
"leave": "",
|
"leave": "",
|
||||||
"participants": {
|
"participants": {
|
||||||
"open": "",
|
"open": "",
|
||||||
|
|||||||
@@ -28,7 +28,10 @@
|
|||||||
"camera": "Camera",
|
"camera": "Camera",
|
||||||
"shareScreen": "Share screen",
|
"shareScreen": "Share screen",
|
||||||
"stopScreenShare": "Stop screen share",
|
"stopScreenShare": "Stop screen share",
|
||||||
"chat": "Chat",
|
"chat": {
|
||||||
|
"open": "Close the chat",
|
||||||
|
"closed": "Open the chat"
|
||||||
|
},
|
||||||
"leave": "Leave",
|
"leave": "Leave",
|
||||||
"participants": {
|
"participants": {
|
||||||
"open": "Hide everyone",
|
"open": "Hide everyone",
|
||||||
|
|||||||
@@ -28,7 +28,10 @@
|
|||||||
"camera": "Camera",
|
"camera": "Camera",
|
||||||
"shareScreen": "Partager l'écran",
|
"shareScreen": "Partager l'écran",
|
||||||
"stopScreenShare": "Arrêter le partage",
|
"stopScreenShare": "Arrêter le partage",
|
||||||
"chat": "Chat",
|
"chat": {
|
||||||
|
"open": "Masquer le chat",
|
||||||
|
"closed": "Afficher le chat"
|
||||||
|
},
|
||||||
"leave": "Quitter",
|
"leave": "Quitter",
|
||||||
"participants": {
|
"participants": {
|
||||||
"open": "Masquer les participants",
|
"open": "Masquer les participants",
|
||||||
|
|||||||
Reference in New Issue
Block a user