import * as React from "react"; import * as Constants from "~/common/constants"; import * as Validations from "~/common/validations"; import { css, keyframes } from "@emotion/core"; import { useState } from "react"; const fadeIn = keyframes` 0%{ opacity: 0; } 100%{ opacity: 1; } `; const STYLES_FILE_PREVIEW_BUBBLE = css` z-index: ${Constants.zindex.tooltip}; padding: 8px; border-radius: 4px; background-color: ${Constants.system.black}; animation: ${fadeIn} 200ms ease-out 1; width: 200px; position: absolute; `; const STYLES_FILE_PREVIEW = css` display: block; width: 100%; height: 100%; `; const STYLES_BUBBLE_ANCHOR = css` display: inline-flex; align-item: center; justify-content: center; cursor: pointer; `; //Jim: the parent of this element needs to be position: relative or this bubble will fly off its position export const FilePreviewBubble = (props) => { const [onHover, setHover] = useState(false); const showPreview = props.type && Validations.isPreviewableImage(props.type) && onHover; return (
setHover(true)} onMouseLeave={() => setHover(false)} > {props.children}
{showPreview && (
)}
); }; export default FilePreviewBubble;