Fix styling for GridReps and add new information

This commit is contained in:
Justin Edmund 2022-02-26 17:46:32 -08:00
parent ea37cf6a79
commit 2a148db4c3
3 changed files with 117 additions and 60 deletions

View file

@ -1,54 +1,82 @@
.GridRep { .GridRep {
border: 2px solid transparent;
border-radius: 6px; border-radius: 6px;
display: flex;
flex-direction: column;
gap: $unit;
padding: $unit * 2;
&:hover {
background: white;
cursor: pointer;
.Grid .grid_weapons .grid_weapon {
box-shadow: inset 0 0 1px $grey-70;
}
}
.Grid {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
flex-shrink: 0; flex-shrink: 0;
margin: 0 8px 8px 0;
padding: 4px; .grid_mainhand {
height: 148px; margin-right: $unit;
width: 311px; height: 139px;
width: auto;
} }
.GridRep:hover { .grid_weapons {
border: 2px solid #2360C5; display: grid;
cursor: pointer; grid-template-columns: 1fr 1fr 1fr;
} grid-template-rows: 1fr 1fr 1fr;
gap: $unit;
.GridRep .weapon {
background: white;
border-radius: 4px;
}
.GridRep .grid_mainhand {
flex-shrink: 0;
height: 136px;
width: 65px;
margin-right: 8px;
}
.GridRep .grid_weapons {
list-style: none;
margin: 0; margin: 0;
padding: 0; padding: 0;
width: fit-content;
} }
.GridRep .grid_weapon { .grid_weapon {
background: white; background: white;
border-radius: 4px; border-radius: 4px;
float: left; float: left;
margin: 0 8px 8px 0;
height: 40px; height: 40px;
width: 70px; width: 70px;
} }
.GridRep .grid_weapon:nth-child(3n+3) { .grid_mainhand img[src*="jpg"],
margin-right: 0; .grid_weapon img[src*="jpg"] {
}
.GridRep .grid_mainhand img[src*="jpg"],
.GridRep .grid_weapon img[src*="jpg"] {
border-radius: 4px; border-radius: 4px;
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
}
.Details {
display: flex;
flex-direction: column;
gap: $unit / 2;
h2 {
color: $grey-00;
font-size: $font-regular;
&.empty {
color: $grey-50;
}
}
.bottom {
display: flex;
flex-direction: row;
}
.raid, time {
color: $grey-50;
font-size: $font-small;
}
.raid {
flex-grow: 1;
}
}
}

View file

@ -1,19 +1,37 @@
import React, { useEffect, useState } from 'react' import React, { useEffect, useState } from 'react'
import classNames from 'classnames'
import { formatTimeAgo } from '~utils/timeAgo'
import './index.scss' import './index.scss'
interface Props { interface Props {
shortcode: string shortcode: string
name: string
raid: Raid
grid: GridWeapon[] grid: GridWeapon[]
updatedAt: Date
onClick: (shortcode: string) => void onClick: (shortcode: string) => void
} }
const GridRep = (props: Props) => { const GridRep = (props: Props) => {
console.log(props)
const numWeapons: number = 9 const numWeapons: number = 9
const [mainhand, setMainhand] = useState<Weapon>() const [mainhand, setMainhand] = useState<Weapon>()
const [weapons, setWeapons] = useState<GridArray<Weapon>>({}) const [weapons, setWeapons] = useState<GridArray<Weapon>>({})
const titleClass = classNames({
'empty': !props.name
})
const raidClass = classNames({
'raid': true,
'empty': !props.raid
})
useEffect(() => { useEffect(() => {
const newWeapons = Array(numWeapons) const newWeapons = Array(numWeapons)
@ -43,6 +61,15 @@ const GridRep = (props: Props) => {
return ( return (
<div className="GridRep" onClick={navigate}> <div className="GridRep" onClick={navigate}>
<div className="Details">
<h2 className={titleClass}>{ (props.name) ? props.name : 'Untitled' }</h2>
<div className="bottom">
<div className={raidClass}>{ (props.raid) ? props.raid.name.en : 'No raid set' }</div>
<time className="last-updated" dateTime={props.updatedAt.toISOString()}>{formatTimeAgo(props.updatedAt, 'en-us')}</time>
</div>
</div>
<div className="Grid">
<div className="weapon grid_mainhand"> <div className="weapon grid_mainhand">
{generateMainhandImage()} {generateMainhandImage()}
</div> </div>
@ -59,6 +86,7 @@ const GridRep = (props: Props) => {
} }
</ul> </ul>
</div> </div>
</div>
) )
} }

View file

@ -1,6 +1,7 @@
.GridRepCollection { .GridRepCollection {
display: flex; display: grid;
flex-wrap: wrap; grid-template-columns: auto auto auto;
justify-content: center; margin: 0 auto;
padding: 0; padding: 0;
width: fit-content;
} }