Fix grid rep styles

This commit is contained in:
Justin Edmund 2023-06-23 19:14:57 -07:00
parent 625031974d
commit 3ea30b4960
4 changed files with 40 additions and 36 deletions

View file

@ -1,4 +1,4 @@
.GridRep { .gridRep {
aspect-ratio: 3/2; aspect-ratio: 3/2;
border-radius: $card-corner; border-radius: $card-corner;
box-sizing: border-box; box-sizing: border-box;
@ -34,25 +34,25 @@
} }
} }
& > .Grid { & > .weaponGrid {
aspect-ratio: 2/0.95; aspect-ratio: 2/0.95;
display: grid; display: grid;
grid-template-columns: 1fr 3.36fr; /* left column takes up 1 fraction, right column takes up 3 fractions */ grid-template-columns: 1fr 3.36fr; /* left column takes up 1 fraction, right column takes up 3 fractions */
grid-gap: $unit; /* add a gap of 8px between grid items */ grid-gap: $unit; /* add a gap of 8px between grid items */
.Weapon { .weapon {
background: var(--card-bg); background: var(--card-bg);
border-radius: 4px; border-radius: 4px;
} }
.Mainhand.Weapon { .mainhand.weapon {
aspect-ratio: 73/153; aspect-ratio: 73/153;
display: grid; display: grid;
grid-column: 1 / 2; /* spans one column */ grid-column: 1 / 2; /* spans one column */
max-height: 140px; max-height: 140px;
} }
.GridWeapons { .weapons {
display: grid; /* make the right-images container a grid */ display: grid; /* make the right-images container a grid */
grid-template-columns: repeat( grid-template-columns: repeat(
3, 3,
@ -67,19 +67,19 @@
// row-gap: $unit-2x; // row-gap: $unit-2x;
} }
.Grid.Weapon { .grid.weapon {
aspect-ratio: 280 / 160; aspect-ratio: 280 / 160;
display: grid; display: grid;
} }
.Mainhand.Weapon img[src*='jpg'], .mainhand.weapon img[src*='jpg'],
.Grid.Weapon img[src*='jpg'] { .grid.weapon img[src*='jpg'] {
border-radius: 4px; border-radius: 4px;
width: 100%; width: 100%;
} }
} }
.Details { .details {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: calc($unit / 2); gap: calc($unit / 2);
@ -126,7 +126,7 @@
} }
} }
.Properties, .properties,
.user { .user {
flex-grow: 1; flex-grow: 1;
} }
@ -138,7 +138,7 @@
font-size: $font-small; font-size: $font-small;
} }
.Properties { .properties {
.auto { .auto {
display: inline-flex; display: inline-flex;
gap: $unit-half; gap: $unit-half;
@ -146,11 +146,11 @@
margin-left: $unit-half; margin-left: $unit-half;
} }
.full_auto { .fullAuto {
color: var(--full-auto-label-text); color: var(--full-auto-label-text);
} }
.auto_guard { .autoGuard {
width: 12px; width: 12px;
height: 12px; height: 12px;

View file

@ -50,13 +50,23 @@ const GridRep = (props: Props) => {
}) })
const raidClass = classNames({ const raidClass = classNames({
raid: true, [styles.raid]: true,
empty: !props.raid, [styles.empty]: !props.raid,
}) })
const userClass = classNames({ const userClass = classNames({
user: true, [styles.user]: true,
empty: !props.user, [styles.empty]: !props.user,
})
const mainhandClasses = classNames({
[styles.weapon]: true,
[styles.mainhand]: true,
})
const weaponClasses = classNames({
[styles.weapon]: true,
[styles.grid]: true,
}) })
useEffect(() => { useEffect(() => {
@ -210,18 +220,18 @@ const GridRep = (props: Props) => {
) )
const detailsWithUsername = ( const detailsWithUsername = (
<div className="Details"> <div className={styles.details}>
<div className="top"> <div className={styles.top}>
<div className="info"> <div className={styles.info}>
<h2 className={titleClass}> <h2 className={titleClass}>
{props.name ? props.name : t('no_title')} {props.name ? props.name : t('no_title')}
</h2> </h2>
<div className="Properties"> <div className={styles.properties}>
<span className={raidClass}> <span className={raidClass}>
{props.raid ? props.raid.name[locale] : t('no_raid')} {props.raid ? props.raid.name[locale] : t('no_raid')}
</span> </span>
{props.fullAuto ? ( {props.fullAuto ? (
<span className="full_auto"> <span className={styles.fullAuto}>
{` · ${t('party.details.labels.full_auto')}`} {` · ${t('party.details.labels.full_auto')}`}
</span> </span>
) : ( ) : (
@ -246,7 +256,7 @@ const GridRep = (props: Props) => {
'' ''
)} )}
</div> </div>
<div className="bottom"> <div className={styles.bottom}>
{props.user ? linkedAttribution() : unlinkedAttribution()} {props.user ? linkedAttribution() : unlinkedAttribution()}
<time className="last-updated" dateTime={props.createdAt.toISOString()}> <time className="last-updated" dateTime={props.createdAt.toISOString()}>
@ -258,15 +268,15 @@ const GridRep = (props: Props) => {
return ( return (
<Link href={`/p/${props.shortcode}`}> <Link href={`/p/${props.shortcode}`}>
<a className="GridRep"> <a className={styles.gridRep}>
{props.displayUser ? detailsWithUsername : details} {props.displayUser ? detailsWithUsername : details}
<div className="Grid"> <div className={styles.weaponGrid}>
<div className="Mainhand Weapon">{generateMainhandImage()}</div> <div className={mainhandClasses}>{generateMainhandImage()}</div>
<ul className="GridWeapons"> <ul className={styles.weapons}>
{Array.from(Array(numWeapons)).map((x, i) => { {Array.from(Array(numWeapons)).map((x, i) => {
return ( return (
<li key={`${props.shortcode}-${i}`} className="Grid Weapon"> <li key={`${props.shortcode}-${i}`} className={weaponClasses}>
{generateGridImage(i)} {generateGridImage(i)}
</li> </li>
) )

View file

@ -1,4 +1,4 @@
.GridRepCollection { .collection {
box-sizing: border-box; box-sizing: border-box;
display: grid; display: grid;
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));

View file

@ -1,6 +1,4 @@
import classNames from 'classnames'
import React from 'react' import React from 'react'
import styles from './index.module.scss' import styles from './index.module.scss'
interface Props { interface Props {
@ -8,11 +6,7 @@ interface Props {
} }
const GridRepCollection = (props: Props) => { const GridRepCollection = (props: Props) => {
const classes = classNames({ return <div className={styles.collection}>{props.children}</div>
GridRepCollection: true,
})
return <div className={classes}>{props.children}</div>
} }
export default GridRepCollection export default GridRepCollection