Extract WeaponCard

This commit is contained in:
Sakura Knoll
2022-01-01 21:31:09 +09:00 Unverified
parent 5042f687de
commit bf90b8f968
2 changed files with 52 additions and 39 deletions
+49
View File
@@ -0,0 +1,49 @@
import { Box, Card, Text } from '@theme-ui/components'
import { WeaponData } from '../../lib/honkai3rd/weapons'
import PageLink from '../atoms/PageLink'
import SquareImageBox from '../atoms/SquareImageBox'
interface WeaponCardProps {
weapon: Pick<WeaponData, 'id' | 'name' | 'rarity'>
hidden?: boolean
}
const WeaponCard = ({ weapon, hidden }: WeaponCardProps) => {
return (
<Card
className={hidden ? 'hidden' : ''}
sx={{
width: '120px',
padding: 2,
margin: 1,
'&.hidden': {
display: 'none',
},
}}
>
<PageLink href={`/honkai3rd/weapons/${weapon.id}`}>
<SquareImageBox
size={100}
alt={weapon.name}
src={`/assets/honkai3rd/weapons/${weapon.id}.png`}
/>
<Box
sx={{
overflow: 'hidden',
textOverflow: 'ellipsis',
width: '100%',
whiteSpace: 'nowrap',
textAlign: 'center',
}}
>
<Text>{weapon.name}</Text>
</Box>
<Box sx={{ fontSize: 1, textAlign: 'center' }}>
{'⭐'.repeat(weapon.rarity)}
</Box>
</PageLink>
</Card>
)
}
export default WeaponCard