File tree Expand file tree Collapse file tree 4 files changed +21
-9
lines changed
gatsby-theme-axii/src/components/Avatar Expand file tree Collapse file tree 4 files changed +21
-9
lines changed Original file line number Diff line number Diff line change 11import { graphql , useStaticQuery } from "gatsby" ;
22import Img from "gatsby-image" ;
33import React from "react" ;
4- import { AvatarData } from "./interfaces" ;
4+ import { AvatarData , AvatarStyle } from "./interfaces" ;
55import useStyles from "./styles" ;
66
77const 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} ;
Original file line number Diff line number Diff line change @@ -5,3 +5,8 @@ export interface AvatarData {
55 } ;
66 } ;
77}
8+
9+ export interface AvatarStyle {
10+ marginBottom : number ;
11+ marginTop : number ;
12+ }
Original file line number Diff line number Diff line change 11import { createStyles , makeStyles , Theme } from "@material-ui/core/styles" ;
2+ import { AvatarStyle } from "./interfaces" ;
23
34const 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
Original file line number Diff line number Diff 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 >
You can’t perform that action at this time.
0 commit comments