fix font loading and different profiles

This commit is contained in:
NilsUeter
2023-06-07 23:34:50 +02:00
parent d1545f2b2c
commit 34bf449184
3 changed files with 55 additions and 21 deletions
+24 -13
View File
@@ -3,7 +3,7 @@ import factionBackground from "./assets/factionBackground.png";
import adeptusAstartesIcon from "./assets/adeptusAstartesIcon.png"; import adeptusAstartesIcon from "./assets/adeptusAstartesIcon.png";
import rangedIcon from "./assets/rangedIcon.png"; import rangedIcon from "./assets/rangedIcon.png";
import { Arrow, wavyLine } from "./assets/icons"; import { Arrow, wavyLine } from "./assets/icons";
import { Weapons } from "./Weapons"; import { Weapons, hasDifferentProfiles } from "./Weapons";
export const Roster = ({ roster, onePerPage }) => { export const Roster = ({ roster, onePerPage }) => {
if (!roster) { if (!roster) {
@@ -111,12 +111,23 @@ const Unit = ({ unit, index, catalog, onePerPage, forceRules }) => {
(weapon.range === "-" || weapon.range === "") && weapon.abilities (weapon.range === "-" || weapon.range === "") && weapon.abilities
) )
.sort((a, b) => a.selectionName.localeCompare(b.selectionName)); .sort((a, b) => a.selectionName.localeCompare(b.selectionName));
const modelsWithDifferentProfiles = weapons.filter( const modelsWithDifferentProfiles = weapons.filter((weapon, index) => {
(weapon) => const { selectionName, name } = weapon;
weapon.selectionName !== weapon.name && const previousWeapon = weapons[index - 1];
!weapon.name.includes("(Shooting)") && const nextWeapon = weapons[index + 1];
!weapon.name.includes("(Melee)") return (
); hasDifferentProfiles(selectionName, name) &&
((previousWeapon &&
hasDifferentProfiles(
previousWeapon.selectionName,
previousWeapon.name
) &&
selectionName === previousWeapon.selectionName) ||
(nextWeapon &&
hasDifferentProfiles(nextWeapon.selectionName, nextWeapon.name) &&
selectionName === nextWeapon.selectionName))
);
});
const overridePrimary = getOverridePrimary(factions, keywords); const overridePrimary = getOverridePrimary(factions, keywords);
@@ -223,7 +234,7 @@ const Unit = ({ unit, index, catalog, onePerPage, forceRules }) => {
style={{ style={{
fontFamily: "ConduitITCStd", fontFamily: "ConduitITCStd",
fontSize: "2.5em", fontSize: "2.5em",
letterSpacing: "1px", letterSpacing: ".1px",
lineHeight: "1", lineHeight: "1",
fontWeight: 800, fontWeight: 800,
textTransform: "uppercase", textTransform: "uppercase",
@@ -340,7 +351,7 @@ const Unit = ({ unit, index, catalog, onePerPage, forceRules }) => {
> >
<Spells title="PSYCHIC" spells={spells} /> <Spells title="PSYCHIC" spells={spells} />
<table <table
cellspacing="0" cellSpacing="0"
className="weapons-table" className="weapons-table"
style={{ width: "100%" }} style={{ width: "100%" }}
> >
@@ -359,7 +370,7 @@ const Unit = ({ unit, index, catalog, onePerPage, forceRules }) => {
</table> </table>
<div style={{ flex: "1" }}></div> <div style={{ flex: "1" }}></div>
<table <table
cellspacing="0" cellSpacing="0"
className="weapons-table" className="weapons-table"
style={{ width: "100%" }} style={{ width: "100%" }}
> >
@@ -679,7 +690,7 @@ const FancyBox = ({ children }) => {
const Psykers = ({ title, psykers }) => { const Psykers = ({ title, psykers }) => {
return ( return (
<table <table
cellspacing="0" cellSpacing="0"
className="weapons-table" className="weapons-table"
style={{ width: "100%", margin: "4px 2px" }} style={{ width: "100%", margin: "4px 2px" }}
> >
@@ -751,7 +762,7 @@ const WoundTracker = ({ woundTracker }) => {
}} }}
> >
<table <table
cellspacing="0" cellSpacing="0"
className="weapons-table" className="weapons-table"
style={{ width: "100%", margin: "4px 2px", marginBottom: -16 }} style={{ width: "100%", margin: "4px 2px", marginBottom: -16 }}
> >
@@ -787,7 +798,7 @@ const WoundTracker = ({ woundTracker }) => {
const Spells = ({ title, spells }) => { const Spells = ({ title, spells }) => {
return ( return (
<table <table
cellspacing="0" cellSpacing="0"
className="weapons-table" className="weapons-table"
style={{ width: "100%", marginTop: "var(--size-20)" }} style={{ width: "100%", marginTop: "var(--size-20)" }}
> >
+28 -5
View File
@@ -34,6 +34,8 @@ export const Weapons = ({ title, weapons, modelStats, forceRules }) => {
<Weapon <Weapon
key={weapon.name} key={weapon.name}
weapon={weapon} weapon={weapon}
previousWeapon={weapons[index - 1]}
nextWeapon={weapons[index + 1]}
modelStats={modelStats} modelStats={modelStats}
isMelee={isMelee} isMelee={isMelee}
className={getWeaponClassNames(weapons, index)} className={getWeaponClassNames(weapons, index)}
@@ -51,7 +53,24 @@ export const Weapons = ({ title, weapons, modelStats, forceRules }) => {
); );
}; };
const Weapon = ({ weapon, modelStats, isMelee, className, forceRules }) => { export const hasDifferentProfiles = (selectionName, name) => {
return (
selectionName &&
selectionName.toLowerCase() !== name.toLowerCase() &&
!name.includes("(Shooting)") &&
!name.includes("(Melee)")
);
};
const Weapon = ({
weapon,
previousWeapon,
nextWeapon,
modelStats,
isMelee,
className,
forceRules,
}) => {
let { name, selectionName, range, type, str, ap, damage, abilities } = weapon; let { name, selectionName, range, type, str, ap, damage, abilities } = weapon;
var lastWhiteSpace = type.lastIndexOf(" "); var lastWhiteSpace = type.lastIndexOf(" ");
const attacks = type.substring(lastWhiteSpace + 1); const attacks = type.substring(lastWhiteSpace + 1);
@@ -65,11 +84,15 @@ const Weapon = ({ weapon, modelStats, isMelee, className, forceRules }) => {
if (name === "Krak grenades") { if (name === "Krak grenades") {
name = "Krak grenade"; name = "Krak grenade";
} }
const differentProfiles = const differentProfiles =
selectionName && hasDifferentProfiles(selectionName, name) &&
selectionName.toLowerCase() !== name.toLowerCase() && ((previousWeapon &&
!name.includes("(Shooting)") && hasDifferentProfiles(previousWeapon.selectionName, previousWeapon.name) &&
!name.includes("(Melee)"); selectionName === previousWeapon.selectionName) ||
(nextWeapon &&
hasDifferentProfiles(nextWeapon.selectionName, nextWeapon.name) &&
selectionName === nextWeapon.selectionName));
if (differentProfiles && name.endsWith(" grenades")) { if (differentProfiles && name.endsWith(" grenades")) {
name = name.replace(" grenades", ""); name = name.replace(" grenades", "");
+3 -3
View File
@@ -22,17 +22,17 @@
@font-face { @font-face {
font-family: "ConduitITCStd"; font-family: "ConduitITCStd";
src: url("fonts/ConduitITCStd ExtraBold.woff2") format("woff2"); src: url("/fonts/ConduitITCStd ExtraBold.woff2") format("woff2");
font-weight: 800; font-weight: 800;
} }
@font-face { @font-face {
font-family: "ConduitITCStd"; font-family: "ConduitITCStd";
src: url("fonts/ConduitITCStd Bold.woff2") format("woff2"); src: url("/fonts/ConduitITCStd Bold.woff2") format("woff2");
font-weight: 700; font-weight: 700;
} }
@font-face { @font-face {
font-family: "ConduitITCStd"; font-family: "ConduitITCStd";
src: url("fonts/ConduitITCStd-Regular.woff2") format("woff2"); src: url("/fonts/ConduitITCStd-Regular.woff2") format("woff2");
font-weight: 400; font-weight: 400;
} }