Skip to content

Commit 8ce2065

Browse files
committed
fix: 🐛 Minimap adjustments
1 parent f11d540 commit 8ce2065

1 file changed

Lines changed: 25 additions & 21 deletions

File tree

src/components/mini-map/mini-map.tsx

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable react/require-default-props */
2-
import React, { useRef, useState } from "react";
2+
import React, { useMemo, useRef, useState } from "react";
33

44
import {
55
useTransformContext,
@@ -16,6 +16,17 @@ export type MiniMapProps = {
1616
HTMLDivElement
1717
>;
1818

19+
const previewStyles = {
20+
position: "absolute",
21+
zIndex: 2,
22+
top: "0px",
23+
left: "0px",
24+
boxSizing: "border-box",
25+
border: "3px solid red",
26+
transformOrigin: "0% 0%",
27+
boxShadow: "rgba(0,0,0,0.2) 0 0 0 10000000px",
28+
} as const;
29+
1930
export const MiniMap: React.FC<MiniMapProps> = ({
2031
width = 200,
2132
height = 200,
@@ -120,32 +131,25 @@ export const MiniMap: React.FC<MiniMapProps> = ({
120131
initialize();
121132
});
122133

134+
const wrapperStyle = useMemo(() => {
135+
return {
136+
...size,
137+
position: "relative",
138+
zIndex: 2,
139+
overflow: "hidden",
140+
} as const;
141+
}, [size]);
142+
123143
return (
124144
<div
125145
{...rest}
126-
style={{
127-
...size,
128-
position: "relative",
129-
zIndex: 2,
130-
overflow: "hidden",
131-
}}
146+
style={wrapperStyle}
147+
className={`rzpp-mini-map ${rest.className || ""}`}
132148
>
133-
<div {...rest} ref={wrapperRef}>
149+
<div {...rest} ref={wrapperRef} className="rzpp-wrapper">
134150
{children}
135151
</div>
136-
<div
137-
ref={previewRef}
138-
style={{
139-
position: "absolute",
140-
zIndex: 2,
141-
top: "0px",
142-
left: "0px",
143-
boxSizing: "border-box",
144-
border: "3px solid green",
145-
transformOrigin: "0% 0%",
146-
boxShadow: "rgba(0,0,0,0.2) 0 0 0 10000000px",
147-
}}
148-
/>
152+
<div className="rzpp-preview" ref={previewRef} style={previewStyles} />
149153
</div>
150154
);
151155
};

0 commit comments

Comments
 (0)