Skip to content

Commit 25f637c

Browse files
committed
feat(web): share reduced-motion icon morphs across controls
1 parent 8e1a945 commit 25f637c

29 files changed

Lines changed: 171 additions & 214 deletions

‎apps/web/src/components/ChatMarkdown.tsx‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,16 @@ import {
55
encodeComposerContextClipboardHtml,
66
} from "@t3tools/shared/composerContextClipboard";
77
import {
8-
CheckIcon,
98
ChevronRightIcon,
10-
CopyIcon,
119
FileSpreadsheetIcon,
1210
FileTextIcon,
1311
GlobeIcon,
1412
ImageIcon,
1513
InfoIcon,
1614
LightbulbIcon,
1715
MailIcon,
18-
Maximize2Icon,
1916
MessageSquareIcon,
2017
MessageSquareWarningIcon,
21-
Minimize2Icon,
2218
OctagonAlertIcon,
2319
PlayIcon,
2420
PresentationIcon,
@@ -27,6 +23,7 @@ import {
2723
WrapTextIcon,
2824
type LucideIcon,
2925
} from "lucide-react";
26+
import { Check, Copy, Maximize2, Minimize2 } from "lucide";
3027
import type {
3128
AssetResource,
3229
EnvironmentId,
@@ -121,6 +118,7 @@ import {
121118
import { hasSpecificPierreIconForFileName, syntheticFileNameForLanguageId } from "../pierre-icons";
122119
import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
123120
import { Button } from "./ui/button";
121+
import { MorphIcon } from "~/components/MorphIcon";
124122
import { ContextChip } from "./ContextChip";
125123
import { Collapsible, CollapsiblePanel, CollapsibleTrigger } from "./ui/collapsible";
126124
import { ScrollArea } from "./ui/scroll-area";
@@ -846,7 +844,7 @@ function MarkdownTable({ children, ...props }: React.ComponentProps<"table">) {
846844
/>
847845
}
848846
>
849-
{expanded ? <Minimize2Icon className="size-3" /> : <Maximize2Icon className="size-3" />}
847+
<MorphIcon className="size-3" icon={expanded ? Minimize2 : Maximize2} />
850848
</TooltipTrigger>
851849
<TooltipPopup side="top">{expandLabel}</TooltipPopup>
852850
</Tooltip>
@@ -866,7 +864,7 @@ function MarkdownTable({ children, ...props }: React.ComponentProps<"table">) {
866864
/>
867865
}
868866
>
869-
{copied ? <CheckIcon className="size-3" /> : <CopyIcon className="size-3" />}
867+
<MorphIcon className="size-3" icon={copied ? Check : Copy} />
870868
</TooltipTrigger>
871869
<TooltipPopup side="top">{copyLabel}</TooltipPopup>
872870
</Tooltip>
@@ -1102,7 +1100,7 @@ function MarkdownCodeBlock({
11021100
/>
11031101
}
11041102
>
1105-
{copied ? <CheckIcon className="size-3" /> : <CopyIcon className="size-3" />}
1103+
<MorphIcon className="size-3" icon={copied ? Check : Copy} />
11061104
</TooltipTrigger>
11071105
<TooltipPopup side="top">{copyLabel}</TooltipPopup>
11081106
</Tooltip>

‎apps/web/src/components/DiffFilePathCopyButton.tsx‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import { CheckIcon, CopyIcon } from "lucide-react";
1+
import { Check, Copy } from "lucide";
22
import { useRef } from "react";
33
import { useCopyToClipboard } from "../hooks/useCopyToClipboard";
4+
import { cn } from "../lib/utils";
45
import {
56
ANCHORED_COPY_TOAST_TIMEOUT_MS,
67
showAnchoredCopyErrorToast,
78
showAnchoredCopySuccessToast,
89
} from "./ui/anchoredCopyToast";
910
import { Button } from "./ui/button";
11+
import { MorphIcon } from "~/components/MorphIcon";
1012
import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
1113

1214
export function DiffFilePathCopyButton({ filePath }: { filePath: string }) {
@@ -30,7 +32,10 @@ export function DiffFilePathCopyButton({ filePath }: { filePath: string }) {
3032
/>
3133
}
3234
>
33-
{isCopied ? <CheckIcon className="size-3 text-success" /> : <CopyIcon className="size-3" />}
35+
<MorphIcon
36+
className={cn("size-3", isCopied && "text-success")}
37+
icon={isCopied ? Check : Copy}
38+
/>
3439
</TooltipTrigger>
3540
<TooltipPopup>
3641
<p>{isCopied ? "Copied" : "Copy path"}</p>

‎apps/web/src/components/DiffPanel.tsx‎

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@ import {
1212
ArrowRightIcon,
1313
CheckIcon,
1414
ChevronDownIcon,
15-
ChevronRightIcon,
16-
ChevronsDownUpIcon,
17-
ChevronsUpDownIcon,
1815
Columns2Icon,
1916
FolderTreeIcon,
2017
PilcrowIcon,
2118
Rows3Icon,
2219
TextWrapIcon,
2320
} from "lucide-react";
21+
import { ChevronDown, ChevronRight, ChevronsDownUp, ChevronsUpDown } from "lucide";
2422
import * as Schema from "effect/Schema";
2523
import * as DateTime from "effect/DateTime";
2624
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
@@ -58,6 +56,7 @@ import { AnnotatableCodeView, type AnnotatableCodeViewHandle } from "./diffs/Ann
5856
import { DiffFileTree } from "./diffs/DiffFileTree";
5957
import { diffFileTreeEntries } from "./diffs/diffFileTree.logic";
6058
import { Button } from "./ui/button";
59+
import { MorphIcon } from "~/components/MorphIcon";
6160
import { ToggleGroup, Toggle } from "./ui/toggle-group";
6261
import { Switch } from "./ui/switch";
6362
import {
@@ -873,11 +872,10 @@ export default function DiffPanel({
873872
/>
874873
}
875874
>
876-
{allDiffFilesCollapsed ? (
877-
<ChevronsUpDownIcon className="size-3.5" />
878-
) : (
879-
<ChevronsDownUpIcon className="size-3.5" />
880-
)}
875+
<MorphIcon
876+
className="size-3.5"
877+
icon={allDiffFilesCollapsed ? ChevronsUpDown : ChevronsDownUp}
878+
/>
881879
</TooltipTrigger>
882880
<TooltipPopup side="top">
883881
{allDiffFilesCollapsed ? "Expand all files" : "Collapse all files"}
@@ -1133,15 +1131,10 @@ export default function DiffPanel({
11331131
/>
11341132
}
11351133
>
1136-
{collapsed ? (
1137-
<ChevronRightIcon
1138-
className={cn("size-4", getDiffCollapseIconClassName(fileDiff))}
1139-
/>
1140-
) : (
1141-
<ChevronDownIcon
1142-
className={cn("size-4", getDiffCollapseIconClassName(fileDiff))}
1143-
/>
1144-
)}
1134+
<MorphIcon
1135+
className={cn("size-4", getDiffCollapseIconClassName(fileDiff))}
1136+
icon={collapsed ? ChevronRight : ChevronDown}
1137+
/>
11451138
</TooltipTrigger>
11461139
<TooltipPopup side="top">
11471140
{collapsed ? "Expand diff" : "Collapse diff"}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { MorphIcon as BaseMorphIcon, type MorphIconProps } from "morphicons/react";
2+
3+
/** Renders `lucide` icon data and morphs between shapes when `icon` changes. */
4+
export function MorphIcon({ reducedMotion = "user", ...props }: MorphIconProps) {
5+
return <BaseMorphIcon reducedMotion={reducedMotion} {...props} />;
6+
}

‎apps/web/src/components/RightPanelTabs.tsx‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ import {
2323
Globe2,
2424
Plus,
2525
TerminalSquare,
26-
Volume2,
27-
VolumeOff,
2826
} from "lucide-react";
27+
import { Volume2, VolumeOff } from "lucide";
2928
import {
3029
type KeyboardEvent as ReactKeyboardEvent,
3130
type MouseEvent as ReactMouseEvent,
@@ -44,6 +43,7 @@ import type { RightPanelSurface } from "~/rightPanelStore";
4443
import { cn } from "~/lib/utils";
4544
import { readLocalApi } from "~/localApi";
4645
import { Button } from "~/components/ui/button";
46+
import { MorphIcon } from "~/components/MorphIcon";
4747
import { AndroidIcon, AppleIcon } from "~/components/Icons";
4848
import { Tooltip, TooltipPopup, TooltipTrigger } from "~/components/ui/tooltip";
4949
import { Kbd } from "~/components/ui/kbd";
@@ -1149,11 +1149,10 @@ export function RightPanelTabs(props: RightPanelTabsProps) {
11491149
.catch(() => undefined);
11501150
}}
11511151
>
1152-
{audio === "muted" ? (
1153-
<VolumeOff className="size-3" />
1154-
) : (
1155-
<Volume2 className="size-3" />
1156-
)}
1152+
<MorphIcon
1153+
className="size-3"
1154+
icon={audio === "muted" ? VolumeOff : Volume2}
1155+
/>
11571156
</button>
11581157
}
11591158
/>

‎apps/web/src/components/chat/ChangedFilesTree.tsx‎

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,15 @@ import {
66
summarizeTurnDiffStats,
77
type TurnDiffTreeNode,
88
} from "../../lib/turnDiffTree";
9-
import {
10-
ChevronsDownUpIcon,
11-
ChevronsUpDownIcon,
12-
ChevronRightIcon,
13-
FileDiffIcon,
14-
FolderIcon,
15-
FolderClosedIcon,
16-
} from "lucide-react";
9+
import { ChevronRightIcon, FileDiffIcon } from "lucide-react";
10+
import { ChevronsDownUp, ChevronsUpDown, Folder, FolderClosed } from "lucide";
1711
import { cn } from "~/lib/utils";
1812
import { DiffStatLabel, hasNonZeroStat } from "./DiffStatLabel";
1913
import { PierreEntryIcon } from "./PierreEntryIcon";
2014
import { Button } from "../ui/button";
2115
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
2216
import { MiddleTruncate } from "../ui/middle-truncate";
17+
import { MorphIcon } from "~/components/MorphIcon";
2318

2419
const EMPTY_DIRECTORY_OVERRIDES: Record<string, boolean> = {};
2520

@@ -86,11 +81,10 @@ export const ChangedFilesCard = memo(function ChangedFilesCard(props: {
8681
/>
8782
}
8883
>
89-
{allDirectoriesExpanded ? (
90-
<ChevronsDownUpIcon className="size-3" />
91-
) : (
92-
<ChevronsUpDownIcon className="size-3" />
93-
)}
84+
<MorphIcon
85+
className="size-3"
86+
icon={allDirectoriesExpanded ? ChevronsDownUp : ChevronsUpDown}
87+
/>
9488
</TooltipTrigger>
9589
<TooltipPopup side="top">
9690
{allDirectoriesExpanded ? "Collapse all folders" : "Expand all folders"}
@@ -195,11 +189,10 @@ export const ChangedFilesTree = memo(function ChangedFilesTree(props: {
195189
isExpanded && "rotate-90",
196190
)}
197191
/>
198-
{isExpanded ? (
199-
<FolderIcon className="size-3.5 shrink-0 text-muted-foreground/75" />
200-
) : (
201-
<FolderClosedIcon className="size-3.5 shrink-0 text-muted-foreground/75" />
202-
)}
192+
<MorphIcon
193+
className="size-3.5 shrink-0 text-muted-foreground/75"
194+
icon={isExpanded ? Folder : FolderClosed}
195+
/>
203196
<span className="truncate font-mono text-2xs text-muted-foreground/90 group-hover:text-foreground/90">
204197
{node.name}
205198
</span>

‎apps/web/src/components/chat/ComposerPrimaryActions.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { memo, type MouseEventHandler, type PointerEventHandler } from "react";
22
import { CheckIcon, ChevronDownIcon, ChevronLeftIcon, PlayIcon } from "lucide-react";
33
import { CornerUpRight, ListPlus } from "lucide";
4-
import { MorphIcon } from "morphicons/react";
4+
import { MorphIcon } from "~/components/MorphIcon";
55
import { useEnvironmentIdentificationMode } from "~/hooks/useSettings";
66
import { cn } from "~/lib/utils";
77
import { useShortcutModifierState } from "../../shortcutModifierState";
@@ -311,7 +311,7 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({
311311
) : isEditingQueuedMessage ? (
312312
<CheckIcon className="size-4" aria-hidden="true" />
313313
) : isRunning ? (
314-
<MorphIcon icon={isQueuing ? ListPlus : CornerUpRight} size={16} reducedMotion="user" />
314+
<MorphIcon className="size-4" icon={isQueuing ? ListPlus : CornerUpRight} />
315315
) : (
316316
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" aria-hidden="true">
317317
<path

‎apps/web/src/components/chat/ExpandedImageDialog.tsx‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ import {
77
type ReactNode,
88
type KeyboardEvent,
99
} from "react";
10-
import { ChevronLeftIcon, ChevronRightIcon, ImageIcon, TextIcon, XIcon } from "lucide-react";
10+
import { ChevronLeftIcon, ChevronRightIcon, XIcon } from "lucide-react";
11+
import { Image as ImageGlyph, Text as TextGlyph } from "lucide";
1112
import { Button } from "../ui/button";
13+
import { MorphIcon } from "~/components/MorphIcon";
1214
import { Dialog, DialogPopup, DialogTitle } from "../ui/dialog";
1315
import type { ExpandedImageItem, ExpandedImagePreview } from "./ExpandedImagePreview";
1416
import { resolveExternalWebLinkHost } from "./externalLinkContextMenu";
@@ -165,7 +167,6 @@ export const ExpandedImageDialog = memo(function ExpandedImageDialog({
165167
: accessibilityDetails?.format === "json"
166168
? "Show accessibility JSON"
167169
: "Show extracted text";
168-
const ContentsIcon = showingAccessibilityDetails ? ImageIcon : TextIcon;
169170

170171
return (
171172
<Dialog
@@ -260,7 +261,11 @@ export const ExpandedImageDialog = memo(function ExpandedImageDialog({
260261
/>
261262
}
262263
>
263-
<ContentsIcon className="size-3" aria-hidden="true" />
264+
<MorphIcon
265+
className="size-3"
266+
aria-hidden="true"
267+
icon={showingAccessibilityDetails ? ImageGlyph : TextGlyph}
268+
/>
264269
</TooltipTrigger>
265270
<TooltipPopup side="top">{contentsLabel}</TooltipPopup>
266271
</Tooltip>

‎apps/web/src/components/chat/MessageCopyButton.tsx‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { memo, useRef } from "react";
2-
import { CopyIcon, CheckIcon } from "lucide-react";
2+
import { Check, Copy } from "lucide";
33
import { Button } from "../ui/button";
4+
import { MorphIcon } from "~/components/MorphIcon";
5+
import { cn } from "~/lib/utils";
46
import { useCopyToClipboard } from "~/hooks/useCopyToClipboard";
57
import {
68
ANCHORED_COPY_TOAST_TIMEOUT_MS,
@@ -47,7 +49,10 @@ export const MessageCopyButton = memo(function MessageCopyButton({
4749
/>
4850
}
4951
>
50-
{isCopied ? <CheckIcon className="size-3 text-primary" /> : <CopyIcon className="size-3" />}
52+
<MorphIcon
53+
className={cn("size-3", isCopied && "text-primary")}
54+
icon={isCopied ? Check : Copy}
55+
/>
5156
</TooltipTrigger>
5257
<TooltipPopup>
5358
<p>Copy message</p>

‎apps/web/src/components/chat/MessagesTimeline.tsx‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,14 @@ import {
139139
XIcon,
140140
ZapIcon,
141141
} from "lucide-react";
142+
import { ChevronDown, ChevronRight } from "lucide";
142143
import type {
143144
ComposerContextId,
144145
ComposerContextRecord,
145146
KnownComposerContextRecord,
146147
} from "@t3tools/contracts";
147148
import { Button, InlineButton } from "../ui/button";
149+
import { MorphIcon } from "~/components/MorphIcon";
148150
import { useAssetUrlRefresh, useAssetUrls, useAssetUrlState } from "../../assets/assetUrls";
149151
import { MediaVideoPlayer } from "../media/MediaVideoPlayer";
150152
import { getVirtualizedScrollFadeClassName } from "../ui/scroll-area";
@@ -2424,7 +2426,6 @@ function TimelineRowTimestamp({
24242426

24252427
function TurnFoldTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "turn-fold" }> }) {
24262428
const ctx = use(TimelineRowCtx);
2427-
const Icon = row.expanded ? ChevronDownIcon : ChevronRightIcon;
24282429

24292430
return (
24302431
<div className="group/timeline-row relative flex items-center gap-1 border-b border-border/60 pb-2 pe-0.5 pt-1">
@@ -2436,7 +2437,7 @@ function TurnFoldTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "turn-
24362437
className="flex cursor-pointer select-none items-center gap-1 rounded-md px-1 text-sm leading-relaxed text-muted-foreground tabular-nums transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/70"
24372438
>
24382439
<span>{row.label}</span>
2439-
<Icon className="size-3.5" />
2440+
<MorphIcon className="size-3.5" icon={row.expanded ? ChevronDown : ChevronRight} />
24402441
</button>
24412442
<TimelineRowTimestamp
24422443
createdAt={row.createdAt}
@@ -2449,7 +2450,6 @@ function TurnFoldTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "turn-
24492450

24502451
function AttemptFoldTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "attempt-fold" }> }) {
24512452
const ctx = use(TimelineRowCtx);
2452-
const Icon = row.expanded ? ChevronDownIcon : ChevronRightIcon;
24532453

24542454
return (
24552455
<button
@@ -2460,7 +2460,10 @@ function AttemptFoldTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "at
24602460
onClick={() => ctx.onToggleAttemptFold(row.attemptId)}
24612461
className="flex w-full cursor-pointer select-none items-center gap-2 rounded-md border border-border/60 bg-muted/20 px-2.5 py-2 text-left transition-colors hover:bg-muted/35 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/70"
24622462
>
2463-
<Icon className="size-3.5 shrink-0 text-muted-foreground" />
2463+
<MorphIcon
2464+
className="size-3.5 shrink-0 text-muted-foreground"
2465+
icon={row.expanded ? ChevronDown : ChevronRight}
2466+
/>
24642467
<span className="text-xs font-medium text-foreground/80">{row.label}</span>
24652468
<span className="text-2xs text-muted-foreground">Partial output retained</span>
24662469
</button>

0 commit comments

Comments
 (0)