diff --git a/src/components/atoms/TypeLabel.tsx b/src/components/atoms/TypeLabel.tsx new file mode 100644 index 00000000..46396c61 --- /dev/null +++ b/src/components/atoms/TypeLabel.tsx @@ -0,0 +1,37 @@ +import { Flex, Text } from '@theme-ui/components' +import SquareImageBox from './SquareImageBox' + +interface TypeLabelProps { + type: string +} + +const TypeLabel = ({ type }: TypeLabelProps) => { + const label = type.replace(/^\w/, (c) => c.toUpperCase()) + return ( + + {isValidType(type) && ( + + )} + {label} + + ) +} + +export default TypeLabel + +function isValidType(type: string): boolean { + switch (type) { + case 'mecha': + case 'biologic': + case 'psychic': + case 'quantum': + case 'imginary': + return true + } + return false +} diff --git a/src/pages/honkai3rd/battlesuits/[battlesuitId].tsx b/src/pages/honkai3rd/battlesuits/[battlesuitId].tsx index b140c278..ca1ce666 100644 --- a/src/pages/honkai3rd/battlesuits/[battlesuitId].tsx +++ b/src/pages/honkai3rd/battlesuits/[battlesuitId].tsx @@ -3,6 +3,7 @@ import { NextPageContext } from 'next' import Image from 'next/image' import React from 'react' import BattlesuitRankIcon from '../../../components/atoms/BattlesuitRankIcon' +import TypeLabel from '../../../components/atoms/TypeLabel' import ValkyrieLabel from '../../../components/atoms/ValkyrieLabel' import Breadcrumb from '../../../components/organisms/Breadcrumb' import Honkai3rdNavigator from '../../../components/organisms/Honkai3rdNavigator' @@ -68,10 +69,10 @@ const BattlesuitShowPage = ({ battlesuit }: BattlesuitShowPageProps) => { + + + - - {battlesuit.type.replace(/^\w/, (c) => c.toUpperCase())} - {battlesuit.strengths.map((strength) => { const strengthData = battlesuitStrengths.find( (aStrength) => aStrength.value === strength