import { useTheme } from 'gloss' import React, { useState } from 'react' import { Card, CardProps } from './Card' import { FloatingView, FloatingViewProps } from './FloatingView' import { useVisibility } from './Visibility' type FloatingCardProps = Omit & Pick< FloatingViewProps, | 'defaultTop' | 'defaultLeft' | 'disableDrag' | 'defaultWidth' | 'defaultHeight' | 'top' | 'left' | 'width' | 'height' | 'usePosition' | 'attach' | 'maxHeight' | 'maxWidth' | 'bounds' > & { visible?: boolean outside?: React.ReactNode } export function FloatingCard({ // @ts-ignore deep usePosition, defaultTop = 0, defaultLeft = 0, disableDrag, defaultWidth, defaultHeight, top, left, width, height, zIndex = 10000000, pointerEvents = 'auto', visible, attach, elevation = 2, maxHeight, maxWidth, outside, bounds, ...cardProps }: FloatingCardProps) { const isVisible = useVisibility() const theme = useTheme() const [collapsed, setCollapsed] = useState(false) const visibilityProps: any = { pointerEvents: isVisible && visible ? pointerEvents : 'none', opacity: visible ? 1 : 0, transform: { y: visible ? 0 : 10, }, } return ( {outside} ) }