Skip to content

Commit 61cf55a

Browse files
committed
refactor(web): move two more IconButtons to Opal Button
The send button only needed `iconClassName` for its loading spinner, and wrapping the icon component says the same thing — the pattern the file picker already uses. Nothing else about it was custom. The rename button sized itself with `h-6 w-6`, which is exactly what size="sm" gives (--height-line-label is 1.5rem). Its resting opacity moves to a wrapper, since that dims the button rather than restyling it. BaseInputBar keeps IconButton for its stop button, whose 1.5px border has no Opal equivalent.
1 parent fe9f91f commit 61cf55a

4 files changed

Lines changed: 24 additions & 21 deletions

File tree

web/src/refresh-components/tiles/FileTile.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import type { FunctionComponent } from "react";
22
import { Button } from "@opal/components";
3-
4-
import { noProp } from "@/lib/utils";
53
import { cn, clickOnKeyDown } from "@opal/utils";
64
import { SvgMaximize2, SvgTextLines, SvgX } from "@opal/icons";
75
import type { IconProps } from "@opal/types";
86
import { Hoverable } from "@opal/core";
7+
import { noProp } from "@/lib/utils";
98
import Text from "../texts/Text";
109
import Truncated from "../texts/Truncated";
1110

web/src/sections/actions/ActionCardHeader.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
"use client";
22

33
import React, { useState } from "react";
4+
import { Button } from "@opal/components";
45
import { cn } from "@opal/utils";
56
import { ActionStatus } from "@/lib/tools/types";
67
import Text from "@/refresh-components/texts/Text";
7-
import IconButton from "@/refresh-components/buttons/IconButton";
88
import ButtonRenaming from "@/refresh-components/buttons/ButtonRenaming";
99
import type { IconProps } from "@opal/types";
1010
import Truncated from "@/refresh-components/texts/Truncated";
@@ -116,16 +116,16 @@ function ActionCardHeader({
116116
)}
117117
{showRenameIcon && (
118118
<Hoverable.Item group="action-card" variant="appear-on-hover">
119-
{/* TODO(@raunakab): migrate to opal Button once className/iconClassName is resolved */}
120-
<IconButton
121-
icon={SvgEdit}
122-
tooltip="Rename"
123-
internal
124-
tertiary
125-
onClick={handleRenameClick}
126-
className="h-6 w-6 opacity-70 hover:opacity-100"
127-
aria-label={`Rename ${title}`}
128-
/>
119+
<div className="opacity-70 hover:opacity-100">
120+
<Button
121+
icon={SvgEdit}
122+
tooltip="Rename"
123+
prominence="tertiary"
124+
size="sm"
125+
onClick={handleRenameClick}
126+
aria-label={`Rename ${title}`}
127+
/>
128+
</div>
129129
</Hoverable.Item>
130130
)}
131131
</div>

web/src/sections/actions/OpenApiActionCard.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"use client";
22

3-
import React, { useCallback, useEffect, useMemo, useState } from "react";
4-
import { toast } from "@opal/layouts";
3+
import { useCallback, useEffect, useMemo, useState } from "react";
54
import ActionCard from "@/sections/actions/ActionCard";
65
import Actions from "@/sections/actions/Actions";
76
import ToolsList from "@/sections/actions/ToolsList";

web/src/sections/input/BaseInputBar.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import PasteTilePopover from "@/sections/input/PasteTilePopover";
1717
import { cn } from "@opal/utils";
1818
import { Disabled } from "@opal/core";
1919
import IconButton from "@/refresh-components/buttons/IconButton";
20-
import { Text } from "@opal/components";
20+
import { Button, Text } from "@opal/components";
2121
import { SvgArrowUp, SvgLoader, SvgStop } from "@opal/icons";
2222
import Keycap from "@/refresh-components/Keycap";
2323
import { useContentEditable } from "@/hooks/useContentEditable";
@@ -368,8 +368,16 @@ const BaseInputBar = memo(
368368
aria-label="Stop generating"
369369
/>
370370
</div>
371-
<IconButton
372-
icon={sandboxInitializing ? SvgLoader : SvgArrowUp}
371+
<Button
372+
icon={
373+
sandboxInitializing
374+
? ({ className }) => (
375+
<SvgLoader
376+
className={cn(className, "animate-spin")}
377+
/>
378+
)
379+
: SvgArrowUp
380+
}
373381
onClick={handleSubmit}
374382
disabled={!canSubmit}
375383
tooltip={
@@ -380,9 +388,6 @@ const BaseInputBar = memo(
380388
: "Send"
381389
}
382390
aria-label={isRunning ? "Queue message" : "Send"}
383-
iconClassName={
384-
sandboxInitializing ? "animate-spin" : undefined
385-
}
386391
/>
387392
</div>
388393
</div>

0 commit comments

Comments
 (0)