Skip to content

Commit dd9e643

Browse files
committed
ui: optimize element layouts
1 parent 948ff8b commit dd9e643

File tree

6 files changed

+42
-39
lines changed

6 files changed

+42
-39
lines changed

src/components/DiagramFrame/SeqDiagram/MessageLayer/Anchor.tsx

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@ import { diagramElementAtom, dragAnchorAtom, scaleAtom } from "@/store/Store";
22
import { useAtomValue, useSetAtom } from "jotai";
33
import { useRef } from "react";
44

5+
const icon = (
6+
<svg
7+
xmlns="http://www.w3.org/2000/svg"
8+
width="11"
9+
height="11"
10+
viewBox="0 0 24 24"
11+
fill="currentColor"
12+
className="life-line-anchor invisible"
13+
>
14+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
15+
<path d="M4.929 4.929a10 10 0 1 1 14.141 14.141a10 10 0 0 1 -14.14 -14.14zm8.071 4.071a1 1 0 1 0 -2 0v2h-2a1 1 0 1 0 0 2h2v2a1 1 0 1 0 2 0v-2h2a1 1 0 1 0 0 -2h-2v-2z" />
16+
</svg>
17+
);
18+
519
export const Anchor = (props: {
620
context: any;
721
participant: string;
@@ -12,38 +26,29 @@ export const Anchor = (props: {
1226
const diagramElement = useAtomValue(diagramElementAtom);
1327
const setAnchor = useSetAtom(dragAnchorAtom);
1428
return (
15-
<div
16-
className="inline-block text-sky-500 -ml-3"
17-
ref={elRef}
18-
onMouseDown={(e) => {
19-
e.stopPropagation();
20-
const {
21-
left = 0,
22-
top = 0,
23-
width = 0,
24-
height = 0,
25-
} = elRef.current?.getBoundingClientRect() || {};
26-
const diagramRect = diagramElement?.getBoundingClientRect();
27-
setAnchor({
28-
context: props.context,
29-
index: props.index,
30-
participant: props.participant,
31-
x: (left + width / 2 - (diagramRect?.left || 0)) / scale,
32-
y: (top + height / 2 - (diagramRect?.top || 0)) / scale,
33-
});
34-
}}
35-
>
36-
<svg
37-
xmlns="http://www.w3.org/2000/svg"
38-
width="23"
39-
height="23"
40-
viewBox="0 0 24 24"
41-
fill="currentColor"
42-
className="pointer-events-auto life-line-anchor"
29+
<div className="relative w-6 h-6 -my-1 -ml-[12.5px]">
30+
<div
31+
className="text-sky-500 cursor-pointer absolute w-6 h-6 inline-flex justify-center items-center pointer-events-auto [&:hover>svg]:visible overflow-hidden"
32+
ref={elRef}
33+
onMouseDown={(e) => {
34+
e.stopPropagation();
35+
const {
36+
left = 0,
37+
top = 0,
38+
height = 0,
39+
} = elRef.current?.getBoundingClientRect() || {};
40+
const diagramRect = diagramElement?.getBoundingClientRect();
41+
setAnchor({
42+
context: props.context,
43+
index: props.index,
44+
participant: props.participant,
45+
x: (left - (diagramRect?.left || 0)) / scale,
46+
y: (top + height / 2 - (diagramRect?.top || 0)) / scale,
47+
});
48+
}}
4349
>
44-
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
45-
<path d="M4.929 4.929a10 10 0 1 1 14.141 14.141a10 10 0 0 1 -14.14 -14.14zm8.071 4.071a1 1 0 1 0 -2 0v2h-2a1 1 0 1 0 0 2h2v2a1 1 0 1 0 2 0v-2h2a1 1 0 1 0 0 -2h-2v-2z" />
46-
</svg>
50+
{icon}
51+
</div>
4752
</div>
4853
);
4954
};

src/components/DiagramFrame/SeqDiagram/MessageLayer/Block/Block.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const Block = (props: {
2424
};
2525
return (
2626
<div
27-
className={cn("block pt-6 pb-2 pointer-events-none", props.className)}
27+
className={cn("block pointer-events-none", props.className)}
2828
style={props.style}
2929
data-origin={props.origin}
3030
>

src/components/DiagramFrame/SeqDiagram/MessageLayer/Block/Statement/Interaction/Interaction.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,7 @@ export const Interaction = (props: {
9595
/>
9696
{assignee && !isSelf && (
9797
<Message
98-
className={cn(
99-
"return transform -translate-y-full",
100-
messageClassNames,
101-
)}
98+
className={cn("return transform -mt-4", messageClassNames)}
10299
context={message}
103100
content={assignee}
104101
rtl={!rightToLeft}

src/components/DiagramFrame/SeqDiagram/MessageLayer/Block/Statement/Interaction/Occurrence/Occurrence.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ export const Occurrence = (props: {
7373
</>
7474
)}
7575
{hasAnyStatementsExceptReturn() && (
76-
<CollapseButton collapsed={collapsed} onClick={toggle} />
76+
<div className="mb-5">
77+
<CollapseButton collapsed={collapsed} onClick={toggle} />
78+
</div>
7779
)}
7880
{props.context.braceBlock() ? (
7981
<Block

src/components/DiagramFrame/SeqDiagram/MessageLayer/MessageLayer.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333

3434
.fragment {
3535
border-width: 1px;
36-
margin: 8px 0 0 0;
3736
padding-bottom: 10px;
3837
}
3938

src/components/DiagramFrame/SeqDiagram/MessageLayer/MessageLayer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const MessageLayer = (props: {
3636

3737
return (
3838
<div
39-
className="message-layer relative z-30 pt-14 pb-10 pointer-events-none"
39+
className="message-layer relative z-30 pt-20 pb-10 pointer-events-none"
4040
style={props.style}
4141
>
4242
<Block

0 commit comments

Comments
 (0)