-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Expand file tree
/
Copy pathRunInTerminalButton.tsx
More file actions
38 lines (34 loc) · 1.28 KB
/
RunInTerminalButton.tsx
File metadata and controls
38 lines (34 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { CommandLineIcon } from "@heroicons/react/24/outline";
import { useContext } from "react";
import { lightGray, vscForeground } from "../..";
import { IdeMessengerContext } from "../../../context/IdeMessenger";
import { extractCommand } from "../utils/commandExtractor";
interface RunInTerminalButtonProps {
command: string;
}
export function RunInTerminalButton({ command }: RunInTerminalButtonProps) {
const ideMessenger = useContext(IdeMessengerContext);
function runInTerminal() {
// Extract just the command line
const extractedCommand = extractCommand(command);
void ideMessenger.post("runCommand", { command: extractedCommand });
}
return (
<div
role="button"
aria-label="Run command in terminal"
className={`text-lightgray flex items-center border-none bg-transparent text-xs text-[${vscForeground}] cursor-pointer outline-none hover:brightness-125`}
onClick={runInTerminal}
>
<div
className="max-2xs:hidden flex items-center gap-1 transition-colors duration-200 hover:brightness-125"
style={{ color: lightGray }}
>
<>
<CommandLineIcon className="h-3 w-3 hover:brightness-125" />
<span className="text-lightgray max-sm:hidden">Run</span>
</>
</div>
</div>
);
}