Fixed Text components warnings

*Fixed AlwaysUpText and SimpleLabelText throwing warnings because off how props were passed. Now to set props of the inside text tag, you pass them as textProps
*Updated Object Renderers to use the new text props passing method
This commit is contained in:
izawartka 2025-07-07 17:29:35 +02:00
parent 55cbface5f
commit 44b838dc1b
7 changed files with 50 additions and 39 deletions

View File

@ -12,8 +12,10 @@ export default function IsolationIdRenderer(props) {
return <SimpleLabelText
text={text}
className="isolation-id"
x={x}
y={y}
textProps={{
className: "isolation-id"
}}
/>
}

View File

@ -25,8 +25,10 @@ export default function RouteRenderer(props) {
additionalRot={-90}
offsetX={object.track_offset}
reverseAnchor={true}
y={offY}
dominantBaseline="bottom"
textProps={{
y: offY,
dominantBaseline: "bottom"
}}
text={object.route_name}
/>
</g>

View File

@ -26,9 +26,12 @@ export default function SignalBoxRenderer(props) {
baseRot={rot - 90}
additionalRot={180}
offsetY={6}
textAnchor='middle'
textProps={{
textAnchor: 'middle'
}}
text={text}
/>
</g>
);
}

View File

@ -7,8 +7,10 @@ export default function SwitchNameRenderer(props) {
return <SimpleLabelText
text={text}
className="switch-name"
x={x}
y={y}
textProps={{
className: "switch-name"
}}
/>;
}

View File

@ -22,10 +22,12 @@ export default function TrackObjectRenderer(props) {
></circle>
<SimpleLabelText
text={text}
className="track-object-label"
x={x}
y={y}
enableBackground="new 0 0 100 100"
textProps={{
enableBackground: "new 0 0 100 100",
className: "track-object-label"
}}
wrapperStyle={{pointerEvents: 'none'}}
/>
</g>

View File

@ -4,7 +4,7 @@ import { mapRotation$ } from "../../../services/mapRotationService";
export default function AlwaysUpText(props) {
const [mapRotation, setMapRotation] = useState(0);
const { baseRot, additionalRot, text, reverseAnchor, offsetX, offsetY } = props;
const { baseRot, additionalRot, text, reverseAnchor, offsetX, offsetY, textProps } = props;
const adjustedRot = AngleHelper.normalizeDegAngle(baseRot + mapRotation);
const upsideDown = adjustedRot >= 180;
@ -21,7 +21,7 @@ export default function AlwaysUpText(props) {
return (
<g transform={`translate(${offsetX || 0}, ${offsetY || 0}) rotate(${upsideDownRot + additionalRot})`}>
<text textAnchor={anchor} dominantBaseline='middle' {...props}>
<text textAnchor={anchor} dominantBaseline='middle' {...textProps}>
{text}
</text>
</g>

View File

@ -2,7 +2,7 @@ import { useCallback, useEffect, useRef } from "react";
import { mapRotation$ } from "../../../services/mapRotationService";
export default function SimpleLabelText(props) {
const { text, x, y, wrapperStyle } = props;
const { text, x, y, wrapperStyle, textProps } = props;
const gRef = useRef(null);
const getTransformString = useCallback((rot) => (
@ -21,7 +21,7 @@ export default function SimpleLabelText(props) {
return (
<g transform={getTransformString(0)} ref={gRef} style={wrapperStyle}>
<text textAnchor="middle" dominantBaseline="middle" {...props} x={null} y={null}>
<text textAnchor="middle" dominantBaseline="middle" {...textProps}>
{text}
</text>
</g>