Skip to content

Commit 603fc36

Browse files
Add h4 serializer and update duotoneLight colors
1 parent 844cc5b commit 603fc36

File tree

4 files changed

+177
-20
lines changed

4 files changed

+177
-20
lines changed

web/colorsAndThemes.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ const themes = {
3333
iconSrc: '/moon.svg',
3434
iconAlt: 'Icon of sun for "Light Mode" theme',
3535
syntax: duotoneLight,
36-
asideBackground: duotoneLight.plain.backgroundColor,
36+
asideBackground: '#fdfcfb',
37+
// asideBackground: duotoneLight.plain.backgroundColor,
3738
articleLinks: colors.articleLinksLight,
3839
listItemBgColor: 'white'
3940
}

web/package-lock.json

Lines changed: 153 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
"dependencies": {
77
"@apollo/react-hooks": "^3.1.5",
88
"@sanity/client": "^1.150.7",
9+
"@types/jest": "^26.0.15",
10+
"@types/node": "^14.14.8",
11+
"@types/react": "^16.9.56",
12+
"@types/react-dom": "^16.9.9",
913
"@zeit/next-css": "^1.0.1",
1014
"apollo-boost": "^0.4.9",
1115
"graphql": "^14.7.0",
@@ -17,7 +21,8 @@
1721
"react": "^16.13.1",
1822
"react-dom": "^16.13.1",
1923
"styled-components": "^5.2.0",
20-
"swr": "^0.1.18"
24+
"swr": "^0.1.18",
25+
"typescript": "^4.0.5"
2126
},
2227
"devDependencies": {
2328
"@svgr/webpack": "^5.4.0",

web/pages/posts/[slug].js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ const MainContent = styled.div`
1515
font-size: 1.25em;
1616
line-height: 1.75em;
1717
`
18-
// const PostTitle = styled.h2`
19-
// `
2018
const PostDescription = styled.p`
2119
font-size: 1.3em;
2220
font-weight: 600;
@@ -45,8 +43,9 @@ const Pre = styled.pre`
4543
font-size: .80em;
4644
overflow: auto;
4745
text-align: left;
48-
margin: 1em 0;
46+
margin: 0 0 1em;
4947
padding: 0.5em;
48+
background-color: ${({ theme }) => theme.asideBackground};
5049
/* TODO: is this really doing much? */
5150
& .token-line {
5251
line-height: 1.4em;
@@ -99,16 +98,21 @@ const H3 = styled.h3`
9998
margin-top: 1.5em;
10099
font-family: 'Cuprum', sans-serif;
101100
`
101+
const H4 = styled.h4`
102+
font-size: 1.25em;
103+
font-weight: bold;
104+
margin: 1.5em 0 0;
105+
font-family: 'Cuprum', sans-serif;
106+
`
102107
const UL = styled.ul`
103108
margin-bottom: 15px;
104109
`
105-
106110
const InfoIcon = styled.img`
107111
float: left;
108112
margin: 0 15px 0 0;
109113
border-radius: 50%;
110114
background-color: ${({ theme }) => theme.secondaryColor};
111-
box-shadow: ${({ theme }) => `0 0 15px ${theme.secondaryColor}`};
115+
box-shadow: ${({ theme }) => `0 0 20px ${theme.secondaryColor}`};
112116
@media screen and (max-width: 600px) {
113117
margin: 0 5px 0 0;
114118
}
@@ -120,6 +124,7 @@ const ListItem = styled.li`
120124
list-style-type: square;
121125
color: ${({ theme }) => theme.text};
122126
`
127+
123128
function Post(props) {
124129
const [articleBtmPos, setArticleBtmPos] = useState(0)
125130
// console.log('Post props: ', props)
@@ -189,6 +194,9 @@ function Post(props) {
189194
else if (section.style === 'h3') {
190195
blockContent.push(<H3 key={section._key}>{section.children[0].text}</H3>)
191196
}
197+
else if (section.style === 'h4') {
198+
blockContent.push(<H4 key={section._key}>{section.children[0].text}</H4>)
199+
}
192200
// unformatted text block
193201
else {
194202
blockContent.push(section.children[i].text)
@@ -303,17 +311,17 @@ function Post(props) {
303311
</Highlight>
304312
)
305313
}
306-
314+
// TODO: test if list rendering works correctly with multiple lists in post
307315
let list = []
308316
props.body && props.body.forEach(section => {
309-
// console.log('section._type: ', section._type)
310317
if (section.listItem) {
311318
list.push(
312-
<ListItem>{formatListItem(section.children)}</ListItem>
319+
<ListItem key={section._key}>{formatListItem(section.children)}</ListItem>
313320
)
314321
} else {
315322
if (list.length > 0) {
316323
postContent.push(
324+
// TODO: why is React key error being thrown here?
317325
<UL>{list}</UL>
318326
)
319327
list = []
@@ -353,7 +361,6 @@ function Post(props) {
353361
}
354362
})
355363

356-
357364
return (
358365
<Layout
359366
onToggleThemeClick={props.onToggleThemeClick}

0 commit comments

Comments
 (0)