@@ -12,13 +12,13 @@ const PostImg = styled.img`
1212 transition: opacity 400ms ease 0ms;
1313 /* width: 100%; */
1414 /* TODO: what exactly were these supposed to be doing? */
15- /* top: 0;
16- left: 0;
17- display: block; */
15+ /* top: 0; */
16+ /* left: 0; */
17+ /* display: block; */
1818`
1919const PostLqipImg = styled ( PostImg ) `
2020 position: absolute;
21- /* width: 100%; */
21+ width: 100%;
2222 /* TODO: what exactly were these supposed to be doing? */
2323 /* transform: scale(1);
2424 transition: visibility 0ms ease 400ms; */
@@ -27,43 +27,37 @@ const PhotoCredit = styled.p`
2727 text-align: center;
2828`
2929
30- function PostImage ( props ) {
31- console . log ( 'Image props : ' , props )
30+ function PostImage ( { postImg } ) {
31+ // console.log('postImg : ', postImg )
3232 const [ isLoaded , setIsLoaded ] = useState ( false ) ;
33- // const [fullImgUrl, setFullImgUrl] = useState(null)
34- // const [lqipImgUrl, setLqipImgUrl] = useState(null)
35- // console.log('isLoaded: ', isLoaded)
36-
37- // useEffect(() => {
38- // console.log('useEffect')
39- // }, [])
40-
41- // function handleOnLoad() {
42- // console.log('handleOnLoad: ', isLoaded)
43- // }
44-
33+ const { width, height } = postImg . metadata . dimensions
34+ // console.log('with/height: ', width + "/" + height)
4535 return (
4636 < PostImgContainer >
4737 < PostLqipImg
48- src = { props . postImg . metadata . lqip }
49- alt = { `Image of ${ props . postImg . description } by ${ props . postImg . creditLine } ` }
38+ src = { postImg . metadata . lqip }
39+ alt = { `Image of ${ postImg . description } by ${ postImg . creditLine } ` }
5040 style = { { visibility : isLoaded ? "hidden" : "visible" } }
41+ width = { width }
42+ height = { height }
5143 />
5244
5345 < PostImg
5446 // key set to unique value ensures that LQIP image doesn't persist on page refresh
5547 key = { Date . now ( ) }
5648 onLoad = { ( ) => setIsLoaded ( true ) }
57- src = { props . postImg . url }
58- alt = { `Image of ${ props . postImg . description } by ${ props . postImg . creditLine } ` }
49+ src = { postImg . url }
50+ alt = { `Image of ${ postImg . description } by ${ postImg . creditLine } ` }
5951 // TODO: move these style tags to Styled Components?
6052 style = { { opacity : isLoaded ? 1 : 0 } }
53+ width = { width }
54+ height = { height }
6155 />
6256
6357 < PhotoCredit >
6458 Photo by
65- < a href = { props . postImg . source . url } target = "_blank" >
66- { props . postImg . creditLine . replace ( 'by Unsplash' , ' ' ) }
59+ < a href = { postImg . source . url } target = "_blank" >
60+ { postImg . creditLine . replace ( 'by Unsplash' , ' ' ) }
6761 </ a >
6862 on < a href = "https://unsplash.com/" target = "_blank" > Unsplash</ a >
6963 </ PhotoCredit >
0 commit comments