From 8ee97f2dc264d60ae2d5839f01d70285c572290a Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Sun, 19 Nov 2023 14:35:56 +0100 Subject: [PATCH] feat: recharge rates for defense in statistics panel (#15) --- src/ShipStatistics/Category.tsx | 5 +- src/ShipStatistics/RechargeRate.tsx | 46 +++++++++++++++ src/ShipStatistics/ShipStatistics.module.css | 59 +++++++++++++++++++- src/ShipStatistics/ShipStatistics.tsx | 28 +++++++--- 4 files changed, 127 insertions(+), 11 deletions(-) create mode 100644 src/ShipStatistics/RechargeRate.tsx diff --git a/src/ShipStatistics/Category.tsx b/src/ShipStatistics/Category.tsx index 9a22810..1ac7846 100644 --- a/src/ShipStatistics/Category.tsx +++ b/src/ShipStatistics/Category.tsx @@ -1,3 +1,4 @@ +import ctlx from "clsx"; import React from "react"; import styles from "./ShipStatistics.module.css"; @@ -17,8 +18,8 @@ export const Category = (props: {headerLabel: string, headerContent: React.React } -export const CategoryLine = (props: {children: React.ReactNode}) => { - return
+export const CategoryLine = (props: {className?: string, children: React.ReactNode}) => { + return
{props.children}
} diff --git a/src/ShipStatistics/RechargeRate.tsx b/src/ShipStatistics/RechargeRate.tsx new file mode 100644 index 0000000..65a6720 --- /dev/null +++ b/src/ShipStatistics/RechargeRate.tsx @@ -0,0 +1,46 @@ +import React from "react"; + +import { useShipAttribute } from '../ShipAttribute'; + +import styles from "./ShipStatistics.module.css"; +import clsx from "clsx"; + +export const RechargeRateItem = (props: {name: string, icon: React.ReactNode}) => { + const stringValue = useShipAttribute({ + name: props.name, + fixed: 1, + }); + + if (stringValue == "0.0") { + return + {props.icon} No Module + + } + + return + {props.icon} {stringValue} hp/s + +} + +export const RechargeRate = () => { + const [moduleType, setModuleType] = React.useState("passiveShieldRecharge"); + const [showDropdown, setShowDropdown] = React.useState(false); + + return +
setShowDropdown((current) => !current)}> + ^ +
+ { showDropdown &&
+
{ setModuleType("armorRepairRate"); setShowDropdown(false); }} className={clsx({[styles.rechargeRateDropdownContentSelected]: moduleType == "armorRepairRate"})}>Armor repair rate
+
{ setModuleType("hullRepairRate"); setShowDropdown(false); }} className={clsx({[styles.rechargeRateDropdownContentSelected]: moduleType == "hullRepairRate"})}>Hull repair rate
+
{ setModuleType("passiveShieldRecharge"); setShowDropdown(false); }} className={clsx({[styles.rechargeRateDropdownContentSelected]: moduleType == "passiveShieldRecharge"})}>Passive shield recharge
+
{ setModuleType("shieldBoostRate"); setShowDropdown(false); }} className={clsx({[styles.rechargeRateDropdownContentSelected]: moduleType == "shieldBoostRate"})}>Shield boost rate
+
} +
setShowDropdown((current) => !current)}> + { moduleType == "armorRepairRate" && A} /> } + { moduleType == "hullRepairRate" && H} /> } + { moduleType == "passiveShieldRecharge" && P} /> } + { moduleType == "shieldBoostRate" && S} /> } +
+
+} diff --git a/src/ShipStatistics/ShipStatistics.module.css b/src/ShipStatistics/ShipStatistics.module.css index 5a43cf3..2783827 100644 --- a/src/ShipStatistics/ShipStatistics.module.css +++ b/src/ShipStatistics/ShipStatistics.module.css @@ -26,15 +26,15 @@ max-height: 0px; } .expanded { - max-height: 150px; + max-height: 180px; } .line { display: flex; + height: 20px; justify-content: space-between; line-height: 20px; - height: 20px; margin: 10px 0px; } .line > span { @@ -42,6 +42,30 @@ margin: 0px 5px; } +.defense { + margin: 20px 0px; +} +.defense:last-child { + margin-bottom: 10px; +} +.defenseShield { + display: flex; + position: relative; + top: -5px; +} +.defenseShield > span:first-child { + line-height: 30px; +} +.defenseShield > span:last-child { + line-height: 15px; +} + +.resistanceHeader { + display: inline-block; + text-align: center; + width: 50px; +} + .resistance { background-color: #252124; display: inline-block; @@ -79,3 +103,34 @@ background-color: #8c5e19; } +.rechargeRate { + position: relative; +} + +.rechargeRateDropdown { + font-weight: bold; + position: absolute; + top: -10px; +} + +.rechargeRateDropdownContent { + background-color: #111111; + line-height: 25px; + position: absolute; + top: 30px; + width: 150px; + z-index: 10; +} + +.rechargeRateDropdownContent > div { + cursor: pointer; + padding: 0px 5px; +} + +.rechargeRateDropdownContentSelected { + background-color: #727272; +} + +.rechargeRateDropdownContent > div:hover { + background-color: #4e4e4e; +} diff --git a/src/ShipStatistics/ShipStatistics.tsx b/src/ShipStatistics/ShipStatistics.tsx index 021aab1..b4aee40 100644 --- a/src/ShipStatistics/ShipStatistics.tsx +++ b/src/ShipStatistics/ShipStatistics.tsx @@ -3,8 +3,11 @@ import React from "react"; import { ShipAttribute } from '../ShipAttribute'; import { Category, CategoryLine } from "./Category"; +import { RechargeRate } from "./RechargeRate"; import { Resistance } from "./Resistance"; +import styles from "./ShipStatistics.module.css"; + /** * Render ship statistics similar to how it is done in-game. */ @@ -42,12 +45,23 @@ export const ShipStatistics = () => { ehp }> - No module + + + E + T + K + X + - - - S - hp + + + + S + + + hp
+ s
+
@@ -56,7 +70,7 @@ export const ShipStatistics = () => {
- + A hp @@ -68,7 +82,7 @@ export const ShipStatistics = () => { - + S hp