Skip to content

Commit

Permalink
fix(fuel-gauge): improve rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
coderbyheart committed Oct 12, 2023
1 parent 8e5012b commit 9460db2
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions src/FuelGauge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,41 +50,41 @@ export const FuelGauge = ({
}) => {
const { V, I: current, T: temp, SoC, TTF, TTE } = fg.v
const isCharging = current < 0
const ChargingIndicator = isCharging ? Charging : NotCharging
return (
<>
<dt>
<button type={'button'} onClick={() => onClick?.()}>
{isCharging ? (
<Charging>
<BatteryCharging />
</Charging>
) : (
<NotCharging>
<BatteryIcon SoC={SoC} />
</NotCharging>
)}
</button>
<ChargingIndicator>
<button type={'button'} onClick={() => onClick?.()}>
{isCharging ? <BatteryCharging /> : <BatteryIcon SoC={SoC} />}
</button>
</ChargingIndicator>
</dt>
<dd class="d-flex flex-column align-items-start justify-content-center">
<button type={'button'} onClick={() => onClick?.()}>
<span class="me-2">{SoC}%</span>
{TTE !== undefined && (
<span class="me-2">empty {formatDistance(TTE)}</span>
)}
{TTF !== undefined && (
<span class="me-2">full {formatDistance(TTF)}</span>
)}
</button>
<button type={'button'} onClick={() => onClick?.()}>
<span class="me-2">{V / 1000} V</span>
<span class="me-2">
<Zap strokeWidth={1} /> {current} mA
</span>
<span class="me-2">
<Thermometer strokeWidth={1} />
{temp / 10} °C
</span>
</button>
<ChargingIndicator>
<button type={'button'} onClick={() => onClick?.()}>
<span class="me-2">{SoC}%</span>
{TTE !== undefined && (
<span class="me-1">(empty {formatDistance(TTE)})</span>
)}
{TTF !== undefined && (
<span class="me-1">(full {formatDistance(TTF)})</span>
)}
</button>
</ChargingIndicator>
<ChargingIndicator>
<button type={'button'} onClick={() => onClick?.()}>
<span class="me-1">{V / 1000} V</span>
<span class="me-1">
<Zap strokeWidth={1} class="me-0" />
{current} mA
</span>
<span class="me-1">
<Thermometer strokeWidth={1} class="me-0" />
{temp / 10} °C
</span>
</button>
</ChargingIndicator>
</dd>
</>
)
Expand Down

0 comments on commit 9460db2

Please sign in to comment.