Skip to content

Commit 4f7bedb

Browse files
committed
Icon fixup
1 parent 5ecb80c commit 4f7bedb

3 files changed

Lines changed: 63 additions & 19 deletions

File tree

lib/src/components/Pond.tsx

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import { createPortal } from 'react-dom';
1414
import { TerminalPane } from './TerminalPane';
1515
import { Baseboard } from './Baseboard';
1616
import { tv } from 'tailwind-variants';
17-
import { BellIcon, BellSlashIcon, SplitHorizontalIcon, SplitVerticalIcon, ArrowsOutIcon, ArrowsInIcon, ArrowLineDownIcon, XIcon, CursorClickIcon, ProhibitIcon } from '@phosphor-icons/react';
17+
import { PopupButtonRow, popupButton } from './design';
18+
import { BellIcon, BellSlashIcon, SplitHorizontalIcon, SplitVerticalIcon, ArrowsOutIcon, ArrowsInIcon, ArrowLineDownIcon, XIcon, CursorClickIcon, SelectionSlashIcon } from '@phosphor-icons/react';
1819
import {
1920
DEFAULT_MOUSE_SELECTION_STATE,
2021
extendSelectionToToken,
@@ -229,6 +230,7 @@ function MouseOverrideBanner({
229230
onCancel: () => void;
230231
}) {
231232
const [pos, setPos] = useState<{ x: number; y: number } | null>(null);
233+
const [flashed, setFlashed] = useState<'sticky' | 'cancel' | null>(null);
232234

233235
useLayoutEffect(() => {
234236
const update = () => {
@@ -244,27 +246,36 @@ function MouseOverrideBanner({
244246
};
245247
}, [anchor]);
246248

249+
useEffect(() => {
250+
if (!flashed) return;
251+
const id = window.setTimeout(() => {
252+
if (flashed === 'sticky') onMakePermanent();
253+
else onCancel();
254+
}, 260);
255+
return () => window.clearTimeout(id);
256+
}, [flashed, onMakePermanent, onCancel]);
257+
247258
if (!pos) return null;
248259

249260
return createPortal(
250-
<div
251-
className="z-[9999] flex items-center gap-2 rounded border border-border bg-surface-raised px-2 py-1 text-xs text-foreground shadow-md"
261+
<PopupButtonRow
262+
className="z-[9999]"
252263
style={clampOverlayPosition({ left: pos.x, top: pos.y, width: 340, height: 32 })}
253264
onMouseDown={(e) => e.stopPropagation()}
254265
role="status"
255266
>
256-
<span>Temporary mouse override until mouse-up.</span>
267+
<span className="px-1.5 py-0.5">Temporary mouse override until mouse-up.</span>
257268
<button
258269
type="button"
259-
className="m-0 rounded px-1.5 py-0.5 text-xs text-muted hover:bg-foreground/10 hover:text-foreground"
260-
onClick={onMakePermanent}
270+
className={popupButton({ tone: 'muted', flashed: flashed === 'sticky' })}
271+
onClick={() => !flashed && setFlashed('sticky')}
261272
>Make sticky</button>
262273
<button
263274
type="button"
264-
className="m-0 rounded px-1.5 py-0.5 text-xs text-muted hover:bg-foreground/10 hover:text-foreground"
265-
onClick={onCancel}
275+
className={popupButton({ tone: 'muted', flashed: flashed === 'cancel' })}
276+
onClick={() => !flashed && setFlashed('cancel')}
266277
>Cancel</button>
267-
</div>,
278+
</PopupButtonRow>,
268279
document.body,
269280
);
270281
}
@@ -773,9 +784,10 @@ export function TerminalPaneHeader({ api }: IDockviewPanelHeaderProps) {
773784
tooltip={mouseIconTooltip}
774785
>
775786
<span className="relative flex items-center justify-center">
776-
<CursorClickIcon size={14} />
777-
{inOverride && (
778-
<ProhibitIcon size={14} weight="bold" className="absolute inset-0 text-accent" />
787+
{inOverride ? (
788+
<SelectionSlashIcon size={14} />
789+
) : (
790+
<CursorClickIcon size={14} />
779791
)}
780792
</span>
781793
</HeaderActionButton>

lib/src/components/SelectionPopup.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { copyRaw, copyRewrapped } from '../lib/clipboard';
1212
import { CheckIcon } from '@phosphor-icons/react';
1313
import { IS_MAC } from '../lib/platform';
1414
import { getTerminalOverlayDims } from '../lib/terminal-registry';
15+
import { PopupButtonRow, popupButton } from './design';
1516

1617
interface Props {
1718
terminalId: string;
@@ -115,18 +116,14 @@ export function SelectionPopup({ terminalId }: Props) {
115116
};
116117

117118
const flashed = (kind: 'raw' | 'rewrapped') => state.copyFlash === kind;
118-
const buttonClass = (kind: 'raw' | 'rewrapped') =>
119-
flashed(kind)
120-
? 'animate-copy-flash m-0 px-1.5 py-0.5 bg-accent/25 text-accent'
121-
: 'm-0 px-1.5 py-0.5 hover:bg-foreground/10';
119+
const buttonClass = (kind: 'raw' | 'rewrapped') => popupButton({ flashed: flashed(kind) });
122120
const shortcutClass = (kind: 'raw' | 'rewrapped') =>
123121
flashed(kind) ? 'text-accent/70' : 'text-muted';
124122

125123
return (
126-
<div
124+
<PopupButtonRow
127125
data-selection-popup-for={terminalId}
128126
style={style}
129-
className="flex items-stretch overflow-hidden rounded border border-border bg-surface-raised text-xs text-foreground shadow-md"
130127
onMouseDown={(e) => e.stopPropagation()}
131128
>
132129
<button
@@ -163,6 +160,6 @@ export function SelectionPopup({ terminalId }: Props) {
163160
</span>{' '}
164161
Copy Rewrapped
165162
</button>
166-
</div>
163+
</PopupButtonRow>
167164
);
168165
}

lib/src/components/design.tsx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { clsx } from 'clsx';
2+
import { tv, type VariantProps } from 'tailwind-variants';
3+
import type { HTMLAttributes } from 'react';
4+
5+
export function PopupButtonRow({
6+
className,
7+
...props
8+
}: HTMLAttributes<HTMLDivElement>) {
9+
return (
10+
<div
11+
className={clsx(
12+
'flex items-stretch overflow-hidden rounded border border-border bg-surface-raised text-xs text-foreground shadow-md',
13+
className,
14+
)}
15+
{...props}
16+
/>
17+
);
18+
}
19+
20+
export const popupButton = tv({
21+
base: 'm-0 px-1.5 py-0.5',
22+
variants: {
23+
tone: {
24+
foreground: '',
25+
muted: 'text-muted hover:text-foreground',
26+
},
27+
flashed: {
28+
true: 'animate-copy-flash bg-accent/25 text-accent',
29+
false: 'hover:bg-foreground/10',
30+
},
31+
},
32+
defaultVariants: { tone: 'foreground', flashed: false },
33+
});
34+
35+
export type PopupButtonVariants = VariantProps<typeof popupButton>;

0 commit comments

Comments
 (0)