import { CheckIcon, PlayIcon } from "@heroicons/react/24/outline"; import { useState } from "react"; import styled from "styled-components"; import { vscEditorBackground } from ".."; import { isJetBrains, postToIde } from "../../util/ide"; import HeaderButtonWithText from "../HeaderButtonWithText"; import { CopyButton } from "./CopyButton"; const TopDiv = styled.div` position: sticky; top: 0; left: 100%; height: 0; width: 0; overflow: visible; z-index: 100; `; const SecondDiv = styled.div<{ bottom: boolean }>` position: absolute; ${(props) => (props.bottom ? "bottom: 1.2rem;" : "top: 4px;")} right: 4px; display: flex; gap: 4px; background-color: ${vscEditorBackground}; `; interface CodeBlockToolBarProps { text: string; bottom: boolean; } function CodeBlockToolBar(props: CodeBlockToolBarProps) { const [copied, setCopied] = useState(false); const [applying, setApplying] = useState(false); return ( {isJetBrains() || ( { if (applying) return; postToIde("applyToCurrentFile", { text: props.text }); setApplying(true); setTimeout(() => setApplying(false), 2000); }} > {applying ? ( ) : ( )} )} ); } export default CodeBlockToolBar;