vscode theme updates

This commit is contained in:
Dallin Romney 2025-05-20 20:53:20 -07:00
parent d19b3e9eec
commit ade64a5cf9
20 changed files with 573 additions and 209 deletions

View file

@ -1,12 +1,12 @@
{
"name": "continue",
"version": "1.1.36",
"version": "1.1.37",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "continue",
"version": "1.1.36",
"version": "1.1.37",
"license": "Apache-2.0",
"dependencies": {
"@continuedev/config-types": "^1.0.14",

View file

@ -9,6 +9,7 @@ import ErrorPage from "./pages/error";
import Chat from "./pages/gui";
import History from "./pages/history";
import Stats from "./pages/stats";
import ThemePage from "./styles/ThemePage";
import { ROUTES } from "./util/navigation";
const router = createMemoryRouter([
@ -37,6 +38,10 @@ const router = createMemoryRouter([
path: ROUTES.CONFIG,
element: <ConfigPage />,
},
{
path: ROUTES.THEME,
element: <ThemePage />,
},
],
},
]);

View file

@ -44,14 +44,7 @@ function SymbolLink({ symbol, content }: SymbolLinkProps) {
data-tooltip-id={id}
data-tooltip-delay-show={500}
>
<code
className="align-middle"
style={{
color: "var(--vscode-textLink-foreground)",
}}
>
{content}
</code>
<code className="text-link align-middle">{content}</code>
</span>
<ToolTip id={id} place="top" className="m-0 p-0">
<pre className="text-left">{processedContent ?? symbol.filepath}</pre>

View file

@ -13,13 +13,25 @@ import {
} from "../../redux/slices/tabsSlice";
import { AppDispatch, RootState } from "../../redux/store";
import { loadSession, saveCurrentSession } from "../../redux/thunks/session";
import { varWithFallback } from "../../styles/theme";
// Haven't set up theme colors for tabs yet
// Will keep it simple and choose from existing ones. Comments show vars we could use
const tabBorderVar = varWithFallback("border"); // --vscode-tab-border
const tabBackgroundVar = varWithFallback("background"); // --vscode-tab-inactiveBackground
const tabForegroundVar = varWithFallback("foreground"); // --vscode-tab-inactiveForeground
const tabHoverBackgroundVar = varWithFallback("list-hover"); // --vscode-tab-hoverBackground
const tabHoverForegroundVar = varWithFallback("foreground"); // --vscode-tab-hoverForeground
const tabSelectedBackgroundVar = varWithFallback("list-hover"); // --vscode-tab-activeBackground
const tabSelectedForegroundVar = varWithFallback("list-active-foreground"); // --vscode-tab-activeForeground
const tabAccentVar = varWithFallback("accent"); // --vscode-tab-activeBorderTop
const TabBarContainer = styled.div`
display: flex;
flex-wrap: wrap;
flex-shrink: 0;
flex-grow: 0;
background-color: var(--vscode-tab-inactiveBackground);
background-color: ${tabBackgroundVar};
border-bottom: none;
position: relative;
margin-top: 2px;
@ -41,24 +53,18 @@ const Tab = styled.div<{ isActive: boolean }>`
max-width: 150px;
height: 25px;
background-color: ${(props) =>
props.isActive
? "var(--vscode-tab-activeBackground)"
: "var(--vscode-tab-inactiveBackground)"};
props.isActive ? tabSelectedBackgroundVar : tabBackgroundVar};
color: ${(props) =>
props.isActive
? "var(--vscode-tab-activeForeground)"
: "var(--vscode-tab-inactiveForeground)"};
props.isActive ? tabSelectedForegroundVar : tabForegroundVar};
cursor: pointer;
border: 1px solid var(--vscode-tab-border);
border: 1px solid ${tabBorderVar};
border-bottom: ${(props) =>
props.isActive ? "none" : `1px solid var(--vscode-tab-border)`};
props.isActive ? "none" : `1px solid ${tabBorderVar}`};
user-select: none;
position: relative;
transition: background-color 0.2s;
border-top: ${(props) =>
props.isActive
? `1px solid var(--vscode-tab-activeBorderTop, --vscode-tab-border)`
: `1px solid var(--vscode-tab-border)`};
props.isActive ? `1px solid ${tabAccentVar}` : `1px solid ${tabBorderVar}`};
&:first-child {
border-left: none;
}
@ -68,13 +74,9 @@ const Tab = styled.div<{ isActive: boolean }>`
&:hover {
background-color: ${(props) =>
props.isActive
? "var(--vscode-tab-activeBackground)"
: "var(--vscode-tab-hoverBackground)"};
props.isActive ? tabSelectedBackgroundVar : tabHoverBackgroundVar};
color: ${(props) =>
props.isActive
? "var(--vscode-tab-activeForeground)"
: "var(--vscode-tab-hoverForeground)"};
props.isActive ? tabSelectedForegroundVar : tabHoverForegroundVar};
}
`;
@ -104,7 +106,7 @@ const CloseButton = styled.button`
&:hover {
opacity: 1;
background-color: var(--vscode-tab-hoverBackground);
background-color: ${tabHoverBackgroundVar};
}
${Tab}:hover & {
@ -119,33 +121,12 @@ const CloseButton = styled.button`
const TabBarSpace = styled.div`
flex: 1;
display: flex;
border-bottom: 1px solid var(--vscode-tab-border);
background-color: var(--vscode-tab-inactiveBackground);
`;
const NewTabButton = styled.button`
display: flex;
align-items: center;
justify-content: center;
width: 35px;
height: 100%;
border: none;
background: transparent;
color: var(--vscode-tab-inactiveForeground);
cursor: pointer;
opacity: 0.7;
transition: opacity 0.2s;
&:hover {
opacity: 1;
background-color: var(--vscode-tab-hoverBackground);
color: var(--vscode-tab-hoverForeground);
}
border-bottom: 1px solid ${tabBorderVar};
background-color: ${tabBackgroundVar};
`;
export function TabBar() {
const dispatch = useDispatch<AppDispatch>();
const currentSession = useSelector((state: RootState) => state.session);
const currentSessionId = useSelector((state: RootState) => state.session.id);
const currentSessionTitle = useSelector(
(state: RootState) => state.session.title,

View file

@ -4,12 +4,12 @@ import ReactMarkdown from "react-markdown";
import styled from "styled-components";
import {
CloseButton,
VSC_BACKGROUND_VAR,
defaultBorderRadius,
parseColorForHex,
vscBackground,
vscForeground,
} from "..";
import { THEME_COLORS } from "../../styles/theme";
import { parseColorForHex } from "../../styles/utils";
interface TextDialogProps {
showDialog: boolean;
@ -22,7 +22,7 @@ const ScreenCover = styled.div`
position: fixed;
width: 100%;
height: 100%;
background-color: ${parseColorForHex(VSC_BACKGROUND_VAR)}aa;
background-color: ${parseColorForHex(THEME_COLORS["background"].var)}aa;
z-index: 100000;
flex-direction: column;
`;

View file

@ -12,8 +12,8 @@ import {
useState,
} from "react";
import { HeaderButton, Input } from "..";
import HeaderButtonWithToolTip from "../gui/HeaderButtonWithToolTip";
import { useAppSelector } from "../../redux/hooks";
import HeaderButtonWithToolTip from "../gui/HeaderButtonWithToolTip";
interface SearchMatch {
index: number;
@ -41,7 +41,7 @@ const HighlightOverlay = (props: HighlightOverlayProps) => {
const { isCurrent, top, left, width, height } = props;
return (
<div
className={isCurrent ? "bg-find-match-selected" : "bg-blue-200/30"} // bg-vsc-find-match can"t get to work
className={isCurrent ? "bg-findMatch-selected" : "bg-findMatch"}
key={`highlight-${top}-${left}`}
style={{
position: "absolute",

View file

@ -39,7 +39,7 @@ function Alert({ children, type = "info" }: AlertProps) {
const { Icon } = ALERT_CONFIGS[type];
return (
<div className="rounded-lg border-l-4 bg-[color:var(--vscode-editor-foreground)] p-4 opacity-70 shadow-none">
<div className="bg-editor-foreground rounded-lg border-l-4 p-4 opacity-70 shadow-none">
<div className="flex items-start">
<Icon
className="h-6 min-h-5 w-6 min-w-5"

View file

@ -1,114 +1,31 @@
import styled from "styled-components";
import { getFontSize } from "../util";
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_BUTTON_FOREGROUND_VAR = "--vscode-button-foreground";
export const VSC_EDITOR_BACKGROUND_VAR = "--vscode-editor-background";
export const VSC_LIST_SELECTION_BACKGROUND_VAR =
"--vscode-list-activeSelectionBackground";
export const VSC_FOCUS_BORDER_VAR = "--vscode-focusBorder";
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_BADGE_BACKGROUND_VAR = "--vscode-badge-background";
export const VSC_BADGE_FOREGROUND_VAR = "--vscode-badge-foreground";
export const VSC_COMMAND_CENTER_ACTIVE_BORDER_VAR =
"--vscode-commandCenter-activeBorder";
export const VSC_COMMAND_CENTER_INACTIVE_BORDER_VAR =
"--vscode-commandCenter-inactiveBorder";
export const VSC_FIND_MATCH_SELECTED_VAR =
"--vscode-editor-findMatchHighlightBackground";
export const VSC_THEME_COLOR_VARS = [
VSC_INPUT_BACKGROUND_VAR,
VSC_BACKGROUND_VAR,
VSC_FOREGROUND_VAR,
VSC_BUTTON_BACKGROUND_VAR,
VSC_BUTTON_FOREGROUND_VAR,
VSC_EDITOR_BACKGROUND_VAR,
VSC_LIST_SELECTION_BACKGROUND_VAR,
VSC_FOCUS_BORDER_VAR,
VSC_LIST_ACTIVE_FOREGROUND_VAR,
VSC_QUICK_INPUT_BACKGROUND_VAR,
VSC_INPUT_BORDER_VAR,
VSC_BADGE_BACKGROUND_VAR,
VSC_BADGE_FOREGROUND_VAR,
VSC_COMMAND_CENTER_ACTIVE_BORDER_VAR,
VSC_COMMAND_CENTER_INACTIVE_BORDER_VAR,
VSC_FIND_MATCH_SELECTED_VAR,
];
import { varWithFallback } from "../styles/theme";
// DEPRECATED - avoid using these where possible, use tailwind classes instead
export const defaultBorderRadius = "5px";
export const lightGray = "#999998";
export const greenButtonColor = "#189e72";
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 vscButtonForeground = `var(${VSC_BUTTON_FOREGROUND_VAR}, #ffffff)`;
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_VAR}, #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_FOCUS_BORDER_VAR}, ${lightGray})`;
export const vscBadgeBackground = `var(${VSC_BADGE_BACKGROUND_VAR}, #1bbe84)`;
export const vscBadgeForeground = `var(${VSC_BADGE_FOREGROUND_VAR}, #ffffff)`;
export const vscCommandCenterActiveBorder = `var(${VSC_COMMAND_CENTER_ACTIVE_BORDER_VAR}, #1bbe84)`;
export const vscCommandCenterInactiveBorder = `var(${VSC_COMMAND_CENTER_INACTIVE_BORDER_VAR}, #1bbe84)`;
export const vscFindMatchSelected = `var(${VSC_FIND_MATCH_SELECTED_VAR}, rgba(255, 223, 0))`;
export function parseHexColor(hexColor: string): {
r: number;
g: number;
b: number;
} {
if (hexColor.startsWith("#")) {
hexColor = hexColor.slice(1);
}
if (hexColor.length > 6) {
hexColor = hexColor.slice(0, 6);
}
const r = parseInt(hexColor.substring(0, 2), 16);
const g = parseInt(hexColor.substring(2, 4), 16);
const b = parseInt(hexColor.substring(4, 6), 16);
return { r, g, b };
}
export function parseColorForHex(colorVar: string): string {
const value = getComputedStyle(document.documentElement).getPropertyValue(
colorVar,
);
if (value.startsWith("#")) {
return value.slice(0, 7);
}
// Parse rgb/rgba
const rgbValues = value
.slice(value.startsWith("rgba") ? 5 : 4, -1)
.split(",")
.map((x) => x.trim())
.filter((_, i) => i < 3) // Only take the first 3 values (RGB, ignore alpha)
.map((x) => parseInt(x, 10));
let hex =
"#" +
rgbValues
.map((x) => x.toString(16))
.map((x) => (x.length === 1 ? "0" + x : x))
.join("");
return hex;
}
export const vscInputBackground = varWithFallback("input-background");
export const vscQuickInputBackground = varWithFallback("input-background");
export const vscBackground = varWithFallback("background");
export const vscForeground = varWithFallback("foreground");
export const vscButtonBackground = varWithFallback("primary-background");
export const vscButtonForeground = varWithFallback("primary-foreground");
export const vscEditorBackground = varWithFallback("editor");
export const vscListActiveBackground = varWithFallback("list-active");
export const vscFocusBorder = varWithFallback("border-focus");
export const vscListActiveForeground = varWithFallback(
"list-active-foreground",
);
export const vscInputBorder = varWithFallback("input-border");
export const vscInputBorderFocus = varWithFallback("border-focus");
export const vscBadgeBackground = varWithFallback("badge");
export const vscBadgeForeground = varWithFallback("badge-foreground");
export const vscCommandCenterActiveBorder = varWithFallback(
"command-border-focus",
);
export const vscCommandCenterInactiveBorder = varWithFallback("command-border");
export const Button = styled.button`
padding: 6px 12px;
@ -226,10 +143,6 @@ export const Input = styled.input`
}
`;
export const Label = styled.label<{ fontSize?: number }>`
font-size: ${(props) => props.fontSize || getFontSize()}px;
`;
export const HeaderButton = styled.button<{
inverted: boolean | undefined;
backgroundColor?: string;

View file

@ -159,7 +159,7 @@ export function ExpandableToolbarPreview(props: ExpandableToolbarPreviewProps) {
contentEditable={false}
>
<div
className="border-b-vsc-commandCenter-inactiveBorder m-0 flex cursor-pointer items-center justify-between break-all border-0 border-b-[1px] border-solid px-[5px] py-1.5 hover:opacity-90"
className="border-b-command-border m-0 flex cursor-pointer items-center justify-between break-all border-0 border-b-[1px] border-solid px-[5px] py-1.5 hover:opacity-90"
style={{
fontSize: getFontSize() - 3,
}}

View file

@ -146,7 +146,7 @@ export function Option({
<StyledExclamationTriangleIcon
data-tooltip-id={`${idx}-errors-tooltip`}
$hovered={hovered}
className="cursor-pointer text-red-500"
className="text-error cursor-pointer"
onClick={onClickError}
/>
<ToolTip id={`${idx}-errors-tooltip`}>

View file

@ -1,6 +1,6 @@
import { createContext, useContext, useState } from "react";
import { parseHexColor } from "../components";
import { useWebviewListener } from "../hooks/useWebviewListener";
import { parseHexColor } from "../styles/utils";
const hljsToTextMate: Record<string, string[]> = {
".hljs-comment": ["comment"],

View file

@ -1,5 +1,4 @@
import { useCallback, useContext, useEffect, useRef } from "react";
import { VSC_THEME_COLOR_VARS } from "../components";
import { IdeMessengerContext } from "../context/IdeMessenger";
import { EDIT_MODE_STREAM_ID } from "core/edit/constants";
@ -29,6 +28,7 @@ import { cancelStream } from "../redux/thunks/cancelStream";
import { refreshSessionMetadata } from "../redux/thunks/session";
import { streamResponseThunk } from "../redux/thunks/streamResponse";
import { updateFileSymbolsFromHistory } from "../redux/thunks/updateFileSymbols";
import { THEME_COLORS } from "../styles/theme";
import { isJetBrains } from "../util";
import { setLocalStorage } from "../util/localStorage";
import { useWebviewListener } from "./useWebviewListener";
@ -139,20 +139,21 @@ function ParallelListeners() {
dispatch(cancelStream());
const jetbrains = isJetBrains();
for (const colorVar of VSC_THEME_COLOR_VARS) {
for (const [colorName, themeVals] of Object.entries(THEME_COLORS)) {
const cssVarName = themeVals.var;
if (jetbrains) {
const cached = localStorage.getItem(colorVar);
const cached = localStorage.getItem(colorName);
if (cached) {
document.body.style.setProperty(colorVar, cached);
document.body.style.setProperty(cssVarName, cached);
}
}
// Remove alpha channel from colors
const value = getComputedStyle(document.documentElement).getPropertyValue(
colorVar,
cssVarName,
);
if (colorVar.startsWith("#") && value.length > 7) {
document.body.style.setProperty(colorVar, value.slice(0, 7));
if (value.startsWith("#") && value.length > 7) {
document.body.style.setProperty(cssVarName, value.slice(0, 7));
}
}
@ -160,9 +161,11 @@ function ParallelListeners() {
// Save theme colors to local storage for immediate loading in JetBrains
ideMessenger.request("jetbrains/getColors", undefined).then((result) => {
if (result.status === "success") {
Object.entries(result.content).forEach(([key, value]) => {
document.body.style.setProperty(key, value);
document.documentElement.style.setProperty(key, value);
Object.entries(result.content).forEach(([colorName, value]) => {
const cssVarName =
THEME_COLORS[colorName as keyof typeof THEME_COLORS]?.var;
document.body.style.setProperty(cssVarName, value);
document.documentElement.style.setProperty(cssVarName, value);
});
}
});
@ -181,12 +184,10 @@ function ParallelListeners() {
(window as any).vscMediaUrl = msg.vscMediaUrl;
});
for (const colorVar of VSC_THEME_COLOR_VARS) {
if (document.body.style.getPropertyValue(colorVar)) {
localStorage.setItem(
colorVar,
document.body.style.getPropertyValue(colorVar),
);
for (const [colorName, themeVals] of Object.entries(THEME_COLORS)) {
const currentVal = document.body.style.getPropertyValue(themeVals.var);
if (currentVal) {
localStorage.setItem(colorName, currentVal);
}
}
}
@ -196,8 +197,9 @@ function ParallelListeners() {
"jetbrains/setColors",
async (data) => {
Object.entries(data).forEach(([key, value]) => {
document.body.style.setProperty(key, value);
document.documentElement.style.setProperty(key, value);
const cssVarName = THEME_COLORS[key as keyof typeof THEME_COLORS]?.var;
document.body.style.setProperty(cssVarName, value);
document.documentElement.style.setProperty(cssVarName, value);
});
},
[],

View file

@ -25,7 +25,7 @@ body,
#root {
height: 100%;
line-height: 1.3;
background-color: var(--vscode-editor-background);
background-color: var(--vscode-sideBar-background);
font-family:
system-ui,
-apple-system,
@ -42,7 +42,7 @@ body,
body {
padding: 0;
color: var(--vscode-editor-foreground);
color: var(--vscode-sideBar-foreground);
padding: 0px;
margin: 0px;
height: 100%;

View file

@ -1,6 +1,7 @@
import {
ArrowTopRightOnSquareIcon,
DocumentArrowUpIcon,
PaintBrushIcon,
TableCellsIcon,
} from "@heroicons/react/24/outline";
import { useContext } from "react";
@ -9,6 +10,7 @@ import { IdeMessengerContext } from "../../context/IdeMessenger";
import { useAppDispatch } from "../../redux/hooks";
import { setOnboardingCard } from "../../redux/slices/uiSlice";
import { saveCurrentSession } from "../../redux/thunks/session";
import { ROUTES } from "../../util/navigation";
import MoreHelpRow from "./MoreHelpRow";
export function HelpCenterSection() {
@ -83,6 +85,16 @@ export function HelpCenterSection() {
ideMessenger.post("showTutorial", undefined);
}}
/>
{process.env.NODE_ENV === "development" && (
<MoreHelpRow
title="Theme Test Page"
description="Development page for testing themes"
Icon={PaintBrushIcon}
onClick={async () => {
navigate(ROUTES.THEME);
}}
/>
)}
</div>
</div>
);

View file

@ -11,7 +11,7 @@ interface KeyboardShortcutProps {
function KeyboardShortcut(props: KeyboardShortcutProps) {
return (
<div
className={`flex flex-col items-start p-2 py-2 sm:flex-row sm:items-center ${props.isEven ? "" : "bg-table-odd-rows"}`}
className={`flex flex-col items-start p-2 py-2 sm:flex-row sm:items-center ${props.isEven ? "" : "bg-table-oddRow"}`}
>
<div className="w-full flex-grow pb-1 pr-4 sm:w-auto sm:pb-0">
<span className="block break-words text-xs">{props.description}:</span>

View file

@ -0,0 +1,136 @@
import {
CheckCircleIcon,
ExclamationCircleIcon,
ExclamationTriangleIcon,
} from "@heroicons/react/24/outline";
import { useState } from "react";
import { useNavigate } from "react-router-dom";
import { THEME_COLORS } from "./theme";
const ThemeTailwindClassExample = ({
className,
varName,
defaultColor,
}: {
className: string;
varName: string;
defaultColor: string;
}) => {
return (
<>
<div className={`line-clamp-1 break-all px-2 text-right`}>
{className}
</div>
<div
className={`line-clamp-1 break-all p-1 text-[9px]`}
style={{
backgroundColor: `var(${varName})`,
}}
>
{varName}
</div>
<div
className={`line-clamp-1 break-all p-1 text-[9px]`}
style={{
backgroundColor: defaultColor,
}}
>
{defaultColor}
</div>
</>
);
};
function ThemePage() {
const navigate = useNavigate();
const [listToggled, setListToggled] = useState(false);
return (
<div className="flex flex-1 flex-col gap-3 px-2 py-2">
<span
className="flex cursor-pointer flex-row items-center gap-2"
onClick={() => navigate("/more")}
>
<span className="">←</span>
Back to Settings
</span>
<div className="bg-background border-border grid grid-cols-1 gap-4 rounded-md border border-solid p-4 md:grid-cols-2">
<div className="col-span-2 flex gap-4">
<p className="">Normal text</p>
<p className="text-description">Description text</p>
<p className="text-description-muted">Muted text</p>
</div>
<button className="bg-primary text-primary-foreground hover:bg-primary-hover cursor-pointer rounded border-none px-4 py-2 disabled:cursor-not-allowed disabled:brightness-75">
Primary Button
</button>
<button className="bg-secondary text-secondary-foreground hover:bg-secondary-hover cursor-pointer rounded border-none px-4 py-2 disabled:cursor-not-allowed disabled:brightness-75">
Secondary Button
</button>
<div className="border-border rounded-md border border-solid p-3">
Normal border
</div>
<div className="border-border-focus rounded-md border border-solid p-3">
Focus border
</div>
<input
className="bg-input text-input-foreground border-input-border focus:border-border-focus active:border-border-focus active:ring-border-focus placeholder:text-input-placeholder focus:bg-input-focus focus:text-input-focus-foreground rounded-md border border-solid p-2 focus:ring-0"
placeholder="Input example"
/>
<div className="bg-badge text-badge-foreground border-border inline-block rounded-full border border-solid p-2">
<span className="px-2">Badge</span>
</div>
<div className="flex gap-3">
<div className="flex items-center gap-2">
<CheckCircleIcon className="text-success h-4 w-4" />
<span className="text-success">Success</span>
</div>
<div className="flex items-center gap-2">
<ExclamationCircleIcon className="text-warning h-4 w-4" />
<span className="text-warning">Warning</span>
</div>
<div className="flex items-center gap-2">
<ExclamationTriangleIcon className="text-error h-4 w-4" />
<span className="text-error">Error</span>
</div>
</div>
<div
onClick={() => setListToggled(!listToggled)}
className={`cursor-pointer p-2 ${listToggled ? "bg-list-active text-list-active-foreground" : "bg-background text-foreground hover:bg-list-hover"}`}
>
List item (click to select)
</div>
<div className="bg-editor text-editor-foreground border-border rounded-sm border border-solid p-2">
<span>Editor</span>
</div>
</div>
<h2 className="mb-2 mt-6 text-xl font-semibold">All Theme Colors</h2>
<div className="grid grid-cols-3">
<div className="p-1">
<span className="font-bold">Tailwind Class</span>
</div>
<div className="p-1">
<span className="font-bold">CSS Var</span>
</div>
<div className="p-1">
<span className="font-bold">Fallback</span>
</div>
{Object.entries(THEME_COLORS).map(([key, val]) => (
<ThemeTailwindClassExample
key={key}
className={key}
defaultColor={val.default}
varName={val.var}
/>
))}
</div>
</div>
);
}
export default ThemePage;

225
gui/src/styles/theme.ts Normal file
View file

@ -0,0 +1,225 @@
// All vscode variables https://gist.github.com/estruyf/ba49203e1a7d6868e9320a4ea480c27a
// Examples for vscode https://github.com/githubocto/tailwind-vscode/blob/main/index.js
export const THEME_COLORS = {
background: {
var: "--vscode-sideBar-background",
default: "#141c2d",
},
foreground: {
var: "--vscode-sideBar-foreground", // --vscode-editor-foreground
default: "rgba(243, 239, 245, 0.8)",
},
editor: {
var: "--vscode-editor-background",
default: "#0e131f",
},
"editor-foreground": {
var: "--vscode-editor-foreground",
default: "#f3eff5",
},
"primary-background": {
var: "--vscode-button-background",
default: "#1bbe84",
},
"primary-foreground": {
var: "--vscode-button-foreground",
default: "#ffffff",
},
"primary-hover": {
var: "--vscode-button-hoverBackground",
default: "#24dfe8",
},
secondary: {
var: "--vscode-button-secondaryBackground",
default: "rgba(243, 239, 245, 0.2)",
},
"secondary-foreground": {
var: "--vscode-button-secondaryForeground",
default: "#f3eff5",
},
"secondary-hover": {
var: "--vscode-button-secondaryHoverBackground",
default: "rgba(243, 239, 245, 0.2)",
},
border: {
// --vscode-panel-border
var: "--vscode-sideBar-border",
default: "#242d34",
},
"border-focus": {
var: "--vscode-focusBorder",
default: "#263354",
},
// Command styles are used for tip-tap editor
command: {
var: "--vscode-commandCenter-background",
default: "#141c2d",
},
"command-foreground": {
var: "--vscode-commandCenter-foreground",
default: "#f3eff5",
},
"command-border": {
var: "--vscode-commandCenter-inactiveBorder",
default: "#999998",
},
"command-border-focus": {
var: "--vscode-commandCenter-activeBorder",
default: "#ed1292",
},
description: {
var: "--vscode-descriptionForeground",
default: "rgba(243, 239, 245, 0.7)",
},
"description-muted": {
var: "--vscode-list-deemphasizedForeground",
default: "#8c8c8c",
},
"input-background": {
var: "--vscode-input-background",
default: "#0d1217",
},
"input-foreground": {
var: "--vscode-input-foreground",
default: "#f3eff5",
},
"input-border": {
var: "--vscode-input-border",
default: "#242d34",
},
"input-placeholder": {
var: "--vscode-input-placeholderForeground",
default: "rgba(243, 239, 245, 0.5)",
},
"table-oddRow": {
var: "--vscode-tree-tableOddRowsBackground",
default: "rgb(45, 45, 45)",
},
badge: {
var: "--vscode-badge-background",
default: "rgb(80, 80, 80)",
},
"badge-foreground": {
var: "--vscode-badge-foreground",
default: "#fff",
},
success: {
var: "--vscode-notebookStatusSuccessIcon-foreground", // "var(--vscode-testing-iconPassed, #1bbe84)" // --vscode-charts-green
default: "#1bbe84",
},
warning: {
var: "--vscode-editorWarning-foreground", // --vscode-list-warningForeground
default: "#ffe45e",
},
error: {
var: "--vscode-editorError-foreground", // --vscode-list-errorForeground
default: "#fe4a49",
},
link: {
var: "--vscode-textLink-foreground",
default: "#4da6ff",
},
accent: {
var: "--vscode-tab-activeBorderTop",
default: "#ed1292",
},
"find-match": {
var: "--vscode-editor-findMatchBackground", // Can't get "var(--vscode-editor-findMatchBackground, rgba(237, 18, 146, 0.5))" to work
default: "rgba(191, 219, 254, 0.3)",
},
"find-match-selected": {
var: "--vscode-editor-findMatchHighlightBackground",
default: "rgba(255, 223, 0, 0.3)",
},
"list-hover": {
var: "--vscode-list-hoverBackground",
default: "rgba(243, 239, 245, 0.13)",
},
"list-active": {
var: "--vscode-list-activeSelectionBackground",
default: "rgba(243, 239, 245, 0.2)",
},
"list-active-foreground": {
var: "--vscode-list-activeSelectionForeground",
default: "#f3eff5",
},
};
// Consider defaults
// 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 vscButtonForeground = `var(${VSC_BUTTON_FOREGROUND_VAR}, #ffffff)`;
// 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_VAR}, #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_FOCUS_BORDER_VAR}, ${lightGray})`;
// export const vscBadgeBackground = `var(${VSC_BADGE_BACKGROUND_VAR}, #1bbe84)`;
// export const vscBadgeForeground = `var(${VSC_BADGE_FOREGROUND_VAR}, #ffffff)`;
// export const vscCommandCenterActiveBorder = `var(${VSC_COMMAND_CENTER_ACTIVE_BORDER_VAR}, #1bbe84)`;
// export const vscCommandCenterInactiveBorder = `var(${VSC_COMMAND_CENTER_INACTIVE_BORDER_VAR}, #1bbe84)`;
// export const vscFindMatchSelected = `var(${VSC_FIND_MATCH_SELECTED_VAR}, rgba(255, 223, 0))`;
// Fonts:
// --vscode - editor - font - family;
// --vscode - font - family;
// Current list of CSS variables needed (e.g. for jetbrains to send!)
// --vscode-sideBar-background
// --vscode-sideBar-foreground
// --vscode-editor-background
// --vscode-editor-foreground
// --vscode-button-background
// --vscode-button-foreground
// --vscode-button-secondaryBackground
// --vscode-button-secondaryForeground
// --vscode-sideBar-border
// --vscode-focusBorder
// --vscode-commandCenter-background
// --vscode-commandCenter-foreground
// --vscode-commandCenter-inactiveBorder
// --vscode-commandCenter-activeBorder
// --vscode-descriptionForeground
// --vscode-list-deemphasizedForeground
// --vscode-input-background
// --vscode-input-foreground
// --vscode-input-border
// --vscode-input-placeholderForeground
// --vscode-tree-tableOddRowsBackground
// --vscode-badge-background
// --vscode-badge-foreground
// --vscode-notebookStatusSuccessIcon-foreground
// --vscode-editorWarning-foreground
// --vscode-editorError-foreground
// --vscode-editor-findMatchBackground
// --vscode-editor-findMatchHighlightBackground
// --vscode-list-hoverBackground
// --vscode-list-activeSelectionBackground
// --vscode-list-activeSelectionForeground
export const THEME_CSS_VARS = Object.values(THEME_COLORS).map(
(value) => value.var,
);
export const THEME_CSS_VAR_DEFAULTS = Object.entries(THEME_COLORS).reduce(
(acc, [_, value]) => {
acc[value.var] = value.default;
return acc;
},
{} as Record<string, string>,
);
export const THEME_DEFAULTS = Object.entries(THEME_COLORS).reduce(
(acc, [key, value]) => {
acc[key] = value.default;
return acc;
},
{} as Record<string, string>,
);
export const varWithFallback = (className: keyof typeof THEME_COLORS) =>
`var(${THEME_COLORS[className].var}, ${THEME_COLORS[className].default})`;

45
gui/src/styles/utils.ts Normal file
View file

@ -0,0 +1,45 @@
export function parseHexColor(hexColor: string): {
r: number;
g: number;
b: number;
} {
if (hexColor.startsWith("#")) {
hexColor = hexColor.slice(1);
}
if (hexColor.length > 6) {
hexColor = hexColor.slice(0, 6);
}
const r = parseInt(hexColor.substring(0, 2), 16);
const g = parseInt(hexColor.substring(2, 4), 16);
const b = parseInt(hexColor.substring(4, 6), 16);
return { r, g, b };
}
export function parseColorForHex(colorVar: string): string {
const value = getComputedStyle(document.documentElement).getPropertyValue(
colorVar,
);
if (value.startsWith("#")) {
return value.slice(0, 7);
}
// Parse rgb/rgba
const rgbValues = value
.slice(value.startsWith("rgba") ? 5 : 4, -1)
.split(",")
.map((x) => x.trim())
.filter((_, i) => i < 3) // Only take the first 3 values (RGB, ignore alpha)
.map((x) => parseInt(x, 10));
let hex =
"#" +
rgbValues
.map((x) => x.toString(16))
.map((x) => (x.length === 1 ? "0" + x : x))
.join("");
return hex;
}

View file

@ -2,5 +2,6 @@
export const ROUTES = {
HOME: "/",
CONFIG: "/config",
THEME: "/theme",
// EXAMPLE_ROUTE_WITH_PARAMS: (params: ParamsType) => `/route/${params}`,
};

View file

@ -1,5 +1,6 @@
/** @type {import('tailwindcss').Config} */
const defaultTheme = require("tailwindcss/defaultTheme");
const { varWithFallback, THEME_COLORS } = require("./src/styles/theme");
module.exports = {
content: [
@ -29,25 +30,75 @@ module.exports = {
default: "5px",
},
colors: {
lightgray: "#999998",
"vsc-input-background": "var(--vscode-input-background, rgb(45 45 45))",
"vsc-background": "var(--vscode-sideBar-background, rgb(30 30 30))",
"vsc-foreground": "var(--vscode-editor-foreground, #fff)",
"vsc-editor-background":
"var(--vscode-editor-background, var(--vscode-sideBar-background, rgb(30 30 30)))",
"vsc-input-border": "var(--vscode-input-border, #999998)",
"vsc-commandCenter-inactiveBorder":
"var(--vscode-commandCenter-inactiveBorder, #999998)",
background: varWithFallback("background"),
foreground: varWithFallback("foreground"),
editor: {
DEFAULT: varWithFallback("editor"),
foreground: varWithFallback("editor-foreground"),
},
primary: {
DEFAULT: varWithFallback("primary-background"),
foreground: varWithFallback("primary-foreground"),
hover: varWithFallback("primary-hover"),
},
secondary: {
DEFAULT: varWithFallback("secondary"),
foreground: varWithFallback("secondary-foreground"),
hover: varWithFallback("secondary-hover"),
},
border: {
DEFAULT: varWithFallback("border"),
focus: varWithFallback("border-focus"),
},
command: {
DEFAULT: varWithFallback("command"),
foreground: varWithFallback("command-foreground"),
border: {
DEFAULT: varWithFallback("command-border"),
focus: varWithFallback("command-border-focus"),
},
},
description: {
DEFAULT: varWithFallback("description"),
muted: varWithFallback("description-muted"),
},
input: {
DEFAULT: varWithFallback("input-background"),
foreground: varWithFallback("input-foreground"),
border: varWithFallback("input-border"),
placeholder: varWithFallback("input-placeholder"),
},
table: {
oddRow: varWithFallback("table-oddRow"),
},
badge: {
DEFAULT: varWithFallback("badge"),
foreground: varWithFallback("badge-foreground"),
},
success: varWithFallback("success"),
warning: varWithFallback("warning"),
error: varWithFallback("error"),
link: varWithFallback("link"),
accent: varWithFallback("accent"),
findMatch: {
DEFAULT: THEME_COLORS["find-match"].default,
selected: varWithFallback("find-match-selected"),
},
list: {
hover: varWithFallback("list-hover"),
active: {
DEFAULT: varWithFallback("list-active"),
foreground: varWithFallback("list-active-foreground"),
},
},
// Starting to make things less vsc-specific
// TODO make it all non-IDE-specific naming
"find-match-selected":
"var(--vscode-editor-findMatchHighlightBackground, rgba(255, 223, 0))",
"table-odd-rows":"var(--vscode-tree-tableOddRowsBackground, #1bbe84)",
"list-active": "var(--vscode-list-activeSelectionBackground, #1bbe84)",
"list-active-foreground":
"var(--vscode-quickInputList-focusForeground, var(--vscode-editor-foreground))",
badge: "var(--vscode-badge-background, #1bbe84)",
// DEPRECATED, slowly remove usages of these ide-named or explicit colors
lightgray: "#999998", // use border, description, or description-muted instead
"vsc-input-background": varWithFallback("input-background"), // use "input-background" instead
"vsc-background": varWithFallback("background"), // use "background" instead
"vsc-foreground": varWithFallback("foreground"), // use "foreground" instead // NOTE - might want to use editor-foreground
"vsc-editor-background": varWithFallback("editor"), // use "editor" instead
"vsc-input-border": varWithFallback("input-border"), // use "input-border" instead
},
},
},