refactor for useTooltip remove unnecessary as $IntentionalAny
This commit is contained in:
parent
9400aa12a1
commit
79f2424a8a
2 changed files with 5 additions and 8 deletions
|
@ -9,7 +9,6 @@ import {usePrism} from '@theatre/react'
|
||||||
import getStudio from '@theatre/studio/getStudio'
|
import getStudio from '@theatre/studio/getStudio'
|
||||||
import {val} from '@theatre/dataverse'
|
import {val} from '@theatre/dataverse'
|
||||||
import useTooltip from '@theatre/studio/uiComponents/Popover/useTooltip'
|
import useTooltip from '@theatre/studio/uiComponents/Popover/useTooltip'
|
||||||
import type {$IntentionalAny} from '@theatre/shared/utils/types'
|
|
||||||
import BasicTooltip from '@theatre/studio/uiComponents/Popover/BasicTooltip'
|
import BasicTooltip from '@theatre/studio/uiComponents/Popover/BasicTooltip'
|
||||||
import ErrorTooltip from '@theatre/studio/uiComponents/Popover/ErrorTooltip'
|
import ErrorTooltip from '@theatre/studio/uiComponents/Popover/ErrorTooltip'
|
||||||
|
|
||||||
|
@ -148,7 +147,7 @@ const OutlinePanel: React.FC<{}> = (props) => {
|
||||||
)
|
)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const [triggerTooltip, triggerButtonRef] = useTooltip(
|
const [triggerTooltip, triggerButtonRef] = useTooltip<HTMLButtonElement>(
|
||||||
{enabled: conflicts.length > 0, enterDelay: conflicts.length > 0 ? 0 : 200},
|
{enabled: conflicts.length > 0, enterDelay: conflicts.length > 0 ? 0 : 200},
|
||||||
() =>
|
() =>
|
||||||
conflicts.length > 0 ? (
|
conflicts.length > 0 ? (
|
||||||
|
@ -167,7 +166,7 @@ const OutlinePanel: React.FC<{}> = (props) => {
|
||||||
<TriggerContainer>
|
<TriggerContainer>
|
||||||
{triggerTooltip}
|
{triggerTooltip}
|
||||||
<TriggerButton
|
<TriggerButton
|
||||||
ref={triggerButtonRef as $IntentionalAny}
|
ref={triggerButtonRef}
|
||||||
data-testid="OutlinePanel-TriggerButton"
|
data-testid="OutlinePanel-TriggerButton"
|
||||||
>
|
>
|
||||||
<VscListTree />
|
<VscListTree />
|
||||||
|
|
|
@ -9,7 +9,7 @@ import {useTooltipOpenState} from './TooltipContext'
|
||||||
import {PortalContext} from 'reakit'
|
import {PortalContext} from 'reakit'
|
||||||
import noop from '@theatre/shared/utils/noop'
|
import noop from '@theatre/shared/utils/noop'
|
||||||
|
|
||||||
export default function useTooltip(
|
export default function useTooltip<T extends HTMLElement>(
|
||||||
opts: {
|
opts: {
|
||||||
enabled?: boolean
|
enabled?: boolean
|
||||||
enterDelay?: number
|
enterDelay?: number
|
||||||
|
@ -20,15 +20,13 @@ export default function useTooltip(
|
||||||
render: () => React.ReactElement,
|
render: () => React.ReactElement,
|
||||||
): [
|
): [
|
||||||
node: React.ReactNode,
|
node: React.ReactNode,
|
||||||
targetRef: MutableRefObject<HTMLElement | SVGElement | null>,
|
targetRef: MutableRefObject<T | null>,
|
||||||
isOpen: boolean,
|
isOpen: boolean,
|
||||||
] {
|
] {
|
||||||
const enabled = opts.enabled !== false
|
const enabled = opts.enabled !== false
|
||||||
const [isOpen, setIsOpen] = useTooltipOpenState()
|
const [isOpen, setIsOpen] = useTooltipOpenState()
|
||||||
|
|
||||||
const [targetRef, targetNode] = useRefAndState<
|
const [targetRef, targetNode] = useRefAndState<T | null>(null)
|
||||||
HTMLElement | SVGElement | null
|
|
||||||
>(null)
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!enabled) {
|
if (!enabled) {
|
||||||
|
|
Loading…
Reference in a new issue