Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add generic fallback for ingredient suffix #273

Merged
merged 1 commit into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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