diff options
author | Nate Sesti <sestinj@gmail.com> | 2023-07-15 15:06:32 -0700 |
---|---|---|
committer | Nate Sesti <sestinj@gmail.com> | 2023-07-15 15:06:32 -0700 |
commit | 46883738a287a5eb1cfae71ab1f6127450f7554f (patch) | |
tree | 057ade81f0c5b218c36bd19c0932bd0ff8dbb1e6 /extension/react-app/src | |
parent | 925c3e0ef45d9eb01a8f6c1efd239fa011492bd2 (diff) | |
download | sncontinue-46883738a287a5eb1cfae71ab1f6127450f7554f.tar.gz sncontinue-46883738a287a5eb1cfae71ab1f6127450f7554f.tar.bz2 sncontinue-46883738a287a5eb1cfae71ab1f6127450f7554f.zip |
use correct label for meta key
Diffstat (limited to 'extension/react-app/src')
-rw-r--r-- | extension/react-app/src/components/ComboBox.tsx | 3 | ||||
-rw-r--r-- | extension/react-app/src/components/StepContainer.tsx | 7 | ||||
-rw-r--r-- | extension/react-app/src/util/index.ts | 17 |
3 files changed, 23 insertions, 4 deletions
diff --git a/extension/react-app/src/components/ComboBox.tsx b/extension/react-app/src/components/ComboBox.tsx index 754c9445..f11e07af 100644 --- a/extension/react-app/src/components/ComboBox.tsx +++ b/extension/react-app/src/components/ComboBox.tsx @@ -13,6 +13,7 @@ import HeaderButtonWithText from "./HeaderButtonWithText"; import { DocumentPlus } from "@styled-icons/heroicons-outline"; import { HighlightedRangeContext } from "../../../schema/FullState"; import { postVscMessage } from "../vscode"; +import { getMetaKeyLabel } from "../util"; // #region styled components const mainInputFontSize = 13; @@ -286,7 +287,7 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { <div className="flex px-2" ref={divRef} hidden={!downshiftProps.isOpen}> <MainTextInput disabled={props.disabled} - placeholder="Ask a question, give instructions, or type '/' to see slash commands. ⌘⏎ to edit." + placeholder={`Ask a question, give instructions, or type '/' to see slash commands. ${getMetaKeyLabel()}⏎ to edit.`} {...getInputProps({ onChange: (e) => { const target = e.target as HTMLTextAreaElement; diff --git a/extension/react-app/src/components/StepContainer.tsx b/extension/react-app/src/components/StepContainer.tsx index 7f23e333..93bdbc89 100644 --- a/extension/react-app/src/components/StepContainer.tsx +++ b/extension/react-app/src/components/StepContainer.tsx @@ -17,6 +17,7 @@ import { StopCircle } from "@styled-icons/heroicons-solid"; import { HistoryNode } from "../../../schema/HistoryNode"; import HeaderButtonWithText from "./HeaderButtonWithText"; import MarkdownPreview from "@uiw/react-markdown-preview"; +import { getMetaKeyLabel, isMetaEquivalentKeyPressed } from "../util"; interface StepContainerProps { historyNode: HistoryNode; @@ -217,7 +218,11 @@ function StepContainer(props: StepContainerProps) { e.stopPropagation(); props.onDelete(); }} - text={props.historyNode.active ? "Stop (⌘⌫)" : "Delete"} + text={ + props.historyNode.active + ? `Stop (${getMetaKeyLabel()}⌫)` + : "Delete" + } > {props.historyNode.active ? ( <StopCircle size="1.6em" onClick={props.onDelete} /> diff --git a/extension/react-app/src/util/index.ts b/extension/react-app/src/util/index.ts index ad711321..c4168e13 100644 --- a/extension/react-app/src/util/index.ts +++ b/extension/react-app/src/util/index.ts @@ -1,6 +1,6 @@ type Platform = "mac" | "linux" | "windows" | "unknown"; -function getPlatform(): Platform { +export function getPlatform(): Platform { const platform = window.navigator.platform.toUpperCase(); if (platform.indexOf("MAC") >= 0) { return "mac"; @@ -13,7 +13,7 @@ function getPlatform(): Platform { } } -function isMetaEquivalentKeyPressed(event: { +export function isMetaEquivalentKeyPressed(event: { metaKey: boolean; ctrlKey: boolean; }): boolean { @@ -28,3 +28,16 @@ function isMetaEquivalentKeyPressed(event: { return event.metaKey; } } + +export function getMetaKeyLabel(): string { + const platform = getPlatform(); + switch (platform) { + case "mac": + return "⌘"; + case "linux": + case "windows": + return "^"; + default: + return "⌘"; + } +} |