Skip to content

Commit

Permalink
Add generic fallback for ingredient suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
Aericio committed Oct 21, 2023
1 parent de31e2e commit c320581
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
14 changes: 5 additions & 9 deletions src/components/checklist/CategoryItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ function CategoryItem({ name, item }) {
rank,
item.maxLvl
)
}
>
}>
{rank}
</div>
);
Expand All @@ -67,19 +66,17 @@ function CategoryItem({ name, item }) {
<PaginatedTooltip
content={
<>
<ItemGeneralInfoTooltip item={item} />
<ItemGeneralInfoTooltip item={item} itemName={name} />
{item.relics && (
<ItemRelicTooltip item={item} name={name} />
)}
</>
}
>
}>
<div
className={classNames("item", {
"item-mastered": mastered,
"item-locked": masteryRankLocked
})}
>
})}>
<Button
className="item-name"
onClick={e => {
Expand All @@ -99,8 +96,7 @@ function CategoryItem({ name, item }) {
else masterItem(name, !mastered);
}
}
}}
>
}}>
{name +
((item.maxLvl || 30) !== 30
? ` [${
Expand Down
23 changes: 12 additions & 11 deletions src/components/checklist/ItemComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@ import PropTypes from "prop-types";
import { ingredientSuffixes } from "../../utils/items";

export default function ItemComponent({
itemName,
componentName,
component,
isSubcomponent
}) {
const imageName =
(componentName.includes(" Prime ") ? "prime-" : "") +
(component.generic
? ingredientSuffixes.find(suffix =>
componentName.endsWith(suffix)
) ?? componentName.replace(`${itemName} `, "")
: componentName);

return (
<div className={classNames({ "item-subcomponent": isSubcomponent })}>
<img
className="component-image"
src={`https://cdn.warframestat.us/img/${
component?.img ||
(componentName.includes(" Prime ") ? "prime-" : "") +
(component.generic
? ingredientSuffixes
.find(suffix =>
componentName.endsWith(suffix)
)
.split(" ")
.join("-")
.toLowerCase()
: componentName.toLowerCase().split(" ").join("-"))
imageName.split(" ").join("-").toLowerCase()
}.png`}
alt=""
width="24px"
Expand All @@ -37,8 +37,9 @@ export default function ItemComponent({
return (
<ItemComponent
key={subcomponentName}
component={subcomponent}
itemName={itemName}
componentName={subcomponentName}
component={subcomponent}
isSubcomponent
/>
);
Expand Down
3 changes: 2 additions & 1 deletion src/components/checklist/ItemGeneralInfoTooltip.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import GluedComponents from "../GluedComponents";
import { PaginatedTooltipTitle } from "../PaginatedTooltip";
import ItemComponent from "./ItemComponent";

function ItemGeneralInfoTooltip({ item }) {
function ItemGeneralInfoTooltip({ item, itemName }) {
const isMacOS =
window.navigator.userAgentData?.platform === "macOS" ||
window.navigator.platform === "MacIntel"; //TODO: Remove usage of deprecated Navigator.platform
Expand All @@ -21,6 +21,7 @@ function ItemGeneralInfoTooltip({ item }) {
return (
<ItemComponent
key={componentName}
itemName={itemName}
componentName={componentName}
component={component}
/>
Expand Down

0 comments on commit c320581

Please sign in to comment.