This commit is contained in:
Sebastian Seedorf
2022-08-18 09:20:00 +02:00
parent 92b762bbd2
commit de95f57b18
60 changed files with 3450 additions and 994 deletions

View File

@@ -1,24 +1,29 @@
import {FC} from "react"
import {Recipe} from "../../../src/types"
import {EntityIcon} from "../EntityIcon/EntityIcon";
import { FC } from 'react'
import { Recipe } from '../../../src/types'
import { EntityIcon } from '../EntityIcon/EntityIcon'
import styles from './Recipe.module.css'
interface Props {
recipe: Recipe
}
export const RecipeSpan: FC<Props> = ({recipe}) => {
const toEntityIcon = ([key, amount]: [string, number]) => <EntityIcon key={key} value={key} amount={amount} />
const joinByPlus = (elems: JSX.Element[]) => elems.reduce((acc, curr) => {
if (acc.length) {
return [...acc, '+', curr]
} else {
return [curr]
}
}, [] as (JSX.Element|string)[])
const before = Object.entries({...recipe.prerequisites}).map(toEntityIcon)
const after = Object.entries({...recipe.output}).map(toEntityIcon)
return <span className={styles.recipe}>
{joinByPlus([toEntityIcon(['/Time', recipe.time]), ...before])} {joinByPlus(after)}
</span>
export const RecipeSpan: FC<Props> = ({ recipe }) => {
const toEntityIcon = ([key, amount]: [string, number]) => (
<EntityIcon key={key} value={key} amount={amount} />
)
const joinByPlus = (elems: JSX.Element[]) =>
elems.reduce((acc, curr) => {
if (acc.length) {
return [...acc, '+', curr]
} else {
return [curr]
}
}, [] as (JSX.Element | string)[])
const before = Object.entries({ ...recipe.prerequisites }).map(toEntityIcon)
const after = Object.entries({ ...recipe.output }).map(toEntityIcon)
return (
<span className={styles.recipe}>
{joinByPlus([toEntityIcon(['/Time', recipe.time]), ...before])} {joinByPlus(after)}
</span>
)
}