Skip to content

Commit c70ec7e

Browse files
Render LQIP and photo credit
1 parent 551cf5d commit c70ec7e

File tree

10 files changed

+4535
-4090
lines changed

10 files changed

+4535
-4090
lines changed

web/components/GlobalStyles.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const GlobalStyles = createGlobalStyle`
1212
margin: 0;
1313
padding: 0;
1414
box-sizing: border-box;
15-
font-weight: 300;
15+
font-weight: 400;
1616
color: ${({ theme }) => theme.primaryColor};
1717
}
1818
@@ -54,7 +54,6 @@ export const GlobalStyles = createGlobalStyle`
5454
font-family: 'Nanum Gothic Coding', monospace;
5555
&:hover {
5656
cursor: pointer;
57-
/* background-color: var(--primary-darker); */
5857
}
5958
}
6059

web/components/Layout.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,15 @@ const Header = styled.header`
1616
justify-content: space-between;
1717
align-items: center;
1818
`
19-
const H1 = styled.h1`
19+
const SiteTitleH1 = styled.h1`
2020
font-size: 1.5em;
2121
`
22+
const SiteTitleText = styled.a`
23+
font-weight: 300;
24+
&:hover {
25+
cursor: pointer;
26+
}
27+
`
2228
const ToggleBtn = styled.img`
2329
height: 1.8em;
2430
width: 1.8em;
@@ -53,7 +59,7 @@ function Layout(props) {
5359
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"/>
5460
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"/>
5561
<link rel="manifest" href="/site.webmanifest"/>
56-
<link href="https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@200;300;400&display=swap" rel="stylesheet"/>
62+
<link href="https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@200;300;400;600&display=swap" rel="stylesheet"/>
5763
<link href="https://fonts.googleapis.com/css2?family=Nanum+Gothic+Coding&display=swap" rel="stylesheet"/>
5864
<link href="https://fonts.googleapis.com/css2?family=Cuprum&family=Fjalla+One&display=swap" rel="stylesheet"/>
5965
<link href="https://fonts.googleapis.com/css2?family=Cutive+Mono&display=swap" rel="stylesheet"/>
@@ -62,11 +68,11 @@ function Layout(props) {
6268

6369
<Header>
6470
<nav>
65-
<H1>
71+
<SiteTitleH1>
6672
<Link href='/'>
67-
<a>Jason Roundtree - Blog</a>
73+
<SiteTitleText>Jason Roundtree - Blog</SiteTitleText>
6874
</Link>
69-
</H1>
75+
</SiteTitleH1>
7076
{/* <Span>a web dev blog, by </Span><a href='http://jasonroundtree.info/' target="_blank">jason roundtree</a> */}
7177
</nav>
7278
<ToggleBtn

web/components/PostImg.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { useState } from 'react'
2+
import styled from 'styled-components'
3+
4+
const PostImgContainer = styled.div`
5+
position: relative;
6+
margin: 2.5em 0;
7+
`
8+
const PostImg = styled.img`
9+
position: relative;
10+
top: 0;
11+
left: 0;
12+
display: block;
13+
width: 100%;
14+
transition: opacity 400ms ease 0ms;
15+
`
16+
const PostLqipImg = styled(PostImg)`
17+
position: absolute;
18+
width: 100%;
19+
filter: blur(10px);
20+
transform: scale(1.1);
21+
transition: visibility 0ms ease 400ms;
22+
`
23+
const PhotoCredit = styled.p`
24+
text-align: center;
25+
`
26+
27+
function PostImage(props) {
28+
console.log('PI props: ', props)
29+
const [isLoaded, setIsLoaded] = useState(false);
30+
return (
31+
<PostImgContainer>
32+
<PostImg
33+
onLoad={() => setIsLoaded(true)}
34+
src={props.postImg.url}
35+
alt={`Image of ${props.postImg.description} by ${props.postImg.creditLine}`}
36+
style={{ opacity: isLoaded ? 1 : 0 }}
37+
/>
38+
39+
<PostLqipImg
40+
src={props.postImg.metadata.lqip}
41+
alt={`Image of ${props.postImg.description} by ${props.postImg.creditLine}`}
42+
style={{ visibility: isLoaded ? "hidden" : "visible" }}
43+
/>
44+
45+
<PhotoCredit>
46+
Photo by 
47+
<a href={props.postImg.source.url} target="_blank">
48+
{props.postImg.creditLine.replace('by Unsplash', ' ')}
49+
</a>
50+
on <a href="https://unsplash.com/" target="_blank">Unsplash</a>
51+
</PhotoCredit>
52+
</PostImgContainer>
53+
)
54+
}
55+
56+
export default PostImage

0 commit comments

Comments
 (0)