♻️(frontend) rename useWidget to useSidePanel
Rename useWidget interaction to useSidePanel. Remove LiveKit-specific naming as we no longer use LiveKit elements in the layout context. This change improves clarity and reflects the current functionality of the hook.
This commit is contained in:
committed by
aleb_the_flash
parent
a84b76170d
commit
0db36c788b
@@ -6,7 +6,7 @@ import { HStack } from '@/styled-system/jsx'
|
|||||||
import { Button, Div } from '@/primitives'
|
import { Button, Div } from '@/primitives'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { RiCloseLine, RiHand } from '@remixicon/react'
|
import { RiCloseLine, RiHand } from '@remixicon/react'
|
||||||
import { useWidgetInteraction } from '@/features/rooms/livekit/hooks/useWidgetInteraction'
|
import { useSidePanel } from '@/features/rooms/livekit/hooks/useSidePanel'
|
||||||
|
|
||||||
export function ToastRaised({ state, ...props }: ToastProps) {
|
export function ToastRaised({ state, ...props }: ToastProps) {
|
||||||
const { t } = useTranslation('notifications')
|
const { t } = useTranslation('notifications')
|
||||||
@@ -17,7 +17,7 @@ export function ToastRaised({ state, ...props }: ToastProps) {
|
|||||||
ref
|
ref
|
||||||
)
|
)
|
||||||
const participant = props.toast.content.participant
|
const participant = props.toast.content.participant
|
||||||
const { isParticipantsOpen, toggleParticipants } = useWidgetInteraction()
|
const { isParticipantsOpen, toggleParticipants } = useSidePanel()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledToastContainer {...toastProps} ref={ref}>
|
<StyledToastContainer {...toastProps} ref={ref}>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { Box, Button, Div } from '@/primitives'
|
|||||||
import { RiCloseLine } from '@remixicon/react'
|
import { RiCloseLine } from '@remixicon/react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { ParticipantsList } from './controls/Participants/ParticipantsList'
|
import { ParticipantsList } from './controls/Participants/ParticipantsList'
|
||||||
import { useWidgetInteraction } from '../hooks/useWidgetInteraction'
|
import { useSidePanel } from '../hooks/useSidePanel'
|
||||||
import { ReactNode } from 'react'
|
import { ReactNode } from 'react'
|
||||||
import { Effects } from './Effects'
|
import { Effects } from './Effects'
|
||||||
import { Chat } from '../prefabs/Chat'
|
import { Chat } from '../prefabs/Chat'
|
||||||
@@ -103,8 +103,7 @@ export const SidePanel = () => {
|
|||||||
const layoutSnap = useSnapshot(layoutStore)
|
const layoutSnap = useSnapshot(layoutStore)
|
||||||
const sidePanel = layoutSnap.sidePanel
|
const sidePanel = layoutSnap.sidePanel
|
||||||
|
|
||||||
const { isParticipantsOpen, isEffectsOpen, isChatOpen } =
|
const { isParticipantsOpen, isEffectsOpen, isChatOpen } = useSidePanel()
|
||||||
useWidgetInteraction()
|
|
||||||
const { t } = useTranslation('rooms', { keyPrefix: 'sidePanel' })
|
const { t } = useTranslation('rooms', { keyPrefix: 'sidePanel' })
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -3,15 +3,15 @@ import { RiChat1Line } from '@remixicon/react'
|
|||||||
import { useSnapshot } from 'valtio'
|
import { useSnapshot } from 'valtio'
|
||||||
import { css } from '@/styled-system/css'
|
import { css } from '@/styled-system/css'
|
||||||
import { ToggleButton } from '@/primitives'
|
import { ToggleButton } from '@/primitives'
|
||||||
import { useWidgetInteraction } from '../../hooks/useWidgetInteraction'
|
|
||||||
import { chatStore } from '@/stores/chat'
|
import { chatStore } from '@/stores/chat'
|
||||||
|
import { useSidePanel } from '../../hooks/useSidePanel'
|
||||||
|
|
||||||
export const ChatToggle = () => {
|
export const ChatToggle = () => {
|
||||||
const { t } = useTranslation('rooms', { keyPrefix: 'controls.chat' })
|
const { t } = useTranslation('rooms', { keyPrefix: 'controls.chat' })
|
||||||
|
|
||||||
const chatSnap = useSnapshot(chatStore)
|
const chatSnap = useSnapshot(chatStore)
|
||||||
|
|
||||||
const { isChatOpen, toggleChat } = useWidgetInteraction()
|
const { isChatOpen, toggleChat } = useSidePanel()
|
||||||
const tooltipLabel = isChatOpen ? 'open' : 'closed'
|
const tooltipLabel = isChatOpen ? 'open' : 'closed'
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { useTranslation } from 'react-i18next'
|
|||||||
import { Dispatch, SetStateAction } from 'react'
|
import { Dispatch, SetStateAction } from 'react'
|
||||||
import { DialogState } from './OptionsButton'
|
import { DialogState } from './OptionsButton'
|
||||||
import { Separator } from '@/primitives/Separator'
|
import { Separator } from '@/primitives/Separator'
|
||||||
import { useWidgetInteraction } from '../../../hooks/useWidgetInteraction'
|
import { useSidePanel } from '../../../hooks/useSidePanel'
|
||||||
|
|
||||||
// @todo try refactoring it to use MenuList component
|
// @todo try refactoring it to use MenuList component
|
||||||
export const OptionsMenuItems = ({
|
export const OptionsMenuItems = ({
|
||||||
@@ -18,7 +18,7 @@ export const OptionsMenuItems = ({
|
|||||||
onOpenDialog: Dispatch<SetStateAction<DialogState>>
|
onOpenDialog: Dispatch<SetStateAction<DialogState>>
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation('rooms', { keyPrefix: 'options.items' })
|
const { t } = useTranslation('rooms', { keyPrefix: 'options.items' })
|
||||||
const { toggleEffects } = useWidgetInteraction()
|
const { toggleEffects } = useSidePanel()
|
||||||
return (
|
return (
|
||||||
<RACMenu
|
<RACMenu
|
||||||
style={{
|
style={{
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { RiGroupLine, RiInfinityLine } from '@remixicon/react'
|
|||||||
import { ToggleButton } from '@/primitives'
|
import { ToggleButton } from '@/primitives'
|
||||||
import { css } from '@/styled-system/css'
|
import { css } from '@/styled-system/css'
|
||||||
import { useParticipants } from '@livekit/components-react'
|
import { useParticipants } from '@livekit/components-react'
|
||||||
import { useWidgetInteraction } from '../../../hooks/useWidgetInteraction'
|
import { useSidePanel } from '../../../hooks/useSidePanel'
|
||||||
|
|
||||||
export const ParticipantsToggle = () => {
|
export const ParticipantsToggle = () => {
|
||||||
const { t } = useTranslation('rooms', { keyPrefix: 'controls.participants' })
|
const { t } = useTranslation('rooms', { keyPrefix: 'controls.participants' })
|
||||||
@@ -16,7 +16,7 @@ export const ParticipantsToggle = () => {
|
|||||||
const participants = useParticipants()
|
const participants = useParticipants()
|
||||||
const numParticipants = participants?.length
|
const numParticipants = participants?.length
|
||||||
|
|
||||||
const { isParticipantsOpen, toggleParticipants } = useWidgetInteraction()
|
const { isParticipantsOpen, toggleParticipants } = useSidePanel()
|
||||||
|
|
||||||
const tooltipLabel = isParticipantsOpen ? 'open' : 'closed'
|
const tooltipLabel = isParticipantsOpen ? 'open' : 'closed'
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ export enum SidePanel {
|
|||||||
CHAT = 'chat',
|
CHAT = 'chat',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useWidgetInteraction = () => {
|
export const useSidePanel = () => {
|
||||||
const layoutSnap = useSnapshot(layoutStore)
|
const layoutSnap = useSnapshot(layoutStore)
|
||||||
const sidePanel = layoutSnap.sidePanel
|
const sidePanel = layoutSnap.sidePanel
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ import { chatStore } from '@/stores/chat'
|
|||||||
import { Div, Text } from '@/primitives'
|
import { Div, Text } from '@/primitives'
|
||||||
import { ChatInput } from '../components/chat/Input'
|
import { ChatInput } from '../components/chat/Input'
|
||||||
import { ChatEntry } from '../components/chat/Entry'
|
import { ChatEntry } from '../components/chat/Entry'
|
||||||
import { useWidgetInteraction } from '../hooks/useWidgetInteraction'
|
import { useSidePanel } from '../hooks/useSidePanel'
|
||||||
|
|
||||||
export interface ChatProps
|
export interface ChatProps
|
||||||
extends React.HTMLAttributes<HTMLDivElement>,
|
extends React.HTMLAttributes<HTMLDivElement>,
|
||||||
@@ -29,7 +29,7 @@ export function Chat({ ...props }: ChatProps) {
|
|||||||
|
|
||||||
const { send, chatMessages, isSending } = useChat()
|
const { send, chatMessages, isSending } = useChat()
|
||||||
|
|
||||||
const { isChatOpen } = useWidgetInteraction()
|
const { isChatOpen } = useSidePanel()
|
||||||
const chatSnap = useSnapshot(chatStore)
|
const chatSnap = useSnapshot(chatStore)
|
||||||
|
|
||||||
// Use useParticipants hook to trigger a re-render when the participant list changes.
|
// Use useParticipants hook to trigger a re-render when the participant list changes.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { proxy } from 'valtio'
|
import { proxy } from 'valtio'
|
||||||
import { SidePanel } from '@/features/rooms/livekit/hooks/useWidgetInteraction'
|
import { SidePanel } from '@/features/rooms/livekit/hooks/useSidePanel'
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
showHeader: boolean
|
showHeader: boolean
|
||||||
|
|||||||
Reference in New Issue
Block a user