Skip to content

Commit 584fc84

Browse files
fix: visual improvement to the frame (#2610)
1 parent 1bb5131 commit 584fc84

File tree

9 files changed

+51
-45
lines changed

9 files changed

+51
-45
lines changed

apps/web/client/src/app/project/[id]/_components/canvas/frame/gesture.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const GestureScreen = observer(({ frame, isResizing }: { frame: WebFrame,
6161
break;
6262
case MouseAction.MOUSE_DOWN:
6363
if (el.tagName.toLocaleLowerCase() === 'body') {
64-
editorEngine.frames.select([frame]);
64+
editorEngine.frames.select([frame], e.shiftKey);
6565
return;
6666
}
6767
// Ignore right-clicks
@@ -120,7 +120,6 @@ export const GestureScreen = observer(({ frame, isResizing }: { frame: WebFrame,
120120

121121
const handleClick = useCallback(
122122
(e: React.MouseEvent<HTMLDivElement>) => {
123-
editorEngine.frames.deselectAll();
124123
editorEngine.frames.select([frame]);
125124
},
126125
[editorEngine.frames],

apps/web/client/src/app/project/[id]/_components/canvas/frame/top-bar.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ export const TopBar = observer(
7272
await editorEngine.frames.goForward(frame.id);
7373
};
7474

75-
const handleClick = () => {
76-
editorEngine.frames.select([frame]);
75+
const handleClick = (e: React.MouseEvent<HTMLDivElement>) => {
76+
editorEngine.frames.select([frame], e.shiftKey);
7777
};
7878

7979
return (
@@ -104,7 +104,7 @@ export const TopBar = observer(
104104
variant="ghost"
105105
size="icon"
106106
className={cn(
107-
'cursor-pointer',
107+
'cursor-pointer rounded-lg',
108108
!editorEngine.frames.navigation.canGoBack(frame.id) && 'hidden',
109109
)}
110110
onClick={handleGoBack}
@@ -118,7 +118,7 @@ export const TopBar = observer(
118118
variant="ghost"
119119
size="icon"
120120
className={cn(
121-
'cursor-pointer',
121+
'cursor-pointer rounded-lg',
122122
!editorEngine.frames.navigation.canGoForward(frame.id) && 'hidden',
123123
)}
124124
onClick={handleGoForward}
@@ -131,7 +131,7 @@ export const TopBar = observer(
131131
<Button
132132
variant="ghost"
133133
size="icon"
134-
className="cursor-pointer"
134+
className="cursor-pointer rounded-lg"
135135
onClick={handleReload}
136136
>
137137
<Icons.Reload />
@@ -151,7 +151,7 @@ export const TopBar = observer(
151151
pointerEvents: shouldShowExternalLink ? 'auto' : 'none',
152152
}}
153153
>
154-
<Button variant="ghost" size="icon">
154+
<Button variant="ghost" size="icon" className="rounded-lg">
155155
<Icons.ExternalLink />
156156
</Button>
157157
</Link>

apps/web/client/src/app/project/[id]/_components/canvas/frame/web-frame.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export const WebFrameComponent = observer(
4444
const maxRetries = 3;
4545
const baseDelay = 1000;
4646
const [penpalChild, setPenpalChild] = useState<PenpalChildMethods | null>(null);
47+
const isSelected = editorEngine.frames.isSelected(frame.id);
4748

4849
const undebouncedReloadIframe = () => {
4950
try {
@@ -278,7 +279,7 @@ export const WebFrameComponent = observer(
278279
<iframe
279280
ref={iframeRef}
280281
id={frame.id}
281-
className={cn('backdrop-blur-sm transition outline outline-4')}
282+
className={cn('backdrop-blur-sm transition outline outline-4', isSelected && 'outline-teal-400')}
282283
src={frame.url}
283284
sandbox="allow-modals allow-forms allow-same-origin allow-scripts allow-popups allow-downloads"
284285
allow="geolocation; microphone; camera; midi; encrypted-media"

apps/web/client/src/app/project/[id]/_components/editor-bar/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export const EditorBar = observer(({ availableWidth }: { availableWidth?: number
9898
exit={{ opacity: 0, y: 20 }}
9999
className={cn(
100100
'flex flex-col border-[0.5px] border-border p-1 px-1.5 bg-background rounded-xl backdrop-blur drop-shadow-xl z-50 overflow-hidden',
101-
editorEngine.state.editorMode === EditorMode.PREVIEW && 'hidden',
101+
editorEngine.state.editorMode === EditorMode.PREVIEW && !windowSelected && 'hidden',
102102
)}
103103
transition={{
104104
type: 'spring',

apps/web/client/src/app/project/[id]/_components/editor-bar/window-selected/rotate-group.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function RotateGroup({ frameData }: { frameData: FrameData }) {
1717
frameData.frame.dimension.height = width;
1818
}}
1919
>
20-
<Icons.CounterClockwiseClock className="h-4 w-4" />
20+
<Icons.Rotate className="h-4 w-4" />
2121
</Button>
2222
</HoverOnlyTooltip>
2323
);

apps/web/client/src/app/project/[id]/_components/left-panel/layers-tab/tree/tree-node.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export const TreeNode = memo(
120120
case MouseAction.MOUSE_DOWN:
121121
if (isWindow) {
122122
editorEngine.clearUI();
123-
editorEngine.frames.select([frameData.frame]);
123+
editorEngine.frames.select([frameData.frame], e.shiftKey);
124124
return;
125125
}
126126
if (e.shiftKey) {

apps/web/client/src/components/store/editor/frames/manager.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ export class FramesManager {
6868
}
6969

7070
registerView(frame: Frame, view: WebFrameView) {
71-
this._frameIdToData.set(frame.id, { frame, view, selected: false });
71+
const isSelected = this.isSelected(frame.id);
72+
this._frameIdToData.set(frame.id, { frame, view, selected: isSelected });
7273
const framePathname = new URL(view.src).pathname;
7374
this._navigation.registerFrame(frame.id, framePathname);
7475
}
@@ -85,10 +86,12 @@ export class FramesManager {
8586
return this._frameIdToData.get(id)?.selected ?? false;
8687
}
8788

88-
select(frames: Frame[]) {
89-
this.deselectAll();
89+
select(frames: Frame[], multiselect = false) {
90+
if (!multiselect) {
91+
this.deselectAll();
92+
}
9093
for (const frame of frames) {
91-
this.updateFrameSelection(frame.id, true);
94+
this.updateFrameSelection(frame.id, !this.isSelected(frame.id));
9295
}
9396
this.notify();
9497
}
@@ -248,7 +251,11 @@ export class FramesManager {
248251
const existingFrame = this.get(frameId);
249252
if (existingFrame) {
250253
const newFrame = { ...existingFrame.frame, ...frame };
251-
this._frameIdToData.set(frameId, { ...existingFrame, frame: newFrame });
254+
this._frameIdToData.set(frameId, {
255+
...existingFrame,
256+
frame: newFrame,
257+
selected: existingFrame.selected,
258+
});
252259
}
253260
await this.saveToStorage(frameId, frame);
254261
}

packages/ui/src/components/color-picker/Gradient.tsx

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -47,33 +47,6 @@ const FlipIcon = ({ className, ...props }: { className?: string; [key: string]:
4747
</svg>
4848
);
4949

50-
const RotateIcon = ({ className, ...props }: { className?: string; [key: string]: any }) => (
51-
<svg
52-
width="16"
53-
height="16"
54-
viewBox="0 0 15 16"
55-
fill="none"
56-
xmlns="http://www.w3.org/2000/svg"
57-
className={className}
58-
{...props}
59-
>
60-
<path
61-
d="M12.197 9.65567C12.3003 7.94296 12.0004 6.57856 10.7554 5.33352C8.74176 3.31988 5.477 3.31988 3.46336 5.33352C2.48972 6.30716 1.98685 7.57332 1.95477 8.84912"
62-
stroke="currentColor"
63-
strokeWidth="0.9375"
64-
strokeLinecap="round"
65-
strokeLinejoin="round"
66-
/>
67-
<path
68-
d="M13.8576 8.65058L12.4213 10.0869C12.2382 10.2699 11.9414 10.2699 11.7584 10.0869L10.3221 8.65058"
69-
stroke="currentColor"
70-
strokeWidth="0.9375"
71-
strokeLinecap="round"
72-
strokeLinejoin="round"
73-
/>
74-
</svg>
75-
);
76-
7750
const SelectedStopIcon = ({ className, ...props }: { className?: string; [key: string]: any }) => (
7851
<svg
7952
width="20"
@@ -850,7 +823,7 @@ export const Gradient: React.FC<GradientProps> = ({
850823
className="p-1.5 text-foreground-secondary hover:text-foreground-primary transition-colors hover:bg-background-hover rounded"
851824
title="Rotate gradient"
852825
>
853-
<RotateIcon className="w-3.5 h-3.5" />
826+
<Icons.Rotate className="w-3.5 h-3.5" />
854827
</button>
855828
</TooltipTrigger>
856829
<TooltipContent hideArrow className="mb-1">

packages/ui/src/components/icons/index.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,6 +1443,32 @@ export const Icons = {
14431443
/>
14441444
</svg>
14451445
),
1446+
Rotate: ({ className, ...props }: { className?: string; [key: string]: any }) => (
1447+
<svg
1448+
width="16"
1449+
height="16"
1450+
viewBox="0 0 15 16"
1451+
fill="none"
1452+
xmlns="http://www.w3.org/2000/svg"
1453+
className={className}
1454+
{...props}
1455+
>
1456+
<path
1457+
d="M12.197 9.65567C12.3003 7.94296 12.0004 6.57856 10.7554 5.33352C8.74176 3.31988 5.477 3.31988 3.46336 5.33352C2.48972 6.30716 1.98685 7.57332 1.95477 8.84912"
1458+
stroke="currentColor"
1459+
strokeWidth="0.9375"
1460+
strokeLinecap="round"
1461+
strokeLinejoin="round"
1462+
/>
1463+
<path
1464+
d="M13.8576 8.65058L12.4213 10.0869C12.2382 10.2699 11.9414 10.2699 11.7584 10.0869L10.3221 8.65058"
1465+
stroke="currentColor"
1466+
strokeWidth="0.9375"
1467+
strokeLinecap="round"
1468+
strokeLinejoin="round"
1469+
/>
1470+
</svg>
1471+
),
14461472

14471473
ArrowDown: ArrowDownIcon,
14481474
ArrowLeft: ArrowLeftIcon,

0 commit comments

Comments
 (0)