allow color override even for demon factions
This commit is contained in:
+20
-5
@@ -5,7 +5,7 @@ import { Arrow, wavyLine } from "../assets/icons";
|
|||||||
import { Weapons, hasDifferentProfiles } from "./Weapons";
|
import { Weapons, hasDifferentProfiles } from "./Weapons";
|
||||||
import { useLocalStorage } from "../helpers/useLocalStorage";
|
import { useLocalStorage } from "../helpers/useLocalStorage";
|
||||||
|
|
||||||
export const Roster = ({ roster, onePerPage }) => {
|
export const Roster = ({ roster, onePerPage, colorUserChoice }) => {
|
||||||
if (!roster) {
|
if (!roster) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -31,13 +31,18 @@ export const Roster = ({ roster, onePerPage }) => {
|
|||||||
{name} [{cost.commandPoints} CP, {cost.points} pts]
|
{name} [{cost.commandPoints} CP, {cost.points} pts]
|
||||||
</div>
|
</div>
|
||||||
{forces.map((force, index) => (
|
{forces.map((force, index) => (
|
||||||
<Force key={index} force={force} onePerPage={onePerPage} />
|
<Force
|
||||||
|
key={index}
|
||||||
|
force={force}
|
||||||
|
onePerPage={onePerPage}
|
||||||
|
colorUserChoice={colorUserChoice}
|
||||||
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const Force = ({ force, onePerPage }) => {
|
const Force = ({ force, onePerPage, colorUserChoice }) => {
|
||||||
const { units, factionRules, rules, catalog } = force;
|
const { units, factionRules, rules, catalog } = force;
|
||||||
var mergedRules = new Map([...factionRules, ...rules]);
|
var mergedRules = new Map([...factionRules, ...rules]);
|
||||||
return (
|
return (
|
||||||
@@ -54,6 +59,7 @@ const Force = ({ force, onePerPage }) => {
|
|||||||
catalog={catalog}
|
catalog={catalog}
|
||||||
onePerPage={onePerPage}
|
onePerPage={onePerPage}
|
||||||
forceRules={rules}
|
forceRules={rules}
|
||||||
|
colorUserChoice={colorUserChoice}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
<ForceRules rules={mergedRules} onePerPage={onePerPage} />
|
<ForceRules rules={mergedRules} onePerPage={onePerPage} />
|
||||||
@@ -61,7 +67,14 @@ const Force = ({ force, onePerPage }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const Unit = ({ unit, index, catalog, onePerPage, forceRules }) => {
|
const Unit = ({
|
||||||
|
unit,
|
||||||
|
index,
|
||||||
|
catalog,
|
||||||
|
onePerPage,
|
||||||
|
forceRules,
|
||||||
|
colorUserChoice,
|
||||||
|
}) => {
|
||||||
const [hide, setHide] = useState(false);
|
const [hide, setHide] = useState(false);
|
||||||
const uploadRef = useRef();
|
const uploadRef = useRef();
|
||||||
let {
|
let {
|
||||||
@@ -105,7 +118,9 @@ const Unit = ({ unit, index, catalog, onePerPage, forceRules }) => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
const overridePrimary = getOverridePrimary(factions, keywords);
|
const overridePrimary = colorUserChoice
|
||||||
|
? ""
|
||||||
|
: getOverridePrimary(factions, keywords);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Check if the browser is Safari, and if so, remove the accept attribute
|
// Check if the browser is Safari, and if so, remove the accept attribute
|
||||||
|
|||||||
+12
-4
@@ -18,6 +18,7 @@ function App() {
|
|||||||
const [edition, setEdition] = useState(10); // [9, 10]
|
const [edition, setEdition] = useState(10); // [9, 10]
|
||||||
const [onePerPage, setOnePerPage] = useState(false);
|
const [onePerPage, setOnePerPage] = useState(false);
|
||||||
const [primaryColor, setPrimaryColor] = useState("#536766");
|
const [primaryColor, setPrimaryColor] = useState("#536766");
|
||||||
|
const [colorUserChoice, setColorUserChoice] = useState(false);
|
||||||
const uploadRef = useRef();
|
const uploadRef = useRef();
|
||||||
async function handleFileSelect(event) {
|
async function handleFileSelect(event) {
|
||||||
const files = event?.target?.files;
|
const files = event?.target?.files;
|
||||||
@@ -155,6 +156,7 @@ function App() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (roster) {
|
if (roster) {
|
||||||
setPrimaryColor(getPrimaryColor(roster.forces[0].catalog));
|
setPrimaryColor(getPrimaryColor(roster.forces[0].catalog));
|
||||||
|
setColorUserChoice(false);
|
||||||
}
|
}
|
||||||
}, [roster]);
|
}, [roster]);
|
||||||
|
|
||||||
@@ -328,6 +330,7 @@ function App() {
|
|||||||
value={primaryColor}
|
value={primaryColor}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setPrimaryColor(e.target.value);
|
setPrimaryColor(e.target.value);
|
||||||
|
setColorUserChoice(true);
|
||||||
}}
|
}}
|
||||||
></input>
|
></input>
|
||||||
<span> Custom Color</span>
|
<span> Custom Color</span>
|
||||||
@@ -336,9 +339,10 @@ function App() {
|
|||||||
{roster &&
|
{roster &&
|
||||||
primaryColor !== getPrimaryColor(roster.forces[0].catalog) && (
|
primaryColor !== getPrimaryColor(roster.forces[0].catalog) && (
|
||||||
<button
|
<button
|
||||||
onClick={() =>
|
onClick={() => {
|
||||||
setPrimaryColor(getPrimaryColor(roster.forces[0].catalog))
|
setPrimaryColor(getPrimaryColor(roster.forces[0].catalog));
|
||||||
}
|
setColorUserChoice(false);
|
||||||
|
}}
|
||||||
style={{
|
style={{
|
||||||
padding: "2px 4px",
|
padding: "2px 4px",
|
||||||
borderRadius: 4,
|
borderRadius: 4,
|
||||||
@@ -355,7 +359,11 @@ function App() {
|
|||||||
</div>
|
</div>
|
||||||
{edition === 9 && <Roster roster={roster} onePerPage={onePerPage} />}
|
{edition === 9 && <Roster roster={roster} onePerPage={onePerPage} />}
|
||||||
{edition === 10 && (
|
{edition === 10 && (
|
||||||
<Roster10th roster={roster} onePerPage={onePerPage} />
|
<Roster10th
|
||||||
|
roster={roster}
|
||||||
|
onePerPage={onePerPage}
|
||||||
|
colorUserChoice={colorUserChoice}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
|||||||
Reference in New Issue
Block a user