From dd12c81aa704833639f1e48fdff56ace890586c2 Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Tue, 6 Aug 2024 15:27:04 +0200 Subject: [PATCH] feat: ability to set ShipFit in read-only mode (#155) This prevents the user from changing the fit. --- src/components/ShipFit/ShipFit.tsx | 64 +++++++++++++++--------------- src/components/ShipFit/Slot.tsx | 52 +++++++++++++++--------- 2 files changed, 65 insertions(+), 51 deletions(-) diff --git a/src/components/ShipFit/ShipFit.tsx b/src/components/ShipFit/ShipFit.tsx index 0b137c3..4625bef 100644 --- a/src/components/ShipFit/ShipFit.tsx +++ b/src/components/ShipFit/ShipFit.tsx @@ -20,7 +20,7 @@ import styles from "./ShipFit.module.css"; /** * Render a ship fit similar to how it is done in-game. */ -export const ShipFit = (props: { withStats?: boolean; isPreview?: boolean }) => { +export const ShipFit = (props: { withStats?: boolean; isPreview?: boolean; readOnly?: boolean }) => { const eveData = useEveData(); const statistics = useStatistics(); @@ -123,28 +123,28 @@ export const ShipFit = (props: { withStats?: boolean; isPreview?: boolean }) => - = 1} main /> + = 1} main readOnly={props.readOnly} /> - = 2} /> + = 2} readOnly={props.readOnly} /> - = 3} /> + = 3} readOnly={props.readOnly} /> - = 4} /> + = 4} readOnly={props.readOnly} /> - = 5} /> + = 5} readOnly={props.readOnly} /> - = 6} /> + = 6} readOnly={props.readOnly} /> - = 7} /> + = 7} readOnly={props.readOnly} /> - = 8} /> + = 8} readOnly={props.readOnly} /> @@ -152,28 +152,28 @@ export const ShipFit = (props: { withStats?: boolean; isPreview?: boolean }) => - = 1} /> + = 1} readOnly={props.readOnly} /> - = 2} /> + = 2} readOnly={props.readOnly} /> - = 3} /> + = 3} readOnly={props.readOnly} /> - = 4} /> + = 4} readOnly={props.readOnly} /> - = 5} /> + = 5} readOnly={props.readOnly} /> - = 6} /> + = 6} readOnly={props.readOnly} /> - = 7} /> + = 7} readOnly={props.readOnly} /> - = 8} /> + = 8} readOnly={props.readOnly} /> @@ -181,51 +181,51 @@ export const ShipFit = (props: { withStats?: boolean; isPreview?: boolean }) => - = 1} /> + = 1} readOnly={props.readOnly} /> - = 2} /> + = 2} readOnly={props.readOnly} /> - = 3} /> + = 3} readOnly={props.readOnly} /> - = 4} /> + = 4} readOnly={props.readOnly} /> - = 5} /> + = 5} readOnly={props.readOnly} /> - = 6} /> + = 6} readOnly={props.readOnly} /> - = 7} /> + = 7} readOnly={props.readOnly} /> - = 8} /> + = 8} readOnly={props.readOnly} /> - = 1} /> + = 1} readOnly={props.readOnly} /> - = 2} /> + = 2} readOnly={props.readOnly} /> - = 3} /> + = 3} readOnly={props.readOnly} /> - = 1} /> + = 1} readOnly={props.readOnly} /> - = 2} /> + = 2} readOnly={props.readOnly} /> - = 3} /> + = 3} readOnly={props.readOnly} /> - = 4} /> + = 4} readOnly={props.readOnly} /> diff --git a/src/components/ShipFit/Slot.tsx b/src/components/ShipFit/Slot.tsx index ecc8792..12ed11e 100644 --- a/src/components/ShipFit/Slot.tsx +++ b/src/components/ShipFit/Slot.tsx @@ -17,7 +17,13 @@ const stateRotation: Record = { Overload: ["Passive", "Online", "Active", "Overload"], }; -export const Slot = (props: { type: EsfSlotType; index: number; fittable: boolean; main?: boolean }) => { +export const Slot = (props: { + type: EsfSlotType; + index: number; + fittable: boolean; + main?: boolean; + readOnly?: boolean; +}) => { const eveData = useEveData(); const statistics = useStatistics(); const fitManager = useFitManager(); @@ -277,28 +283,36 @@ export const Slot = (props: { type: EsfSlotType; index: number; fittable: boolea return (
-
+
{svg}
{item}
-
- {module?.charge !== undefined && ( - - Remove Charge - - - )} - - Unfit Module - - - {module?.max_state !== "Passive" && ( - - Put Offline - + {props.readOnly !== true && ( +
+ {module?.charge !== undefined && ( + + Remove Charge + + + )} + + Unfit Module + - )} -
+ {module?.max_state !== "Passive" && ( + + Put Offline + + + )} +
+ )}
); };