Skip to content

Commit 06d5674

Browse files
committed
style(webview): replace remaining inline styles in FilesChangedOverview with CSS utility classes where feasible; keep dynamic styles for virtualization
1 parent 3a62761 commit 06d5674

File tree

1 file changed

+18
-115
lines changed

1 file changed

+18
-115
lines changed

webview-ui/src/components/file-changes/FilesChangedOverview.tsx

Lines changed: 18 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -203,27 +203,11 @@ const FilesChangedOverview: React.FC = () => {
203203

204204
return (
205205
<div
206-
className="files-changed-overview"
207-
data-testid="files-changed-overview"
208-
style={{
209-
border: "1px solid var(--vscode-panel-border)",
210-
borderRadius: "4px",
211-
padding: "12px",
212-
margin: "8px 0",
213-
backgroundColor: "var(--vscode-editor-background)",
214-
}}>
206+
className="files-changed-overview border border-vscode-panel-border rounded p-3 my-2 bg-vscode-editor-background"
207+
data-testid="files-changed-overview">
215208
{/* Collapsible header */}
216209
<div
217-
style={{
218-
display: "flex",
219-
justifyContent: "space-between",
220-
alignItems: "center",
221-
marginBottom: isCollapsed ? "0" : "12px",
222-
borderBottom: isCollapsed ? "none" : "1px solid var(--vscode-panel-border)",
223-
paddingBottom: "8px",
224-
cursor: "pointer",
225-
userSelect: "none",
226-
}}
210+
className={`flex justify-between items-center ${isCollapsed ? "" : "mb-3 border-b border-vscode-panel-border pb-2"} cursor-pointer select-none`}
227211
onClick={() => setIsCollapsed(!isCollapsed)}
228212
onKeyDown={(e) => {
229213
if (e.key === "Enter" || e.key === " ") {
@@ -241,15 +225,11 @@ const FilesChangedOverview: React.FC = () => {
241225
: t("file-changes:accessibility.expanded"),
242226
})}
243227
title={isCollapsed ? t("file-changes:header.expand") : t("file-changes:header.collapse")}>
244-
<div style={{ display: "flex", alignItems: "center", gap: "8px" }}>
228+
<div className="flex items-center gap-2">
245229
<span
246-
className={`codicon ${isCollapsed ? "codicon-chevron-right" : "codicon-chevron-down"}`}
247-
style={{
248-
fontSize: "12px",
249-
transition: "transform 0.2s ease",
250-
}}
230+
className={`codicon ${isCollapsed ? "codicon-chevron-right" : "codicon-chevron-down"} text-[12px] transition-transform`}
251231
/>
252-
<h3 style={{ margin: 0, fontSize: "14px", fontWeight: "bold" }} data-testid="files-changed-header">
232+
<h3 className="m-0 text-sm font-bold" data-testid="files-changed-header">
253233
{t("file-changes:summary.count_with_changes", {
254234
count: files.length,
255235
changes: totalChanges,
@@ -259,24 +239,15 @@ const FilesChangedOverview: React.FC = () => {
259239

260240
{/* Action buttons always visible for quick access */}
261241
<div
262-
style={{ display: "flex", gap: "8px" }}
242+
className="flex gap-2"
263243
onClick={(e) => e.stopPropagation()} // Prevent collapse toggle when clicking buttons
264244
>
265245
<button
266246
onClick={() => handleWithDebounce(handleRejectAll)}
267247
disabled={isProcessing}
268248
tabIndex={0}
269249
data-testid="reject-all-button"
270-
style={{
271-
backgroundColor: "var(--vscode-button-secondaryBackground)",
272-
color: "var(--vscode-button-secondaryForeground)",
273-
border: "none",
274-
borderRadius: "3px",
275-
padding: "4px 8px",
276-
fontSize: "12px",
277-
cursor: isProcessing ? "not-allowed" : "pointer",
278-
opacity: isProcessing ? 0.6 : 1,
279-
}}
250+
className={`bg-vscode-button-secondaryBackground text-vscode-button-secondaryForeground border border-vscode-button-border rounded px-2 py-1 text-xs ${isProcessing ? "opacity-60 cursor-not-allowed" : "cursor-pointer"}`}
280251
title={t("file-changes:actions.reject_all")}>
281252
{t("file-changes:actions.reject_all")}
282253
</button>
@@ -285,16 +256,7 @@ const FilesChangedOverview: React.FC = () => {
285256
disabled={isProcessing}
286257
tabIndex={0}
287258
data-testid="accept-all-button"
288-
style={{
289-
backgroundColor: "var(--vscode-button-background)",
290-
color: "var(--vscode-button-foreground)",
291-
border: "none",
292-
borderRadius: "3px",
293-
padding: "4px 8px",
294-
fontSize: "12px",
295-
cursor: isProcessing ? "not-allowed" : "pointer",
296-
opacity: isProcessing ? 0.6 : 1,
297-
}}
259+
className={`bg-vscode-button-background text-vscode-button-foreground border border-vscode-button-border rounded px-2 py-1 text-xs ${isProcessing ? "opacity-60 cursor-not-allowed" : "cursor-pointer"}`}
298260
title={t("file-changes:actions.accept_all")}>
299261
{t("file-changes:actions.accept_all")}
300262
</button>
@@ -304,13 +266,7 @@ const FilesChangedOverview: React.FC = () => {
304266
{/* Collapsible content area */}
305267
{!isCollapsed && (
306268
<div
307-
style={{
308-
maxHeight: "300px",
309-
overflowY: "auto",
310-
transition: "opacity 0.2s ease-in-out",
311-
opacity: isCollapsed ? 0 : 1,
312-
position: "relative",
313-
}}
269+
className={`max-h-[300px] overflow-y-auto transition-opacity duration-200 ease-in-out ${isCollapsed ? "opacity-0" : "opacity-100"} relative`}
314270
onScroll={handleScroll}>
315271
{shouldVirtualize && (
316272
<div style={{ height: totalHeight, position: "relative" }}>
@@ -382,92 +338,39 @@ const FileItem: React.FC<FileItemProps> = React.memo(
382338
({ file, formatLineChanges, onViewDiff, onAcceptFile, onRejectFile, handleWithDebounce, isProcessing, t }) => (
383339
<div
384340
data-testid={`file-item-${file.uri}`}
385-
style={{
386-
display: "flex",
387-
justifyContent: "space-between",
388-
alignItems: "center",
389-
padding: "6px 8px",
390-
marginBottom: "4px",
391-
backgroundColor: "var(--vscode-list-hoverBackground)",
392-
borderRadius: "3px",
393-
fontSize: "13px",
394-
minHeight: "60px", // Consistent height for virtualization
395-
}}>
396-
<div style={{ flex: 1, minWidth: 0 }}>
397-
<div
398-
style={{
399-
fontFamily: "var(--vscode-editor-font-family)",
400-
fontSize: "12px",
401-
color: "var(--vscode-editor-foreground)",
402-
overflow: "hidden",
403-
textOverflow: "ellipsis",
404-
whiteSpace: "nowrap",
405-
}}>
341+
className="flex justify-between items-center px-2 py-1.5 mb-1 bg-vscode-list-hoverBackground rounded text-[13px] min-h-[60px]">
342+
<div className="flex-1 min-w-0">
343+
<div className="text-xs text-vscode-editor-foreground overflow-hidden text-ellipsis whitespace-nowrap">
406344
{file.uri}
407345
</div>
408-
<div
409-
style={{
410-
fontSize: "11px",
411-
color: "var(--vscode-descriptionForeground)",
412-
marginTop: "2px",
413-
}}>
346+
<div className="text-[11px] text-vscode-descriptionForeground mt-0.5">
414347
{t(`file-changes:file_types.${file.type}`)}{formatLineChanges(file)}
415348
</div>
416349
</div>
417350

418-
<div style={{ display: "flex", gap: "4px", marginLeft: "8px" }}>
351+
<div className="flex gap-1 ml-2">
419352
<button
420353
onClick={() => handleWithDebounce(() => onViewDiff(file.uri))}
421354
disabled={isProcessing}
422355
title={t("file-changes:actions.view_diff")}
423356
data-testid={`diff-${file.uri}`}
424-
style={{
425-
backgroundColor: "transparent",
426-
color: "var(--vscode-button-foreground)",
427-
border: "1px solid var(--vscode-button-border)",
428-
borderRadius: "3px",
429-
padding: "2px 6px",
430-
fontSize: "11px",
431-
cursor: isProcessing ? "not-allowed" : "pointer",
432-
minWidth: "50px",
433-
opacity: isProcessing ? 0.6 : 1,
434-
}}>
357+
className={`bg-transparent text-vscode-button-foreground border border-vscode-button-border rounded px-1.5 py-0.5 text-[11px] min-w-[50px] ${isProcessing ? "opacity-60 cursor-not-allowed" : "cursor-pointer"}`}>
435358
{t("file-changes:actions.view_diff")}
436359
</button>
437360
<button
438361
onClick={() => handleWithDebounce(() => onRejectFile(file.uri))}
439362
disabled={isProcessing}
440363
title={t("file-changes:actions.reject_file")}
441364
data-testid={`reject-${file.uri}`}
442-
style={{
443-
backgroundColor: "var(--vscode-button-secondaryBackground)",
444-
color: "var(--vscode-button-secondaryForeground)",
445-
border: "1px solid var(--vscode-button-border)",
446-
borderRadius: "3px",
447-
padding: "2px 6px",
448-
fontSize: "11px",
449-
cursor: isProcessing ? "not-allowed" : "pointer",
450-
minWidth: "20px",
451-
opacity: isProcessing ? 0.6 : 1,
452-
}}>
365+
className={`bg-vscode-button-secondaryBackground text-vscode-button-secondaryForeground border border-vscode-button-border rounded px-1.5 py-0.5 text-[11px] min-w-[20px] ${isProcessing ? "opacity-60 cursor-not-allowed" : "cursor-pointer"}`}>
453366
454367
</button>
455368
<button
456369
onClick={() => handleWithDebounce(() => onAcceptFile(file.uri))}
457370
disabled={isProcessing}
458371
title={t("file-changes:actions.accept_file")}
459372
data-testid={`accept-${file.uri}`}
460-
style={{
461-
backgroundColor: "var(--vscode-button-background)",
462-
color: "var(--vscode-button-foreground)",
463-
border: "1px solid var(--vscode-button-border)",
464-
borderRadius: "3px",
465-
padding: "2px 6px",
466-
fontSize: "11px",
467-
cursor: isProcessing ? "not-allowed" : "pointer",
468-
minWidth: "20px",
469-
opacity: isProcessing ? 0.6 : 1,
470-
}}>
373+
className={`bg-vscode-button-background text-vscode-button-foreground border border-vscode-button-border rounded px-1.5 py-0.5 text-[11px] min-w-[20px] ${isProcessing ? "opacity-60 cursor-not-allowed" : "cursor-pointer"}`}>
471374
472375
</button>
473376
</div>

0 commit comments

Comments
 (0)