Skip to content

Commit 089f94d

Browse files
authored
Refactor: styled-components to CSS modules - initial setup and contactUs cards
Migrating project back to CSS Modules with SCSS from style-components
2 parents d19fa2a + a78ce1f commit 089f94d

File tree

9 files changed

+104
-12
lines changed

9 files changed

+104
-12
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
152152
- Updated outdated dependencies
153153

154154
### Fixed
155+
156+
### Changed
157+
- Started migrating styles from Styled Components to CSS Modules (ContactUsCard)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.contactCards {
2+
background-color: var(--bg-contact-card);
3+
}

components/ContactUsCards.js renamed to components/ContactUs/ContactUsCards/index.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import { ContactCardsColumns } from './containers/CardColumns/ContactCardsColumns';
2-
import RevealContentContainer from './containers/RevealContentContainer';
3-
import styled from 'styled-components';
1+
import { ContactCardsColumns } from '../../containers/CardColumns/ContactCardsColumns';
2+
import RevealContentContainer from '../../containers/RevealContentContainer';
3+
import styles from './ContactUsCards.module.scss';
44

55
const cards = [
6-
76
{
87
title: 'FAQ',
98
image: '/images/svg/faq-icon.svg',
@@ -31,16 +30,12 @@ const cards = [
3130
},
3231
];
3332

34-
const ContactCardsContainer = styled.div`
35-
background-color: ${({ theme }) => theme.colors.white};
36-
`;
37-
3833
export default function ContactUsCards() {
3934
return (
40-
<ContactCardsContainer>
35+
<article className={styles.contactCards}>
4136
<RevealContentContainer>
4237
<ContactCardsColumns cards={cards} />
4338
</RevealContentContainer>
44-
</ContactCardsContainer>
39+
</article>
4540
);
4641
}

pages/_app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import Layout from '@/components/layout/Layout';
22
import { useState } from 'react';
33
import { ThemeProvider } from 'styled-components';
44
import { lightTheme, darkTheme, GlobalStyles } from '@/styles/themeConfig';
5+
import '@/styles/index.scss';
56

67
function MyApp({ Component, pageProps }) {
7-
88
// Only uncomment when the darkTheme is set
99
// const [theme, setTheme] = useState('light');
1010
// const toggleTheme = () => {

pages/contact.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useState } from 'react';
22
import ContactUsFormSubscribe from '@/components/ContactUs';
3-
import ContactUsCards from '@/components/ContactUsCards';
3+
import ContactUsCards from '@/components/ContactUs/ContactUsCards';
44
import S from '@/styles/pages/contactStyles';
55

66
export default function ContactUs() {

styles/_mixins.scss

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
@use './variables' as *;
2+
3+
@mixin transition($args...) {
4+
-webkit-transition: $args;
5+
-moz-transition: $args;
6+
-ms-transition: $args;
7+
-o-transition: $args;
8+
transition: $args;
9+
}
10+
11+
@mixin tablet {
12+
@media (min-width: $tablet-breakpoint) {
13+
@content;
14+
}
15+
}
16+
17+
@mixin desktop {
18+
@media (min-width: $desktop-breakpoint) {
19+
@content;
20+
}
21+
}
22+
23+
@mixin desktop-breakpoint-plus {
24+
@media (min-width: $desktop-breakpoint-plus) {
25+
@content;
26+
}
27+
}
28+
29+
@mixin medium-desktop {
30+
@media (min-width: $medium-desktop-breakpoint) {
31+
@content;
32+
}
33+
}
34+
35+
@mixin large-desktop {
36+
@media (min-width: $large-desktop-breakpoint) {
37+
@content;
38+
}
39+
}
40+
41+
@mixin desktop-breakpoint-minus {
42+
@media (max-width: $desktop-breakpoint-minus) {
43+
@content;
44+
}
45+
}
46+
47+
@mixin mobile {
48+
@media (max-width: $lg-mobile-breakpoint) {
49+
@content;
50+
}
51+
}
52+
53+
@mixin small-mobile {
54+
@media (max-width: $sm-mobile-breakpoint) {
55+
@content;
56+
}
57+
}

styles/_variables.scss

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Media Query Breakpoints
2+
$sm-mobile-breakpoint: 350px;
3+
$mobile-breakpoint: 578px;
4+
$lg-mobile-breakpoint: 767px;
5+
$tablet-breakpoint: 768px;
6+
$desktop-breakpoint-minus: 1023px;
7+
$desktop-breakpoint: 1024px;
8+
$desktop-breakpoint-plus: 1025px;
9+
$medium-desktop-breakpoint: 1250px;
10+
$large-desktop-breakpoint: 1440px;
11+
$extra-large-breakpoint: 2560px;
12+
13+
//Fonts
14+
$copy-font: 'Assistant';
15+
$heading-font: 'Open Sans';

styles/index.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@use './themes';
2+
@use './mixins';
3+
@use './variables';

styles/themes.scss

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
:root {
2+
--bg-contact-card: #ffffff;
3+
--bg-color: #eaeaea;
4+
}
5+
6+
// placeholder colors
7+
[data-theme='dark'] {
8+
--bg-contact-card: #232431;
9+
--bg-color: #333;
10+
}
11+
12+
// Theming notes:
13+
/*
14+
Set document data-theme to dark to activate dark theme, for example
15+
document.documentElement.setAttribute('data-theme', 'dark');
16+
*/

0 commit comments

Comments
 (0)