diff --git a/src/App.jsx b/src/App.jsx
index bdf9710..3f6f6a0 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -9,6 +9,7 @@ function App() {
const [error, setError] = useState();
const [roster, setRoster] = useState();
const [onePerPage, setOnePerPage] = useState(false);
+ const [primaryColor, setPrimaryColor] = useState();
const uploadRef = useRef();
async function handleFileSelect(event) {
const files = event?.target?.files;
@@ -89,6 +90,11 @@ function App() {
uploadRef.current?.removeAttribute("accept");
}
}, []);
+ useEffect(() => {
+ if (roster) {
+ setPrimaryColor(getPrimaryColor(roster.forces[0].catalog));
+ }
+ }, [roster]);
return (
@@ -101,7 +107,13 @@ function App() {
-
+
+
{error}
@@ -191,4 +214,51 @@ function App() {
);
}
+const getPrimaryColor = (catalog) => {
+ switch (catalog) {
+ case "Adeptus Astartes":
+ return "#536766";
+ case "Adeptus Custodes":
+ return "#536766";
+ case "Adeptus Mechanicus":
+ return "#536766";
+ case "Astra Militarum":
+ return "#375441";
+ case "Chaos Daemons":
+ return "#536766";
+ case "Chaos Space Marines":
+ return "#1d3138";
+ case "Death Guard":
+ return "#536766";
+ case "Drukhari":
+ return "#536766";
+ case "Genestealer Cults":
+ return "#536766";
+ case "Grey Knights":
+ return "#536766";
+ case "Harlequins":
+ return "#536766";
+ case "Imperial Knights":
+ return "#536766";
+ case "Necrons":
+ return "#005c2f";
+ case "Orks":
+ return "#4b6621";
+ case "Sisters of Battle":
+ return "#536766";
+ case "Space Marines":
+ return "#536766";
+ case "Tau Empire":
+ return "#536766";
+ case "Thousand Sons":
+ return "#536766";
+ case "Tyranids":
+ return "#44264C";
+ case "Ynnari":
+ return "#536766";
+ default:
+ return "#536766";
+ }
+};
+
export default App;
diff --git a/src/Roster.jsx b/src/Roster.jsx
index e5a41d4..baccfb7 100644
--- a/src/Roster.jsx
+++ b/src/Roster.jsx
@@ -10,13 +10,10 @@ export const Roster = ({ roster, onePerPage }) => {
return null;
}
const { name, cost, forces } = roster;
- const primaryColor = getPrimaryColor(forces[0].catalog);
return (
{
);
};
-const getPrimaryColor = (catalog) => {
- switch (catalog) {
- case "Adeptus Astartes":
- return "#536766";
- case "Adeptus Custodes":
- return "#536766";
- case "Adeptus Mechanicus":
- return "#536766";
- case "Astra Militarum":
- return "#375441";
- case "Chaos Daemons":
- return "#536766";
- case "Chaos Space Marines":
- return "#1d3138";
- case "Death Guard":
- return "#536766";
- case "Drukhari":
- return "#536766";
- case "Genestealer Cults":
- return "#536766";
- case "Grey Knights":
- return "#536766";
- case "Harlequins":
- return "#536766";
- case "Imperial Knights":
- return "#536766";
- case "Necrons":
- return "#005c2f";
- case "Orks":
- return "#4b6621";
- case "Sisters of Battle":
- return "#536766";
- case "Space Marines":
- return "#536766";
- case "Tau Empire":
- return "#536766";
- case "Thousand Sons":
- return "#536766";
- case "Tyranids":
- return "#44264C";
- case "Ynnari":
- return "#536766";
- default:
- return "#536766";
- }
-};
-
const Force = ({ force, onePerPage }) => {
const { units, rules, catalog } = force;
@@ -173,9 +123,12 @@ const Unit = ({ unit, index, catalog, onePerPage }) => {
marginBottom: 32,
}}
>
-