From 47f6a5c1bd404caff465d6792e6915a39c03f3a8 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Tue, 27 Dec 2022 19:18:59 -0800 Subject: [PATCH] Make GridRep flexible --- components/GridRep/index.scss | 61 +++++++++++++------------ components/GridRep/index.tsx | 9 ++-- components/GridRepCollection/index.scss | 9 ++-- 3 files changed, 39 insertions(+), 40 deletions(-) diff --git a/components/GridRep/index.scss b/components/GridRep/index.scss index 1bdd076d..f36667a1 100644 --- a/components/GridRep/index.scss +++ b/components/GridRep/index.scss @@ -2,11 +2,12 @@ aspect-ratio: 3/2; border-radius: $card-corner; box-sizing: border-box; - display: flex; - flex-direction: column; + display: grid; + grid-template-rows: 1fr 1fr; gap: $unit; padding: $unit-2x; - max-width: 320px; + min-width: 320px; + width: 100%; &:hover { background: var(--grid-rep-hover); @@ -20,56 +21,58 @@ cursor: pointer; } - .Grid .weapon { + .Grid .Weapon { box-shadow: inset 0 0 0 1px var(--grid-border-color); } @include breakpoint(phone) { background: inherit; - .Grid .weapon { + .Grid .Weapon { box-shadow: none; } } } - .Grid { - display: flex; - flex-direction: row; - flex-shrink: 0; - gap: $unit; + & > .Grid { + aspect-ratio: 2/1; + display: grid; + grid-template-columns: 1fr 3fr; /* left column takes up 1 fraction, right column takes up 3 fractions */ + grid-template-rows: repeat( + 3, + 1fr + ); /* create 3 rows, each taking up 1 fraction */ + grid-gap: $unit; /* add a gap of 8px between grid items */ - .weapon { + .Weapon { background: var(--card-bg); border-radius: 4px; } - .grid_mainhand { - $d: 64px; - aspect-ratio: 200 / 418; - height: auto; - max-width: $d; - min-width: $d; + .Mainhand.Weapon { + grid-column: 1 / 2; /* spans one column */ } - .grid_weapons { - $p: 29.5%; - box-sizing: border-box; - display: grid; - grid-template-columns: fit-content($p) fit-content($p) fit-content($p); - grid-template-rows: fit-content($p) fit-content($p) fit-content($p); + .GridWeapons { + display: grid; /* make the right-images container a grid */ + grid-template-columns: repeat( + 3, + 1fr + ); /* create 3 columns, each taking up 1 fraction */ + grid-template-rows: repeat( + 3, + 1fr + ); /* create 3 rows, each taking up 1 fraction */ gap: $unit; - margin: 0; - padding: 0; - width: 100%; } - .grid_weapon { + .Grid.Weapon { aspect-ratio: 160 / 92; + display: grid; } - .grid_mainhand img[src*='jpg'], - .grid_weapon img[src*='jpg'] { + .Mainhand.Weapon img[src*='jpg'], + .Grid.Weapon img[src*='jpg'] { border-radius: 4px; width: 100%; height: 100%; diff --git a/components/GridRep/index.tsx b/components/GridRep/index.tsx index 105bbfbd..f1b2c6af 100644 --- a/components/GridRep/index.tsx +++ b/components/GridRep/index.tsx @@ -212,15 +212,12 @@ const GridRep = (props: Props) => { {props.displayUser ? detailsWithUsername : details}
-
{generateMainhandImage()}
+
{generateMainhandImage()}
-
    +
      {Array.from(Array(numWeapons)).map((x, i) => { return ( -
    • +
    • {generateGridImage(i)}
    • ) diff --git a/components/GridRepCollection/index.scss b/components/GridRepCollection/index.scss index 93098ba3..8471bbd2 100644 --- a/components/GridRepCollection/index.scss +++ b/components/GridRepCollection/index.scss @@ -1,21 +1,20 @@ .GridRepCollection { + box-sizing: border-box; display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); margin: 0 auto; padding: 0; transition: opacity 0.14s ease-in-out; justify-items: center; - // width: fit-content; - width: auto; + width: 100%; max-width: 996px; @include breakpoint(tablet) { - grid-template-columns: minmax(320px, 1fr); + grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); max-width: inherit; - width: 100%; } - @include breakpoint(tablet) { + @include breakpoint(phone) { grid-template-columns: 1fr; max-width: inherit; width: 100%;