Skip to content

Commit

Permalink
fix: show ship name if the hull image can't be loaded (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
TrueBrain authored Jun 8, 2024
1 parent b94f722 commit 03ac963
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/components/ShipFit/Hull.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react";

import { useCurrentFit } from "@/providers/CurrentFitProvider";
import { useEveData } from "@/providers/EveDataProvider";

import styles from "./ShipFit.module.css";

Expand All @@ -9,8 +10,10 @@ export interface ShipFitProps {
}

export const Hull = () => {
const eveData = useEveData();
const currentFit = useCurrentFit();
if (currentFit.currentFit === null) {

if (currentFit.currentFit === null || eveData === null) {
return <></>;
}

Expand All @@ -21,7 +24,10 @@ export const Hull = () => {

return (
<div className={styles.hull}>
<img src={`https://images.evetech.net/types/${shipTypeId}/render?size=1024`} />
<img
src={`https://images.evetech.net/types/${shipTypeId}/render?size=1024`}
alt={eveData.typeIDs[shipTypeId].name}
/>
</div>
);
};
3 changes: 3 additions & 0 deletions src/components/ShipFit/ShipFit.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@
}

.hull > img {
align-items: center;
border-radius: 50%;
display: flex;
height: calc(100% - 2 * 3%);
justify-content: space-evenly;
left: 3%;
opacity: 0.8;
position: relative;
Expand Down

0 comments on commit 03ac963

Please sign in to comment.