-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(Wallet): Big cards grid #448
Changes from 14 commits
fa2b39c
2d80dab
480cf9c
8b2e74e
9abc451
9c0ab22
d9382bc
67c7719
9055bba
1b6bbd9
d2ec259
6db7d08
4947625
6ce6722
b5eeca0
2963ef4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,24 @@ | ||||||
import { Container, Grid } from '@mui/material' | ||||||
import type { BaseBlock } from '@/components/Home/types' | ||||||
import layoutCss from '@/components/common/styles.module.css' | ||||||
import getComponentByName from '@/lib/getComponentByName' | ||||||
|
||||||
const BigCardsGrid = ({ items }: { items: Array<BaseBlock['items'] & { component: string }> }) => ( | ||||||
<Container className={layoutCss.containerShort}> | ||||||
<Grid container spacing={{ xs: '30px', xl: '50px' }}> | ||||||
{items?.map((item, index) => { | ||||||
const { component } = item | ||||||
|
||||||
const CardComponent = getComponentByName(`${component}`, () => <></>) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to fallback to an "empty" component?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's a suitable fallback. Do you have any other suggestion? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure - I'll leave it up to you. |
||||||
|
||||||
return ( | ||||||
<Grid key={index} item xs={12} md={6}> | ||||||
<CardComponent {...item} /> | ||||||
</Grid> | ||||||
) | ||||||
})} | ||||||
</Grid> | ||||||
</Container> | ||||||
) | ||||||
|
||||||
export default BigCardsGrid |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Typography } from '@mui/material' | ||
import type { BaseBlock } from '@/components/Home/types' | ||
import css from './styles.module.css' | ||
|
||
const BigImageCard = ({ caption, title, text, image }: BaseBlock) => ( | ||
<div className={css.card}> | ||
<Typography variant="caption">{caption}</Typography> | ||
|
||
<img {...image} className={css.image} /> | ||
|
||
<Typography variant="h4" className={css.title}> | ||
{title} | ||
</Typography> | ||
|
||
{text ? <Typography color="primary.light">{text}</Typography> : null} | ||
</div> | ||
) | ||
|
||
export default BigImageCard |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.card { | ||
outline: 1px solid var(--mui-palette-border-light); | ||
border-radius: 16px; | ||
padding: 16px; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: flex-start; | ||
text-align: center; | ||
height: 100%; | ||
} | ||
|
||
.image { | ||
width: 240px; | ||
} | ||
|
||
.title { | ||
width: 80%; | ||
margin-bottom: 24px; | ||
} | ||
|
||
@media (min-width: 600px) { | ||
.card { | ||
padding: 32px; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,4 @@ | ||
import walletContent from '@/content/wallet.json' | ||
import type { getStaticProps } from '@/pages/wallet' | ||
import type { InferGetStaticPropsType } from 'next' | ||
import ChainsContext from '@/contexts/ChainsContext' | ||
import PageContent from '../common/PageContent' | ||
|
||
export const Wallet = (props: InferGetStaticPropsType<typeof getStaticProps>) => ( | ||
<ChainsContext.Provider value={props.chainsData}> | ||
<PageContent content={walletContent} path="wallet.json" /> | ||
</ChainsContext.Provider> | ||
) | ||
export const Wallet = () => <PageContent content={walletContent} path="wallet.json" /> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,6 @@ | ||
import type { InferGetStaticPropsType, NextPage } from 'next' | ||
import type { NextPage } from 'next' | ||
import { Wallet } from '@/components/Wallet' | ||
import { loadChainsData } from '@/lib/loadChainsData' | ||
|
||
const WalletPage: NextPage<InferGetStaticPropsType<typeof getStaticProps>> = (props) => { | ||
return <Wallet {...props} /> | ||
} | ||
|
||
export async function getStaticProps() { | ||
const chainsData = await loadChainsData() | ||
|
||
return { | ||
props: { | ||
chainsData, | ||
}, | ||
} | ||
} | ||
const WalletPage: NextPage = () => <Wallet /> | ||
|
||
export default WalletPage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there are no items, this will still render the
Container
. Is this expected?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The content is static so I think this can't really become an issue but I made it render conditionally nevertheless. Thanks for the catch.