Skip to content

Commit

Permalink
better layout for nftGrid and account page
Browse files Browse the repository at this point in the history
  • Loading branch information
samepant committed Jan 19, 2024
1 parent 85c6338 commit 39f03b2
Show file tree
Hide file tree
Showing 10 changed files with 205 additions and 181 deletions.
15 changes: 13 additions & 2 deletions frontend/src/components/Layout/Layout.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,27 @@
flex-direction: column;
gap: 50px;
min-height: 100vh;
max-width: 2000px;
margin: 0 auto;
}

.header {
.headerContainer {
position: fixed;
top: 0;
left: 0;
z-index: 100;
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
justify-content: center;
}

.header {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
max-width: 2000px;
padding: 20px;
}

Expand Down Expand Up @@ -42,6 +52,7 @@
margin: 100px 0;
position: relative;
z-index: 10;
padding: 0 20px;
}

.nav {
Expand Down
22 changes: 12 additions & 10 deletions frontend/src/components/Layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@ const Layout: React.FC<Props> = ({ children, mechAddress }) => {
return (
<div className={classes.layout}>
<img src="/cockpit.png" alt="cockpit" className={classes.cockpit} />
<header className={classes.header}>
<div className={classes.nav}>
<Link to="/">
<h1>Mech</h1>
</Link>
<Search />
</div>
<div className={classes.buttonGroup}>
<ChainSelect />
<ConnectButton />
<header className={classes.headerContainer}>
<div className={classes.header}>
<div className={classes.nav}>
<Link to="/">
<h1>Mech</h1>
</Link>
<Search />
</div>
<div className={classes.buttonGroup}>
<ChainSelect />
<ConnectButton />
</div>
</div>
</header>
<main className={classes.main}>{children}</main>
Expand Down
37 changes: 7 additions & 30 deletions frontend/src/components/NFTGrid/NFTGrid.module.css
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
.grid {
display: flex;
flex-wrap: wrap;
justify-content: center;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
width: 100%;
gap: 20px;
margin-bottom: 20px;
width: 100%;
}

.grid li {
}

.container {
display: flex;
flex-direction: column;
align-items: center;
gap: 20px;
width: 72%;
max-width: 2000px;
margin: 0 auto;
}

Expand All @@ -30,27 +31,3 @@
border-radius: 10px;
width: fit-content;
}

.indicator {
width: 15px;
height: 15px;
border-radius: 50%;
background-color: var(--button-border);
filter: blur(4px);
}

.indicator.undeployed {
background-color: rgb(189 192 179);
}

.noDeployed {
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
background-color: var(--box-bg);
padding: 10px 15px 10px 10px;
border-radius: 20px;
aspect-ratio: 2/1;
width: 250px;
}
51 changes: 11 additions & 40 deletions frontend/src/components/NFTGrid/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ interface Props {

const NFTGrid: React.FC<Props> = ({ address }) => {
const chainId = useChainId()
console.log("chainId", chainId)
const { data, isLoading, error } = useTokenBalances({
accountAddress: address,
chainId,
Expand All @@ -33,46 +32,18 @@ const NFTGrid: React.FC<Props> = ({ address }) => {
calculateMechAddress(getNFTContext(nft), chainId).toLowerCase()
)

const deployed = nftBalances.filter(isDeployed)
const undeployed = nftBalances.filter((nft) => !isDeployed(nft))
console.log("undeployed", undeployed.length)
const nfts = nftBalances.map((nft) => ({ ...nft, deployed: isDeployed(nft) }))

if (isLoading) return <Spinner />

return (
<div className={classes.container}>
<div className={classes.categoryContainer}>
<div className={classes.category}>
<div className={classes.indicator}></div>
<h2>Deployed</h2>
</div>
</div>
{deployed.length === 0 && (
<div className={classes.noDeployed}>
<p>No mechs deployed</p>
</div>
)}
<ul className={classes.grid}>
{deployed.map((nft, index) => (
<li key={`${index}-${nft.token_address}`}>
<NFTGridItem chainId={chainId} nft={nft} />
</li>
))}
</ul>
<div className={classes.categoryContainer}>
<div className={classes.category}>
<div className={clsx(classes.indicator, classes.undeployed)}></div>
<h2>Undeployed</h2>
</div>
</div>
{undeployed.length > 0 && (
<ul className={classes.grid}>
{undeployed.map((nft, index) => (
<li key={`${index}-${nft.token_address}`}>
<NFTGridItem chainId={chainId} nft={nft} />
</li>
))}
</ul>
)}
{isLoading && <Spinner />}
</div>
<ul className={classes.grid}>
{nfts.map((nft, index) => (
<li key={`${index}-${nft.token_address}`}>
<NFTGridItem chainId={chainId} nft={nft} />
</li>
))}
</ul>
)
}

Expand Down
130 changes: 83 additions & 47 deletions frontend/src/components/NFTGridItem/NFTItem.module.css
Original file line number Diff line number Diff line change
@@ -1,30 +1,84 @@
.itemContainer {
.linkContainer {
border-radius: 20px;
background-color: var(--box-bg);
padding: 10px;
display: flex;
flex-direction: column;
gap: 10px;

text-decoration: none;
aspect-ratio: 1/1;
width: 250px;
position: relative;
text-decoration: none;
color: var(--text-color);
border: 2px solid transparent;
overflow: hidden;
}

.header {
.linkContainer:hover {
border: 2px solid var(--button-border);
}

.header,
.footer {
display: flex;
justify-content: space-between;
position: absolute;
left: 10px;
z-index: 10;
width: calc(100% - 20px);
}

.header p {
display: inline-block;
border-radius: 10px;
background-color: var(--box-bg);
background-color: rgb(246 241 212);
padding: 2px 8px;
text-overflow: ellipsis;
overflow-x: hidden;
white-space: nowrap;
}

.header {
top: 10px;
}

.footer {
display: none;
bottom: 10px;
}

.deployStatus {
display: flex;
align-items: center;
gap: 5px;
border-radius: 10px;
background-color: rgb(246 241 212);
padding: 2px 8px;
font-style: italic;
font-size: 12px;
}

.indicator {
width: 10px;
aspect-ratio: 1;
border-radius: 50%;
background-color: var(--button-border);
filter: blur(4px);
}

.indicator.undeployed {
background-color: rgb(189 192 179);
}

.chain {
display: flex;
align-items: center;
border-radius: 10px;
background-color: rgb(246 241 212);
padding: 2px 8px;
}
.chain svg {
width: 15px;
height: 15px;
}

.tokenId {
max-width: 30%;
font-family: monospace;
Expand All @@ -40,30 +94,23 @@
}

.main {
height: 63%;
display: flex;
justify-content: space-between;
aspect-ratio: 1;
}

.imageContainer {
width: 50%;
aspect-ratio: 1;
display: flex;
justify-content: center;
}

.main .image {
object-fit: contain;
object-position: top;
height: min-content;
object-fit: cover;
max-height: 100%;
border-radius: 10px;
}

.noImage {
width: 50%;
height: 100%;
background-color: var(--box-bg);
border-radius: 10px;
}

.noImage::after {
Expand All @@ -77,45 +124,34 @@
align-items: center;
}

.infoItem {
font-size: 12px;
font-family: monospace;
display: flex;
justify-content: space-between;
align-items: center;
gap: 5px;
border-radius: 10px;
background-color: var(--box-bg);
padding: 2px 8px;
height: 30px;
}

.address {
cursor: pointer;
transition: filter 0.1s ease-in-out;
}

.address:hover {
filter: brightness(1.2);
}

.spinner {
width: 100%;
display: flex;
justify-content: center;
align-items: center;
min-height: 40px;
}
.useButton {
width: 100%;
}

.chainIcon {
height: 80%;
.linkContainer:hover .footer {
display: flex;
}

.info {
.linkContainer:hover .visit {
display: flex;
}

.visit {
position: absolute;
inset: 0;
display: none;
flex-direction: column;
gap: 10px;
justify-content: center;
align-items: center;
background-color: rgb(241 255 203 / 65%);
}

.visit h3 {
font-size: 1.5em;
color: var(--button-border);
mix-blend-mode: exclusion;
}
Loading

0 comments on commit 39f03b2

Please sign in to comment.