Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
enh: Improve home page UI. (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
xaerru authored Apr 1, 2021
1 parent 77cdf11 commit 3ec65c2
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 26 deletions.
48 changes: 27 additions & 21 deletions src/components/card-grid.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import React from 'react';
import Button from '@material-ui/core/Button';
import Card from '@material-ui/core/Card';
import CardActions from '@material-ui/core/CardActions';
import CardActionArea from '@material-ui/core/CardActionArea';
import CardContent from '@material-ui/core/CardContent';
import CardMedia from '@material-ui/core/CardMedia';
import Typography from '@material-ui/core/Typography';
import infos from '../data/dungeon-info.json';
import Grid from '@material-ui/core/Grid';
import { homeStyles } from '../utils/styles';
import ArrowForwardIcon from '@material-ui/icons/ArrowForward';
import infos from '../data/dungeon-info.json';
import { homeStyles } from '../utils/styles';

export default function CardGrid(props) {
const classes = homeStyles();
Expand All @@ -25,25 +26,30 @@ export default function CardGrid(props) {
: `${process.env.GATSBY_BASE_IMAGE_URL}${info.image}`;

return info ? (
<Grid item xs={12} sm={6} md={4}>
<Card className={classes.card}>
<CardMedia
className={classes.cardMedia}
image={defaultImage}
title={info.display}
/>
<CardContent className={classes.cardContent}>
<Typography gutterBottom variant='h5' component='h2'>
{info.display}
</Typography>
<Typography>{post.excerpt}</Typography>
</CardContent>
<CardActions dir='rtl'>
<Button size='small' color='primary' href={slug.slice(0, -1)}>
<ArrowForwardIcon />
</Button>
</CardActions>
</Card>
<Grid item xs={props.xs} sm={props.sm} md={props.md}>
<CardActionArea
href={slug.slice(0, -1)}
style={{ textDecoration: 'none' }}
>
<Card className={classes.card}>
<CardMedia
className={classes.cardMedia}
image={defaultImage}
title={info.display}
/>
<CardContent className={classes.cardContent}>
<Typography gutterBottom variant='h5' component='h2'>
{info.display}
</Typography>
<Typography>{post.excerpt}</Typography>
</CardContent>
<CardActions dir='rtl'>
<Button size='small' color='primary'>
<ArrowForwardIcon />
</Button>
</CardActions>
</Card>
</CardActionArea>
</Grid>
) : null;
}
2 changes: 1 addition & 1 deletion src/components/hide-appbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ export default function HideAppBar(props) {
</HideOnScroll>
</React.Fragment>
);
}
}
7 changes: 3 additions & 4 deletions src/pages/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import SEO from '../components/seo';
export default function Home({ data }) {
const classes = homeStyles();
const posts = data.allMarkdownRemark.nodes;

return (
<React.Fragment>
<SEO />
Expand Down Expand Up @@ -43,11 +42,11 @@ export default function Home({ data }) {
</Typography>
</Container>
</div>
<Container className={classes.cardGrid} maxWidth='md'>
<Container className={classes.cardGrid} maxWidth='lg'>
{/* End hero unit */}
<Grid container spacing={4}>
<Grid container spacing={6}>
{posts.map((post, index) => (
<CardGrid item key={index} post={post} />
<CardGrid item key={index} post={post} xs={12} sm={6} md={3} />
))}
</Grid>
</Container>
Expand Down
1 change: 1 addition & 0 deletions src/utils/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const homeStyles = makeStyles((theme) => ({
},
cardContent: {
flexGrow: 1,
textAlign: 'center',
},
footer: {
backgroundColor: theme.palette.background.paper,
Expand Down

0 comments on commit 3ec65c2

Please sign in to comment.