Skip to content

Commit 214d640

Browse files
committed
improvement(avatar): add marginTop and marginBottom params
1 parent 7450256 commit 214d640

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

packages/gatsby-theme-axii/src/components/Avatar/component.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { graphql, useStaticQuery } from "gatsby";
22
import Img from "gatsby-image";
33
import React from "react";
4-
import { AvatarData } from "./interfaces";
4+
import { AvatarData, AvatarStyle } from "./interfaces";
55
import useStyles from "./styles";
66

77
const query = graphql`
@@ -16,15 +16,19 @@ const query = graphql`
1616
}
1717
`;
1818

19-
const Avatar: React.FC = props => {
20-
const classes = useStyles();
19+
const Avatar: React.FC<AvatarStyle> = ({
20+
marginBottom = 0,
21+
marginTop = 0,
22+
...rest
23+
}) => {
24+
const classes = useStyles({ marginBottom, marginTop });
2125
const data: AvatarData = useStaticQuery(query);
2226

2327
return (
2428
<Img
2529
fluid={data.file.childImageSharp.fluid}
2630
className={classes.avatar}
27-
{...props}
31+
{...rest}
2832
/>
2933
);
3034
};

packages/gatsby-theme-axii/src/components/Avatar/interfaces.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,8 @@ export interface AvatarData {
55
};
66
};
77
}
8+
9+
export interface AvatarStyle {
10+
marginBottom: number;
11+
marginTop: number;
12+
}

packages/gatsby-theme-axii/src/components/Avatar/styles.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
import { createStyles, makeStyles, Theme } from "@material-ui/core/styles";
2+
import { AvatarStyle } from "./interfaces";
23

34
const useStyles = makeStyles((theme: Theme) =>
45
createStyles({
5-
avatar: {
6+
avatar: (props: AvatarStyle) => ({
7+
marginBottom: theme.spacing(props.marginBottom),
8+
marginTop: theme.spacing(props.marginTop),
69
width: "200px",
710
[theme.breakpoints.up("md")]: {
811
width: "300px"
912
},
1013
[theme.breakpoints.up("lg")]: {
1114
width: "400px"
1215
}
13-
}
16+
})
1417
})
1518
);
1619

packages/site/content/pages/index.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ import Typography from "@material-ui/core/Typography";
77
<Seo />
88
<Grid container direction="column" justify="center" alignItems="center">
99
<Grid item xs={12}>
10-
<Typography variant="h1" component="h1" align="center" gutterBottom>
10+
<Typography variant="h1" component="h1" align="center">
1111
AXII
1212
</Typography>
1313
</Grid>
1414
<Grid item xs={12}>
15-
<Avatar />
15+
<Avatar marginBottom={6} marginTop={6} />
1616
</Grid>
1717
<Grid item xs={12}>
18-
<Typography variant="h2" component="h2" align="center" gutterBottom>
18+
<Typography variant="h2" component="h2" align="center">
1919
A Gatsby blog theme.
2020
</Typography>
2121
</Grid>

0 commit comments

Comments
 (0)