feat(MapNode): add viewBoxWidth prop for scaling and adjust text rendering for fixed visual size
This commit is contained in:
@@ -20,6 +20,7 @@ interface MapNodeProps {
|
|||||||
kills?: number;
|
kills?: number;
|
||||||
showJumps?: boolean;
|
showJumps?: boolean;
|
||||||
showKills?: boolean;
|
showKills?: boolean;
|
||||||
|
viewBoxWidth?: number; // Add viewBox width for scaling calculations
|
||||||
}
|
}
|
||||||
|
|
||||||
export const MapNode: React.FC<MapNodeProps> = ({
|
export const MapNode: React.FC<MapNodeProps> = ({
|
||||||
@@ -41,6 +42,7 @@ export const MapNode: React.FC<MapNodeProps> = ({
|
|||||||
kills,
|
kills,
|
||||||
showJumps = false,
|
showJumps = false,
|
||||||
showKills = false,
|
showKills = false,
|
||||||
|
viewBoxWidth = 1200,
|
||||||
}) => {
|
}) => {
|
||||||
const [isHovered, setIsHovered] = useState(false);
|
const [isHovered, setIsHovered] = useState(false);
|
||||||
const [isDragging, setIsDragging] = useState(false);
|
const [isDragging, setIsDragging] = useState(false);
|
||||||
@@ -185,7 +187,7 @@ export const MapNode: React.FC<MapNodeProps> = ({
|
|||||||
className="transition-all duration-300"
|
className="transition-all duration-300"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Node label */}
|
{/* Node label - fixed visual size regardless of zoom */}
|
||||||
<text
|
<text
|
||||||
x="0"
|
x="0"
|
||||||
y={textOffset}
|
y={textOffset}
|
||||||
@@ -195,7 +197,12 @@ export const MapNode: React.FC<MapNodeProps> = ({
|
|||||||
fontWeight="bold"
|
fontWeight="bold"
|
||||||
className={`transition-all duration-300 ${isHovered ? 'fill-purple-200' : 'fill-white'
|
className={`transition-all duration-300 ${isHovered ? 'fill-purple-200' : 'fill-white'
|
||||||
} pointer-events-none select-none`}
|
} pointer-events-none select-none`}
|
||||||
style={{ textShadow: '2px 2px 4px rgba(0,0,0,0.8)' }}
|
style={{
|
||||||
|
textShadow: '2px 2px 4px rgba(0,0,0,0.8)',
|
||||||
|
vectorEffect: 'non-scaling-stroke'
|
||||||
|
}}
|
||||||
|
transform={`scale(${1 / (1200 / viewBoxWidth)})`}
|
||||||
|
transformOrigin="0 0"
|
||||||
>
|
>
|
||||||
{name} {security !== undefined && (
|
{name} {security !== undefined && (
|
||||||
<tspan fill={getSecurityColor(security)}>{security.toFixed(1)}</tspan>
|
<tspan fill={getSecurityColor(security)}>{security.toFixed(1)}</tspan>
|
||||||
@@ -208,12 +215,17 @@ export const MapNode: React.FC<MapNodeProps> = ({
|
|||||||
fill="#a3a3a3"
|
fill="#a3a3a3"
|
||||||
fontSize="12"
|
fontSize="12"
|
||||||
className="pointer-events-none select-none"
|
className="pointer-events-none select-none"
|
||||||
style={{ textShadow: '1px 1px 2px rgba(0,0,0,0.8)' }}
|
style={{
|
||||||
|
textShadow: '1px 1px 2px rgba(0,0,0,0.8)',
|
||||||
|
vectorEffect: 'non-scaling-stroke'
|
||||||
|
}}
|
||||||
|
transform={`scale(${1 / (1200 / viewBoxWidth)})`}
|
||||||
|
transformOrigin="0 0"
|
||||||
>
|
>
|
||||||
{signatures !== undefined && signatures > 0 && `📡 ${signatures}`}
|
{signatures !== undefined && signatures > 0 && `📡 ${signatures}`}
|
||||||
</text>
|
</text>
|
||||||
|
|
||||||
{/* Statistics display */}
|
{/* Statistics display - fixed visual size regardless of zoom */}
|
||||||
{showJumps && jumps !== undefined && (
|
{showJumps && jumps !== undefined && (
|
||||||
<text
|
<text
|
||||||
x="0"
|
x="0"
|
||||||
@@ -222,7 +234,12 @@ export const MapNode: React.FC<MapNodeProps> = ({
|
|||||||
fill="#60a5fa"
|
fill="#60a5fa"
|
||||||
fontSize="10"
|
fontSize="10"
|
||||||
className="pointer-events-none select-none"
|
className="pointer-events-none select-none"
|
||||||
style={{ textShadow: '1px 1px 2px rgba(0,0,0,0.8)' }}
|
style={{
|
||||||
|
textShadow: '1px 1px 2px rgba(0,0,0,0.8)',
|
||||||
|
vectorEffect: 'non-scaling-stroke'
|
||||||
|
}}
|
||||||
|
transform={`scale(${1 / (1200 / viewBoxWidth)})`}
|
||||||
|
transformOrigin="0 0"
|
||||||
>
|
>
|
||||||
🚀 {jumps}
|
🚀 {jumps}
|
||||||
</text>
|
</text>
|
||||||
@@ -236,7 +253,12 @@ export const MapNode: React.FC<MapNodeProps> = ({
|
|||||||
fill="#f87171"
|
fill="#f87171"
|
||||||
fontSize="10"
|
fontSize="10"
|
||||||
className="pointer-events-none select-none"
|
className="pointer-events-none select-none"
|
||||||
style={{ textShadow: '1px 1px 2px rgba(0,0,0,0.8)' }}
|
style={{
|
||||||
|
textShadow: '1px 1px 2px rgba(0,0,0,0.8)',
|
||||||
|
vectorEffect: 'non-scaling-stroke'
|
||||||
|
}}
|
||||||
|
transform={`scale(${1 / (1200 / viewBoxWidth)})`}
|
||||||
|
transformOrigin="0 0"
|
||||||
>
|
>
|
||||||
⚔️ {kills}
|
⚔️ {kills}
|
||||||
</text>
|
</text>
|
||||||
|
@@ -1088,6 +1088,7 @@ export const RegionMap = ({ regionName, focusSystem, isCompact = false, isWormho
|
|||||||
kills={getSystemKills(system.solarSystemName)}
|
kills={getSystemKills(system.solarSystemName)}
|
||||||
showJumps={showJumps}
|
showJumps={showJumps}
|
||||||
showKills={showKills}
|
showKills={showKills}
|
||||||
|
viewBoxWidth={viewBox.width}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user