Skip to content

Commit 0889547

Browse files
committed
align decorative arrow to be in the middle
1 parent 92e9b9b commit 0889547

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

builder-frontend/src/components/shared/QuestionTooltip.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ export default function QuestionTooltip(props: TooltipProps) {
1717
const [position, setPosition] = createSignal<{
1818
x: number;
1919
align: TooltipAlignment;
20-
}>({ x: 0, align: TooltipAlignment.Center });
20+
containerWidth: number;
21+
}>({ x: 0, align: TooltipAlignment.Center, containerWidth: 0 });
2122

2223
let containerRef: HTMLDivElement | undefined;
2324

@@ -44,7 +45,7 @@ export default function QuestionTooltip(props: TooltipProps) {
4445
if (containerRef) {
4546
const rect = containerRef.getBoundingClientRect();
4647
const align = determineAlignment(rect);
47-
setPosition({ x: 0, align });
48+
setPosition({ x: 0, align, containerWidth: rect.width });
4849
}
4950
setIsVisible(true);
5051
};
@@ -87,10 +88,15 @@ export default function QuestionTooltip(props: TooltipProps) {
8788
class={`absolute w-3 h-3 bg-white border-t border-l border-gray-200 rotate-45 -top-[7px] ${
8889
position().align === TooltipAlignment.Center
8990
? "left-1/2 -translate-x-1/2"
90-
: position().align === TooltipAlignment.Left
91-
? "left-3"
92-
: "right-3"
91+
: ""
9392
}`}
93+
style={
94+
position().align === TooltipAlignment.Left
95+
? { left: `${position().containerWidth / 2 - 6}px` }
96+
: position().align === TooltipAlignment.Right
97+
? { right: `${position().containerWidth / 2 - 6}px` }
98+
: {}
99+
}
94100
/>
95101
</div>
96102
</Show>

0 commit comments

Comments
 (0)