Files
supabase/apps/www/components/LaunchWeek/13/useLWPartyMode.tsx
Francesco Sansalvadore 0111ea1426 tiger init follow up (#30659)
* meetups link

* max-height

* fix cursor and update share text
2024-11-25 17:12:46 -05:00

31 lines
910 B
TypeScript

import { useEffect, useState } from 'react'
import { useKey } from 'react-use'
import { useCommandMenuOpen } from 'ui-patterns'
import useLwGame from '../hooks/useLwGame'
import useConfData from '../hooks/use-conf-data'
const useLWPartyMode = (disabled?: boolean) => {
const [isPartyMode, setIsPartyMode] = useState<boolean>(true)
const { ticketState } = useConfData()
const isCommandMenuOpen = useCommandMenuOpen()
const { isGameMode } = useLwGame()
const enableTrigger = !disabled && !isCommandMenuOpen && !isGameMode
useKey('p', () => enableTrigger && setIsPartyMode(!isPartyMode), {}, [
isPartyMode,
isCommandMenuOpen,
isGameMode,
])
useKey('Escape', () => !isGameMode && setIsPartyMode(false), {}, [isPartyMode, isGameMode])
useEffect(() => {
setIsPartyMode(isPartyMode)
}, [ticketState])
return { isPartyMode, setIsPartyMode }
}
export default useLWPartyMode