Skip to content

Commit 5d8accb

Browse files
authored
Merge pull request #255 from Web-Dev-Path/refactor/to-scss-postcontent
Convert PostContent's styles from Styled Components to CSS Modules
2 parents df725c2 + 411cb5e commit 5d8accb

4 files changed

Lines changed: 22 additions & 27 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
163163
- ButtonLink
164164
- SubmitButton
165165
- AuthorBio
166+
- PostContent
166167
- SearchBar
167168
- BlogPostsContainer
168169
- RevealContentContainer
169-
170170
- Updated ContactUsForm's checkbox wrapper from div to label to enhance its accessibility
171171
- Updated SearchInput width to 100% for better styling

components/blog/PostContent/styles.js renamed to components/blog/PostContent/PostContent.module.scss

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
import styled, { css } from 'styled-components';
2-
3-
const P = styled.p`
1+
.subtitle {
42
font-size: 2rem;
53
font-style: italic;
64
text-align: left;
75
line-height: normal;
86
margin: 2rem 0;
9-
`;
10-
const SubTitle = styled(P)``;
7+
}
118

12-
const ContentContainer = styled.div`
9+
.contentContainer {
1310
a {
14-
color: ${({ theme }) => theme.colors.blue};
11+
color: var(--color-blue);
1512
}
1613
.article-body-image-wrapper {
1714
display: flex;
@@ -44,29 +41,23 @@ const ContentContainer = styled.div`
4441
font-size: 1rem;
4542
padding: 1rem;
4643
border-radius: 0.5rem;
47-
background-color: ${({ theme }) => theme.colors.black};
48-
color: ${({ theme }) => theme.colors.white};
44+
background-color: var(--color-black);
45+
color: var(--color-white);
4946
overflow-x: scroll;
5047
}
5148
.highlight__panel-action.js-fullscreen-code-action {
5249
display: none;
5350
}
54-
`;
51+
}
5552

56-
const ImageWrapper = styled.div`
53+
.imageWrapper {
5754
position: relative;
5855
max-width: 828px;
5956
height: 348px;
6057
margin: 0 auto;
6158
img {
62-
border-color: ${({ theme }) => theme.colors.darkGrey};
59+
border-color: var(--color-dark-grey);
6360
border-radius: 10px;
6461
object-fit: contain;
6562
}
66-
`;
67-
68-
export default {
69-
SubTitle,
70-
ContentContainer,
71-
ImageWrapper,
72-
};
63+
}
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1-
import S from './styles';
1+
import styles from './PostContent.module.scss';
22
import Image from 'next/image';
33
import Container from '@/components/containers/Container';
4+
45
export default function PostContent({ post }) {
56
const publishedDate = post.published_at.split('T')[0];
67
return (
78
<Container>
89
<h1>{post.title}</h1>
9-
<S.SubTitle>{`${post.user.name}\u00A0\u00A0\u00A0${publishedDate}`}</S.SubTitle>
10-
10+
<p
11+
className={styles.subtitle}
12+
>{`${post.user.name}\u00A0\u00A0\u00A0${publishedDate}`}</p>
1113
{post.cover_image && (
12-
<S.ImageWrapper>
14+
<div className={styles.imageWrapper}>
1315
<Image src={post.cover_image} alt='Blog post cover' fill />
14-
</S.ImageWrapper>
16+
</div>
1517
)}
16-
<S.ContentContainer>
18+
<div className={styles.contentContainer}>
1719
<div dangerouslySetInnerHTML={{ __html: post.body_html }} />
18-
</S.ContentContainer>
20+
</div>
1921
</Container>
2022
);
2123
}

styles/themes.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
:root {
22
--bg-contact-card: #ffffff;
33
--bg-color: #eaeaea;
4+
--color-black: #000000;
5+
--color-blue: #0000ee;
46
--color-dark-grey: #9ba39d;
57
--color-grey: #d9d9d9;
68
--color-white: #ffffff;

0 commit comments

Comments
 (0)