import ReactDOM from "react-dom";
import styled from "styled-components";
import {
StyledTooltip,
defaultBorderRadius,
lightGray,
vscForeground,
} from "..";
import { getPlatform } from "../../util";
const GridDiv = styled.div`
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
grid-gap: 2rem;
padding: 1rem;
justify-items: center;
align-items: center;
border-top: 0.5px solid ${lightGray};
`;
const StyledKeyDiv = styled.div`
border: 0.5px solid ${lightGray};
border-radius: ${defaultBorderRadius};
padding: 4px;
color: ${vscForeground};
width: 16px;
height: 16px;
display: flex;
justify-content: center;
align-items: center;
`;
const keyToName = {
"⌘": "Cmd",
"⌃": "Ctrl",
"⇧": "Shift",
"⏎": "Enter",
"⌫": "Backspace",
"⌥": "Option",
};
function KeyDiv({ text }: { text: string }) {
const tooltipPortalDiv = document.getElementById("tooltip-portal-div");
return (
<>
{text}
{tooltipPortalDiv &&
ReactDOM.createPortal(
,
tooltipPortalDiv,
)}
>
);
}
interface KeyboardShortcutProps {
mac: string;
windows: string;
description: string;
}
function KeyboardShortcut(props: KeyboardShortcutProps) {
const shortcut = getPlatform() === "mac" ? props.mac : props.windows;
return (
{props.description}
{shortcut.split(" ").map((key) => {
return ;
})}
);
}
const vscodeShortcuts: KeyboardShortcutProps[] = [
{
mac: "⌘ L",
windows: "⌃ L",
description: "Select Code + New Session",
},
{
mac: "⌘ I",
windows: "⌃ I",
description: "Edit highlighted code",
},
{
mac: "⌘ ⇧ L",
windows: "⌃ ⇧ L",
description: "Select Code",
},
{
mac: "⌘ ⇧ ⏎",
windows: "⌃ ⇧ ⏎",
description: "Accept Diff",
},
{
mac: "⌘ ⇧ ⌫",
windows: "⌃ ⇧ ⌫",
description: "Reject Diff",
},
{
mac: "⌥ ⌘ L",
windows: "⌥ ⌃ L",
description: "Toggle Auxiliary Bar",
},
{
mac: "⌘ ⇧ R",
windows: "⌃ ⇧ R",
description: "Debug Terminal",
},
{
mac: "⌘ ⌫",
windows: "⌃ ⌫",
description: "Cancel response",
},
{
mac: "⌘ K ⌘ M",
windows: "⌃ K ⌃ M",
description: "Toggle Full Screen",
},
{
mac: "⌘ '",
windows: "⌃ '",
description: "Toggle Selected Model",
},
];
const jetbrainsShortcuts: KeyboardShortcutProps[] = [
{
mac: "⌘ J",
windows: "⌃ J",
description: "Select Code + New Session",
},
{
mac: "⌘ ⇧ J",
windows: "⌃ ⇧ J",
description: "Select Code",
},
{
mac: "⌘ ⇧ ⏎",
windows: "⌃ ⇧ ⏎",
description: "Accept Diff",
},
{
mac: "⌘ ⇧ ⌫",
windows: "⌃ ⇧ ⌫",
description: "Reject Diff",
},
{
mac: "⌥ ⇧ J",
windows: "⌥ ⇧ J",
description: "Quick Input",
},
{
mac: "⌥ ⌘ J",
windows: "⌥ ⌃ J",
description: "Toggle Sidebar",
},
{
mac: "⌘ ⌫",
windows: "⌃ ⌫",
description: "Cancel response",
},
{
mac: "⌘ '",
windows: "⌃ '",
description: "Toggle Selected Model",
},
];
function KeyboardShortcutsDialog() {
return (
Keyboard Shortcuts
{(localStorage.getItem("ide") === "jetbrains"
? jetbrainsShortcuts
: vscodeShortcuts
).map((shortcut) => {
return (
);
})}
);
}
export default KeyboardShortcutsDialog;