feat(ott-279): hide score if ToggleScore is activated (#86)
parent
abfcf74bec
commit
c4904601d8
@ -0,0 +1,28 @@ |
|||||||
|
import type { KeyboardEvent } from 'react' |
||||||
|
import { useCallback } from 'react' |
||||||
|
|
||||||
|
import { useToggle } from 'hooks' |
||||||
|
import { useScoreStore } from 'features/ToggleScore' |
||||||
|
|
||||||
|
export const useCard = () => { |
||||||
|
const { |
||||||
|
close, |
||||||
|
isOpen, |
||||||
|
open, |
||||||
|
} = useToggle() |
||||||
|
const { isVisible } = useScoreStore() |
||||||
|
|
||||||
|
const onKeyPress = useCallback((e: KeyboardEvent<HTMLLIElement>) => { |
||||||
|
if (e.key === 'Enter') { |
||||||
|
open() |
||||||
|
} |
||||||
|
}, [open]) |
||||||
|
|
||||||
|
return { |
||||||
|
close, |
||||||
|
isOpen, |
||||||
|
onKeyPress, |
||||||
|
open, |
||||||
|
showScore: !isVisible, |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue