From 63ed4d5f9143a02b7f79d8cf04bd28a91c074676 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Wed, 17 Jan 2024 21:05:40 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20closer=20match=20to=20vscode=20c?= =?UTF-8?q?olor=20scheme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gui/src/components/Layout.tsx | 6 +-- gui/src/components/archive/EditableDiv.tsx | 4 +- .../dialogs/SelectContextGroupDialog.tsx | 4 +- gui/src/components/dialogs/index.tsx | 6 +-- gui/src/components/gui/StepContainer.tsx | 4 +- gui/src/components/index.ts | 42 +++++++++++++------ .../mainInput/CodeBlockExtension.tsx | 4 +- gui/src/components/mainInput/InputToolbar.tsx | 4 +- gui/src/components/mainInput/MentionList.tsx | 12 +++--- gui/src/components/mainInput/TipTapEditor.css | 8 ++-- gui/src/components/mainInput/TipTapEditor.tsx | 9 ++-- gui/src/components/markdown/LinkableCode.tsx | 4 +- .../components/modelSelection/ModelCard.tsx | 15 ++++--- .../components/modelSelection/ModelSelect.tsx | 22 +++++----- gui/src/components/modelSelection/Toggle.tsx | 14 +++++-- gui/src/pages/help.tsx | 13 ++---- gui/src/pages/history.tsx | 10 ++--- gui/src/pages/monaco.tsx | 14 +++---- gui/src/pages/settings.tsx | 4 +- 19 files changed, 115 insertions(+), 84 deletions(-) diff --git a/gui/src/components/Layout.tsx b/gui/src/components/Layout.tsx index f76bfa728..1ed010361 100644 --- a/gui/src/components/Layout.tsx +++ b/gui/src/components/Layout.tsx @@ -10,9 +10,9 @@ import { Outlet, useLocation, useNavigate } from "react-router-dom"; import styled from "styled-components"; import { defaultBorderRadius, - secondaryDark, vscBackground, vscForeground, + vscInputBackground, } from "."; import { defaultModelSelector } from "../redux/selectors/modelSelectors"; import { @@ -61,7 +61,7 @@ const BottomMessageDiv = styled.div<{ displayOnBottom: boolean }>` right: 0; margin: 8px; margin-top: 0; - background-color: ${secondaryDark}; + background-color: ${vscInputBackground}; color: ${vscForeground}; border-radius: ${defaultBorderRadius}; padding: 12px; @@ -93,7 +93,7 @@ const GridDiv = styled.div` `; const DropdownPortalDiv = styled.div` - background-color: ${secondaryDark}; + background-color: ${vscInputBackground}; position: relative; margin-left: 8px; z-index: 200; diff --git a/gui/src/components/archive/EditableDiv.tsx b/gui/src/components/archive/EditableDiv.tsx index 730bc8dcb..1ed08ee24 100644 --- a/gui/src/components/archive/EditableDiv.tsx +++ b/gui/src/components/archive/EditableDiv.tsx @@ -2,8 +2,8 @@ import styled from "styled-components"; import { defaultBorderRadius, lightGray, - secondaryDark, vscForeground, + vscInputBackground, } from ".."; import { getFontSize } from "../../util"; @@ -17,7 +17,7 @@ const Div = styled.div<{ fontSize?: number }>` margin: 8px auto; height: auto; width: 100%; - background-color: ${secondaryDark}; + background-color: ${vscInputBackground}; color: ${vscForeground}; z-index: 1; border: 1px solid transparent; diff --git a/gui/src/components/dialogs/SelectContextGroupDialog.tsx b/gui/src/components/dialogs/SelectContextGroupDialog.tsx index b8154ac43..0d8e1c541 100644 --- a/gui/src/components/dialogs/SelectContextGroupDialog.tsx +++ b/gui/src/components/dialogs/SelectContextGroupDialog.tsx @@ -4,9 +4,9 @@ import styled from "styled-components"; import { Button, defaultBorderRadius, - secondaryDark, vscBackground, vscForeground, + vscInputBackground, } from ".."; import { setDialogMessage, @@ -36,7 +36,7 @@ const ContextGroupSelectDiv = styled.div` gap: 8px; padding: 8px; border-radius: ${defaultBorderRadius}; - background-color: ${secondaryDark}; + background-color: ${vscInputBackground}; color: ${vscForeground}; margin-top: 8px; cursor: pointer; diff --git a/gui/src/components/dialogs/index.tsx b/gui/src/components/dialogs/index.tsx index 30c7e18fd..baf72d828 100644 --- a/gui/src/components/dialogs/index.tsx +++ b/gui/src/components/dialogs/index.tsx @@ -1,7 +1,7 @@ import React, { isValidElement, useEffect } from "react"; -import styled from "styled-components"; -import { secondaryDark, vscBackground, vscForeground } from ".."; import { ReactMarkdown } from "react-markdown/lib/react-markdown"; +import styled from "styled-components"; +import { vscBackground, vscForeground, vscInputBackground } from ".."; const ScreenCover = styled.div` position: fixed; @@ -37,7 +37,7 @@ const TextArea = styled.textarea` padding: 8px; outline: 1px solid black; resize: none; - background-color: ${secondaryDark}; + background-color: ${vscInputBackground}; color: ${vscForeground}; &:focus { diff --git a/gui/src/components/gui/StepContainer.tsx b/gui/src/components/gui/StepContainer.tsx index a13aa1e41..86e9a3868 100644 --- a/gui/src/components/gui/StepContainer.tsx +++ b/gui/src/components/gui/StepContainer.tsx @@ -9,8 +9,8 @@ import styled from "styled-components"; import { defaultBorderRadius, lightGray, - secondaryDark, vscBackground, + vscInputBackground, } from ".."; import { RootStore } from "../../redux/store"; import { getFontSize } from "../../util"; @@ -50,7 +50,7 @@ const ContentDiv = styled.div<{ isUserInput: boolean; fontSize?: number }>` padding: 2px; padding-right: 0px; background-color: ${(props) => - props.isUserInput ? secondaryDark : vscBackground}; + props.isUserInput ? vscInputBackground : vscBackground}; font-size: ${(props) => props.fontSize || getFontSize()}px; border-radius: ${defaultBorderRadius}; overflow: hidden; diff --git a/gui/src/components/index.ts b/gui/src/components/index.ts index 93de7238e..d7bb09ff1 100644 --- a/gui/src/components/index.ts +++ b/gui/src/components/index.ts @@ -3,31 +3,49 @@ import styled, { keyframes } from "styled-components"; import { getFontSize } from "../util"; import { isJetBrains } from "../util/ide"; -export const VSC_SECONDARY_DARK_VAR = "--vscode-input-background"; +export const VSC_INPUT_BACKGROUND_VAR = "--vscode-input-background"; export const VSC_BACKGROUND_VAR = "--vscode-sideBar-background"; export const VSC_FOREGROUND_VAR = "--vscode-editor-foreground"; export const VSC_BUTTON_BACKGROUND_VAR = "--vscode-button-background"; export const VSC_EDITOR_BACKGROUND_VAR = "--vscode-editor-background"; +export const VSC_LIST_SELECTION_BACKGROUND_VAR = + "--vscode-list-activeSelectionBackground"; +export const VSC_FOCUS_BORDER = "--vscode-focus-border"; +export const VSC_LIST_ACTIVE_FOREGROUND_VAR = + "--vscode-quickInputList-focusForeground"; +export const VSC_QUICK_INPUT_BACKGROUND_VAR = "--vscode-quickInput-background"; +export const VSC_INPUT_BORDER_VAR = "--vscode-input-border"; +export const VSC_INPUT_BORDER_FOCUS_VAR = "--vscode-focusBorder"; export const VSC_THEME_COLOR_VARS = [ - VSC_SECONDARY_DARK_VAR, + VSC_INPUT_BACKGROUND_VAR, VSC_BACKGROUND_VAR, VSC_FOREGROUND_VAR, VSC_BUTTON_BACKGROUND_VAR, VSC_EDITOR_BACKGROUND_VAR, + VSC_LIST_SELECTION_BACKGROUND_VAR, + VSC_FOCUS_BORDER, + VSC_LIST_ACTIVE_FOREGROUND_VAR, + VSC_QUICK_INPUT_BACKGROUND_VAR, + VSC_INPUT_BORDER_VAR, + VSC_INPUT_BORDER_FOCUS_VAR, ]; export const defaultBorderRadius = "5px"; export const lightGray = "#646464"; -export const buttonColor = "#1bbe84"; -export const buttonColorHover = "#1bbe84a8"; +export const greenButtonColor = "#1bbe84"; -export const secondaryDark = `var(${VSC_SECONDARY_DARK_VAR}, rgb(45 45 45))`; -// export const vscBackground = "var(--vscode-editor-background, rgb(30 30 30))"; +export const vscInputBackground = `var(${VSC_INPUT_BACKGROUND_VAR}, rgb(45 45 45))`; +export const vscQuickInputBackground = `var(${VSC_QUICK_INPUT_BACKGROUND_VAR}, ${VSC_INPUT_BACKGROUND_VAR}, rgb(45 45 45))`; export const vscBackground = `var(${VSC_BACKGROUND_VAR}, rgb(30 30 30))`; export const vscForeground = `var(${VSC_FOREGROUND_VAR}, #fff)`; export const vscButtonBackground = `var(${VSC_BUTTON_BACKGROUND_VAR}, #1bbe84)`; export const vscEditorBackground = `var(${VSC_EDITOR_BACKGROUND_VAR}, ${VSC_BACKGROUND_VAR}, rgb(30 30 30))`; +export const vscListActiveBackground = `var(${VSC_LIST_SELECTION_BACKGROUND_VAR}, #1bbe84)`; +export const vscFocusBorder = `var(${VSC_FOCUS_BORDER}, #1bbe84)`; +export const vscListActiveForeground = `var(${VSC_LIST_ACTIVE_FOREGROUND_VAR}, ${VSC_FOREGROUND_VAR})`; +export const vscInputBorder = `var(${VSC_INPUT_BORDER_VAR}, ${lightGray})`; +export const vscInputBorderFocus = `var(${VSC_INPUT_BORDER_FOCUS_VAR}, ${lightGray})`; if (typeof document !== "undefined") { for (const colorVar of VSC_THEME_COLOR_VARS) { @@ -55,7 +73,7 @@ export const Button = styled.button` border: none; color: white; - background-color: ${buttonColor}; + background-color: ${vscListActiveBackground}; &:disabled { color: gray; @@ -85,7 +103,7 @@ export const TextArea = styled.textarea` margin: 16px auto; height: auto; width: calc(100% - 32px); - background-color: ${secondaryDark}; + background-color: ${vscInputBackground}; color: ${vscForeground}; z-index: 1; border: 1px solid transparent; @@ -120,7 +138,7 @@ export const Pre = styled.pre` `; export const H3 = styled.h3` - background-color: ${secondaryDark}; + background-color: ${vscInputBackground}; border-radius: ${defaultBorderRadius}; padding: 4px 8px; width: fit-content; @@ -138,7 +156,7 @@ export const Input = styled.input` color: ${vscForeground}; &:focus { - background: ${secondaryDark}; + background: ${vscInputBackground}; } &:invalid { @@ -157,7 +175,7 @@ export const NumberInput = styled.input.attrs({ type: "number" })` color: ${vscForeground}; &:focus { - background: ${secondaryDark}; + background: ${vscInputBackground}; } `; @@ -242,7 +260,7 @@ export const HeaderButton = styled.button<{ inverted: boolean | undefined }>` &:hover { background-color: ${({ inverted }) => typeof inverted === "undefined" || inverted - ? secondaryDark + ? vscInputBackground : "transparent"}; } display: flex; diff --git a/gui/src/components/mainInput/CodeBlockExtension.tsx b/gui/src/components/mainInput/CodeBlockExtension.tsx index caff21e15..829de25ba 100644 --- a/gui/src/components/mainInput/CodeBlockExtension.tsx +++ b/gui/src/components/mainInput/CodeBlockExtension.tsx @@ -2,7 +2,7 @@ import { mergeAttributes, Node } from "@tiptap/core"; import { NodeViewWrapper, ReactNodeViewRenderer } from "@tiptap/react"; import { ContextItemWithId } from "core"; import { useDispatch, useSelector } from "react-redux"; -import { buttonColor } from ".."; +import { vscFocusBorder } from ".."; import { setEditingContextItemAtIndex } from "../../redux/slices/stateSlice"; import { RootStore } from "../../redux/store"; import CodeSnippetPreview from "../markdown/CodeSnippetPreview"; @@ -27,7 +27,7 @@ const CodeBlockComponent = ({ item.id === contextItems[0]?.id ? "#d0d" : selected - ? buttonColor + ? vscFocusBorder : undefined } item={item} diff --git a/gui/src/components/mainInput/InputToolbar.tsx b/gui/src/components/mainInput/InputToolbar.tsx index 5fc725386..1d4cf70cd 100644 --- a/gui/src/components/mainInput/InputToolbar.tsx +++ b/gui/src/components/mainInput/InputToolbar.tsx @@ -1,5 +1,5 @@ import styled from "styled-components"; -import { defaultBorderRadius, lightGray, secondaryDark } from ".."; +import { defaultBorderRadius, lightGray, vscInputBackground } from ".."; const StyledDiv = styled.div<{ hidden?: boolean }>` position: absolute; @@ -8,7 +8,7 @@ const StyledDiv = styled.div<{ hidden?: boolean }>` right: 4px; bottom: 4px; width: calc(100% - 10px); - background-color: ${secondaryDark}; + background-color: ${vscInputBackground}; ${(props) => (props.hidden ? "display: none;" : "")} diff --git a/gui/src/components/mainInput/MentionList.tsx b/gui/src/components/mainInput/MentionList.tsx index 16ee7be9b..d16871728 100644 --- a/gui/src/components/mainInput/MentionList.tsx +++ b/gui/src/components/mainInput/MentionList.tsx @@ -28,11 +28,12 @@ import { } from "react"; import styled from "styled-components"; import { - buttonColor, defaultBorderRadius, lightGray, - secondaryDark, vscForeground, + vscListActiveBackground, + vscListActiveForeground, + vscQuickInputBackground, } from ".."; import FileIcon from "../FileIcon"; import { ComboBoxItem, ComboBoxItemType } from "./types"; @@ -89,7 +90,7 @@ const ItemsDiv = styled.div` padding: 0.2rem; position: relative; - background-color: ${secondaryDark}; + background-color: ${vscQuickInputBackground}; /* backdrop-filter: blur(12px); */ `; @@ -106,7 +107,8 @@ const ItemDiv = styled.div` cursor: pointer; &.is-selected { - background-color: ${buttonColor}33; + background-color: ${vscListActiveBackground}; + color: ${vscListActiveForeground}; } `; @@ -292,7 +294,7 @@ const MentionList = forwardRef((props: MentionListProps, ref) => { ` color: ${(props) => (props.link ? "#ff4343" : "#f78383")}; word-wrap: break-word; border-radius: ${defaultBorderRadius}; - background-color: ${secondaryDark}; + background-color: ${vscInputBackground}; ${(props) => props.link && "cursor: pointer;"} &:hover { diff --git a/gui/src/components/modelSelection/ModelCard.tsx b/gui/src/components/modelSelection/ModelCard.tsx index f16c95885..271c51748 100644 --- a/gui/src/components/modelSelection/ModelCard.tsx +++ b/gui/src/components/modelSelection/ModelCard.tsx @@ -1,7 +1,12 @@ import { BookOpenIcon } from "@heroicons/react/24/outline"; import React, { useEffect, useState } from "react"; import styled from "styled-components"; -import { buttonColor, defaultBorderRadius, lightGray } from ".."; +import { + defaultBorderRadius, + greenButtonColor, + lightGray, + vscFocusBorder, +} from ".."; import { MODEL_PROVIDER_TAG_COLORS, PROVIDER_INFO, @@ -56,13 +61,13 @@ const DimensionOptionDiv = styled.div<{ selected: boolean }>` ${(props) => props.selected && ` - background-color: ${buttonColor}; + background-color: ${greenButtonColor}; color: white; `} &:hover { cursor: pointer; - outline: 1px solid ${buttonColor}; + outline: 1px solid ${vscFocusBorder}; } `; @@ -104,7 +109,7 @@ function ModelCard(props: ModelCardProps) { return (
{ diff --git a/gui/src/components/modelSelection/ModelSelect.tsx b/gui/src/components/modelSelection/ModelSelect.tsx index c6cb9ffd3..1d164ea6f 100644 --- a/gui/src/components/modelSelection/ModelSelect.tsx +++ b/gui/src/components/modelSelection/ModelSelect.tsx @@ -10,12 +10,13 @@ import { useDispatch, useSelector } from "react-redux"; import { useNavigate } from "react-router-dom"; import styled from "styled-components"; import { - buttonColor, defaultBorderRadius, lightGray, - secondaryDark, vscBackground, vscForeground, + vscInputBackground, + vscListActiveBackground, + vscListActiveForeground, } from ".."; import { defaultModelSelector } from "../../redux/selectors/modelSelectors"; import { setDefaultModel } from "../../redux/slices/stateSlice"; @@ -47,7 +48,7 @@ const Select = styled.select` outline: none; } &:hover { - background-color: ${secondaryDark}; + background-color: ${vscInputBackground}; } `; @@ -60,7 +61,7 @@ const StyledPlusIcon = styled(PlusIcon)` height: 100%; &:hover { - background-color: ${secondaryDark}; + background-color: ${vscInputBackground}; } border-left: 0.5px solid ${lightGray}; `; @@ -73,7 +74,7 @@ const NewProviderDiv = styled.div` border-top: 0.5px solid ${lightGray}; &:hover { - background-color: ${secondaryDark}; + background-color: ${vscInputBackground}; } `; @@ -109,12 +110,12 @@ const StyledListboxButton = styled(Listbox.Button)` } &:hover { - background-color: ${secondaryDark}; + background-color: ${vscInputBackground}; } `; const StyledListboxOptions = styled(Listbox.Options)` - background-color: ${secondaryDark}; + background-color: ${vscInputBackground}; padding: 0; position: absolute; @@ -127,12 +128,13 @@ const StyledListboxOptions = styled(Listbox.Options)` const StyledListboxOption = styled(Listbox.Option)<{ selected: boolean }>` background-color: ${({ selected }) => - selected ? `${buttonColor}88` : secondaryDark}; + selected ? vscListActiveBackground : vscInputBackground}; cursor: pointer; padding: 6px 8px; &:hover { - background-color: ${buttonColor}44; + background-color: ${vscListActiveBackground}; + color: ${vscListActiveForeground}; } `; @@ -175,7 +177,7 @@ function ListBoxOption({ e.stopPropagation(); e.preventDefault(); }} - style={{ backgroundColor: secondaryDark }} + style={{ backgroundColor: vscInputBackground }} className="absolute right-0 p-1" > diff --git a/gui/src/components/modelSelection/Toggle.tsx b/gui/src/components/modelSelection/Toggle.tsx index 4a1d3c930..0507305ab 100644 --- a/gui/src/components/modelSelection/Toggle.tsx +++ b/gui/src/components/modelSelection/Toggle.tsx @@ -1,6 +1,11 @@ -import React from "react"; import styled from "styled-components"; -import { buttonColor, defaultBorderRadius, lightGray, secondaryDark } from ".."; +import { + defaultBorderRadius, + lightGray, + vscInputBackground, + vscListActiveBackground, + vscListActiveForeground, +} from ".."; const TopDiv = styled.div` display: flex; @@ -12,7 +17,7 @@ const TopDiv = styled.div` border: 1px solid ${lightGray}; - background-color: ${secondaryDark}; + background-color: ${vscInputBackground}; border-radius: ${defaultBorderRadius}; &:hover { @@ -30,8 +35,9 @@ const SubDiv = styled.div<{ selected: boolean }>` ${(props) => props.selected && ` - background-color: ${buttonColor}77; + background-color: ${vscListActiveBackground}; box-shadow: 0px 0px 8px 0px ${lightGray}88; + color: ${vscListActiveForeground}; `} `; diff --git a/gui/src/pages/help.tsx b/gui/src/pages/help.tsx index 15a027283..1b36afe5a 100644 --- a/gui/src/pages/help.tsx +++ b/gui/src/pages/help.tsx @@ -1,13 +1,8 @@ -import { useNavigate } from "react-router-dom"; import { ArrowLeftIcon } from "@heroicons/react/24/outline"; -import KeyboardShortcutsDialog from "../components/dialogs/KeyboardShortcuts"; -import { - buttonColor, - lightGray, - vscBackground, - vscForeground, -} from "../components"; +import { useNavigate } from "react-router-dom"; import styled from "styled-components"; +import { lightGray, vscBackground, vscForeground } from "../components"; +import KeyboardShortcutsDialog from "../components/dialogs/KeyboardShortcuts"; const IconDiv = styled.div<{ backgroundColor?: string }>` display: flex; @@ -60,7 +55,7 @@ function HelpPage() { - + { @@ -33,7 +33,7 @@ const SectionHeader = styled.tr` padding: 4px; padding-left: 16px; padding-right: 16px; - background-color: ${secondaryDark}; + background-color: ${vscInputBackground}; width: 100%; font-weight: bold; text-align: center; diff --git a/gui/src/pages/monaco.tsx b/gui/src/pages/monaco.tsx index 9dd75c998..1bddac4ec 100644 --- a/gui/src/pages/monaco.tsx +++ b/gui/src/pages/monaco.tsx @@ -1,10 +1,10 @@ -import React, { useEffect } from "react"; -import Editor, { DiffEditor } from "@monaco-editor/react"; -import { postToIde } from "../util/ide"; -import { v4 } from "uuid"; -import { secondaryDark } from "../components"; -import HeaderButtonWithText from "../components/HeaderButtonWithText"; import { CheckIcon, XMarkIcon } from "@heroicons/react/24/outline"; +import { DiffEditor } from "@monaco-editor/react"; +import React, { useEffect } from "react"; +import { v4 } from "uuid"; +import { vscInputBackground } from "../components"; +import HeaderButtonWithText from "../components/HeaderButtonWithText"; +import { postToIde } from "../util/ide"; interface EditorFrameProps { filename: string; @@ -40,7 +40,7 @@ function EditorFrame(props: EditorFrameProps) {