Skip to content

Commit c1e7657

Browse files
authored
Show discard only for dirty code tabs (#319)
- Hide the Discard button when there are no unsaved changes - Simplify save button styling across dirty, saved, and clean states
1 parent 2f100f7 commit c1e7657

1 file changed

Lines changed: 16 additions & 13 deletions

File tree

apps/web/src/components/CodeViewerPanel.tsx

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -473,30 +473,33 @@ export const CodeViewerFileContent = memo(function CodeViewerFileContent(
473473
Edit
474474
</Button>
475475
) : null}
476+
{tab?.isDirty ? (
477+
<Button
478+
type="button"
479+
size="xs"
480+
variant="outline"
481+
onClick={handleDiscardChanges}
482+
disabled={isSaving}
483+
>
484+
<RotateCcwIcon className="size-3.5" />
485+
Discard
486+
</Button>
487+
) : null}
476488
<Button
477489
type="button"
478490
size="xs"
479491
variant="outline"
480-
onClick={handleDiscardChanges}
481-
disabled={!tab?.isDirty || isSaving}
482-
>
483-
<RotateCcwIcon className="size-3.5" />
484-
Discard
485-
</Button>
486-
<Button
487-
type="button"
488-
size="xs"
489492
onClick={handleSave}
490493
disabled={!editable || isSaving}
491494
aria-live="polite"
492495
className={cn(
493-
"min-w-[7rem] justify-center overflow-hidden transition-[color,background-color,border-color,box-shadow] duration-200",
496+
"justify-center overflow-hidden transition-[color,background-color,border-color,box-shadow] duration-200",
494497
saveButtonState === "dirty" &&
495-
"border border-primary/25 bg-linear-to-b from-primary to-[hsl(223_82%_62%)] text-button-primary-foreground shadow-[0_14px_30px_-22px_color-mix(in_srgb,var(--primary)_65%,transparent)] hover:brightness-105",
498+
"border-primary/40 text-primary hover:bg-primary/10 dark:border-primary/30 dark:text-primary",
496499
saveButtonState === "saved" &&
497-
"border border-emerald-500/20 bg-emerald-500/10 text-emerald-700 shadow-none hover:bg-emerald-500/10 dark:text-emerald-200",
500+
"border-emerald-500/30 text-emerald-600 hover:bg-emerald-500/10 dark:border-emerald-500/20 dark:text-emerald-400",
498501
saveButtonState === "clean" &&
499-
"border border-border/80 bg-card text-muted-foreground shadow-none hover:border-border/80 hover:bg-card hover:text-muted-foreground",
502+
"text-muted-foreground",
500503
)}
501504
title={
502505
saveButtonState === "dirty"

0 commit comments

Comments
 (0)