Elffuss BraidHub

kikocis/continue public

Merge pull request #6317 from continuedev/nate/clean-gui

Styled components to tailwind demo migration
Changeset826666adffd2ca4fb4473480017d59ccafb1333684b478676d7e253d9ddb580e
AuthorNate Sesti <33237525+sestinj@users.noreply.github.com> · 2025-07-03 19:06 -07:00
CommitterGitHub <noreply@github.com> · 2025-07-03 19:06 -07:00
Parentsc2565dc27945, c8c20a430667

Browse the files at this changeset

8 files changed

added .continue/rules/migrate-styled-components-to-tailwind.md +5 −0
@@ -0,0 +1,5 @@
1+---
2+alwaysApply: false
3+---
4+
5+Convert all of the styled components in this file into tailwind CSS. If a variable is used that is not already in @theme.ts and @tailwind.config.cjs, then you should figure out where it comes from and try adding that so it can be used. Wherever a function is called to interpolate a value, you can just use inline `styles={{ ... }}`. For ternaries, you could use @cn.ts.
modified gui/src/components/AssistantAndOrgListbox/shared.tsx +76 −31
@@ -6,11 +6,8 @@
66 } from "@heroicons/react/24/outline";
77 import { useState } from "react";
88 import styled from "styled-components";
9-import {
10- defaultBorderRadius,
11- lightGray,
12- vscCommandCenterInactiveBorder,
13-} from "..";
9+import { lightGray } from "..";
10+import { cn } from "../../util/cn";
1411 import { ToolTip } from "../gui/Tooltip";
1512
1613 export const OptionDiv = styled.div<{
@@ -47,11 +44,6 @@
4744
4845 export const MAX_HEIGHT_PX = 300;
4946
50-export const Divider = styled.div`
51- height: 0.5px;
52- background-color: ${vscCommandCenterInactiveBorder};
53-`;
54-
5547 interface ModelOptionProps {
5648 children: React.ReactNode;
5749 idx: number;
@@ -64,28 +56,81 @@
6456 onClickError?: (e: any) => void;
6557 }
6658
67-const IconBase = styled.div<{ $hovered: boolean }>`
68- width: 1.2em;
69- height: 1.2em;
70- cursor: pointer;
71- padding: 4px;
72- border-radius: ${defaultBorderRadius};
73- opacity: ${(props) => (props.$hovered ? 0.75 : 0)};
74- visibility: ${(props) => (props.$hovered ? "visible" : "hidden")};
75-
76- &:hover {
77- opacity: 1;
78- background-color: ${lightGray}33;
79- }
80-`;
59+interface IconBaseProps {
60+ $hovered: boolean;
61+ onClick?: (e: any) => void;
62+ className?: string;
63+ children?: React.ReactNode;
64+ [key: string]: any;
65+}
66+
67+function IconBase({
68+ $hovered,
69+ onClick,
70+ className,
71+ children,
72+ ...props
73+}: IconBaseProps) {
74+ return (
75+ <div
76+ className={cn(
77+ "rounded-default h-[1.2em] w-[1.2em] cursor-pointer p-1",
78+ $hovered ? "visible opacity-75" : "invisible opacity-0",
79+ "hover:bg-lightgray/20 hover:opacity-100",
80+ className,
81+ )}
82+ onClick={onClick}
83+ {...props}
84+ >
85+ {children}
86+ </div>
87+ );
88+}
8189
82-const StyledCog6ToothIcon = styled(IconBase).attrs({ as: Cog6ToothIcon })``;
83-const StyledArrowTopRightOnSquareIcon = styled(IconBase).attrs({
84- as: ArrowTopRightOnSquareIcon,
85-})``;
86-const StyledExclamationTriangleIcon = styled(IconBase).attrs({
87- as: ExclamationTriangleIcon,
88-})``;
90+const StyledCog6ToothIcon = ({
91+ $hovered,
92+ onClick,
93+}: {
94+ $hovered: boolean;
95+ onClick?: (e: any) => void;
96+}) => (
97+ <IconBase $hovered={$hovered} onClick={onClick}>
98+ <Cog6ToothIcon />
99+ </IconBase>
100+);
101+
102+const StyledArrowTopRightOnSquareIcon = ({
103+ $hovered,
104+ onClick,
105+}: {
106+ $hovered: boolean;
107+ onClick?: (e: any) => void;
108+}) => (
109+ <IconBase $hovered={$hovered} onClick={onClick}>
110+ <ArrowTopRightOnSquareIcon />
111+ </IconBase>
112+);
113+
114+const StyledExclamationTriangleIcon = ({
115+ $hovered,
116+ onClick,
117+ className,
118+ ...props
119+}: {
120+ $hovered: boolean;
121+ onClick?: (e: any) => void;
122+ className?: string;
123+ [key: string]: any;
124+}) => (
125+ <IconBase
126+ $hovered={$hovered}
127+ onClick={onClick}
128+ className={className}
129+ {...props}
130+ >
131+ <ExclamationTriangleIcon />
132+ </IconBase>
133+);
89134
90135 export function Option({
91136 children,
deleted gui/src/components/Footer.tsx +0 −21
@@ -1,21 +0,0 @@
1-import { useAppSelector } from "../redux/hooks";
2-import { selectSelectedChatModel } from "../redux/slices/configSlice";
3-
4-function Footer() {
5- const defaultModel = useAppSelector(selectSelectedChatModel);
6-
7- // TODO hook hub up to free trial
8- // if (defaultModel?.provider === "free-trial") {
9- // return (
10- // <footer className="flex flex-col border-0 border-t border-solid border-t-zinc-700 px-2 py-2">
11- // <FreeTrialProgressBar
12- // completed={getLocalStorage("ftc") ?? 0}
13- // total={FREE_TRIAL_LIMIT_REQUESTS}
14- // />
15- // </footer>
16- // );
17- // }
18- return null;
19-}
20-
21-export default Footer;
modified gui/src/components/Layout.tsx +0 −2
@@ -17,7 +17,6 @@
1717 import { ROUTES } from "../util/navigation";
1818 import { FatalErrorIndicator } from "./config/FatalErrorNotice";
1919 import TextDialog from "./dialogs";
20-import Footer from "./Footer";
2120 import { GenerateRuleDialog } from "./GenerateRuleDialog";
2221 import { LumpProvider } from "./mainInput/Lump/LumpContext";
2322 import { useMainEditor } from "./mainInput/TipTapEditor";
@@ -261,7 +260,6 @@
261260 <PostHogPageView />
262261 <Outlet />
263262 <FatalErrorIndicator />
264- <Footer />
265263 </GridDiv>
266264 </div>
267265 <div style={{ fontSize: fontSize(-4) }} id="tooltip-portal-div" />
modified gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/ToolbarButtonWithTooltip.tsx +6 −22
@@ -1,25 +1,7 @@
11 import { ReactNode, useMemo } from "react";
22 import { Tooltip } from "react-tooltip";
3-import styled from "styled-components";
4-import { lightGray, vscForeground } from "../..";
53 import { getFontSize } from "../../../util";
64
7-export const ToolbarButton = styled.button`
8- display: flex;
9- align-items: center;
10- border: none;
11- outline: none;
12- background: transparent;
13-
14- color: ${vscForeground};
15- font-size: ${getFontSize() - 2}px;
16-
17- &:hover {
18- cursor: pointer;
19- filter: brightness(1.25);
20- }
21-`;
22-
235 interface ToolbarButtonWithTooltipProps {
246 onClick: () => void;
257 children: ReactNode;
@@ -40,15 +22,17 @@
4022
4123 return (
4224 <>
43- <ToolbarButton
25+ <button
4426 onClick={onClick}
45- style={{ color: lightGray }}
27+ style={{
28+ fontSize: `${getFontSize() - 2}px`,
29+ }}
4630 data-tooltip-id={tooltipId}
4731 data-testid={testId}
48- className="px-0.5"
32+ className="text-foreground flex items-center border-none bg-transparent px-0.5 outline-none hover:cursor-pointer hover:brightness-125"
4933 >
5034 {children}
51- </ToolbarButton>
35+ </button>
5236 <Tooltip id={tooltipId} place="top">
5337 {tooltipContent}
5438 </Tooltip>
modified gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/index.tsx +8 −34
@@ -1,12 +1,6 @@
11 import { ChevronDownIcon } from "@heroicons/react/24/outline";
22 import { inferResolvedUriFromRelativePath } from "core/util/ideUtils";
33 import { useContext, useEffect, useMemo, useState } from "react";
4-import styled from "styled-components";
5-import {
6- defaultBorderRadius,
7- vscCommandCenterInactiveBorder,
8- vscEditorBackground,
9-} from "../..";
104 import { IdeMessengerContext } from "../../../context/IdeMessenger";
115 import { useIdeMessengerRequest } from "../../../hooks/useIdeMessengerRequest";
126 import { useWebviewListener } from "../../../hooks/useWebviewListener";
@@ -25,29 +19,6 @@
2519 import { InsertButton } from "./InsertButton";
2620 import { RunInTerminalButton } from "./RunInTerminalButton";
2721
28-const TopDiv = styled.div`
29- display: flex;
30- flex-direction: column;
31- outline: 1px solid ${vscCommandCenterInactiveBorder};
32- outline-offset: -0.5px;
33- border-radius: ${defaultBorderRadius};
34- margin-bottom: 8px !important;
35- margin-top: 8px !important;
36- background-color: ${vscEditorBackground};
37- min-width: 0;
38-`;
39-
40-const ToolbarDiv = styled.div<{ isExpanded: boolean }>`
41- display: flex;
42- justify-content: space-between;
43- align-items: center;
44- font-size: ${getFontSize() - 2}px;
45- padding: 4px 6px;
46- margin: 0;
47- border-bottom: ${({ isExpanded }) =>
48- isExpanded ? `1px solid ${vscCommandCenterInactiveBorder}` : "inherit"};
49-`;
50-
5122 export interface StepContainerPreToolbarProps {
5223 codeBlockContent: string;
5324 language: string | null;
@@ -290,9 +261,12 @@
290261 }
291262
292263 return (
293- <TopDiv>
294- <ToolbarDiv isExpanded={isExpanded} className="find-widget-skip gap-3">
295- <div className="max-w-[50% flex flex-row items-center">
264+ <div className="outline-command-border -outline-offset-0.5 rounded-default bg-editor mb-2 mt-2 flex min-w-0 flex-col outline outline-1">
265+ <div
266+ className={`find-widget-skip m-0 flex items-center justify-between gap-3 px-1.5 py-1 ${isExpanded ? "border-command-border border-b" : ""}`}
267+ style={{ fontSize: `${getFontSize() - 2}px` }}
268+ >
269+ <div className="flex max-w-[50%] flex-row items-center">
296270 <ChevronDownIcon
297271 data-testid="toggle-codeblock"
298272 onClick={() => setIsExpanded(!isExpanded)}
@@ -323,11 +297,11 @@
323297
324298 {renderActionButtons()}
325299 </div>
326- </ToolbarDiv>
300+ </div>
327301
328302 {isExpanded && (
329303 <div className="overflow-hidden overflow-y-auto">{children}</div>
330304 )}
331- </TopDiv>
305+ </div>
332306 );
333307 }
modified gui/src/util/cn.ts +14 −0
@@ -1,6 +1,20 @@
11 import { clsx, type ClassValue } from "clsx";
22 import { twMerge } from "tailwind-merge";
33
4+/**
5+ * Combines multiple class values and merges Tailwind CSS classes.
6+ *
7+ * This utility function combines the functionality of clsx (for conditional class names)
8+ * and tailwind-merge (for intelligently merging Tailwind CSS classes, removing duplicates
9+ * and conflicts).
10+ *
11+ * @param inputs - Class values that can be strings, objects, arrays, or conditional expressions
12+ * @returns A merged string of class names with Tailwind conflicts resolved
13+ *
14+ * @example
15+ * cn('px-2 py-1', 'px-4') // Returns 'py-1 px-4' (px-2 is overridden by px-4)
16+ * cn('text-red-500', { 'text-blue-500': isActive }) // Conditionally applies classes
17+ */
418 export function cn(...inputs: ClassValue[]) {
519 return twMerge(clsx(inputs));
620 }
modified gui/tailwind.config.cjs +3 −0
@@ -29,6 +29,9 @@
2929 borderRadius: {
3030 default: "0.5rem",
3131 },
32+ outlineOffset: {
33+ 0.5: "0.5px",
34+ },
3235 colors: {
3336 background: varWithFallback("background"),
3437 foreground: varWithFallback("foreground"),