Skip to content

Commit 7f91ba4

Browse files
authored
Merge pull request #266 from Web-Dev-Path/refactor/to-scss-Wrapper
CSS modeules migration for Wrapper Component
2 parents 1d94296 + 52e6554 commit 7f91ba4

File tree

7 files changed

+23
-21
lines changed

7 files changed

+23
-21
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
173173
- Member
174174
- Row
175175
- Container
176+
- Wrapper
176177
- Updated ContactUsForm's checkbox wrapper from div to label to enhance its accessibility
177178
- Updated SearchInput width to 100% for better styling
178179
- Reverted the prop name to styles in Container component as the change of the name introduced a styling bug
179180
- Rename RowAlignLeft to Row
180-
- Extracted :root from themes.scss to globals.scss
181+
- Extracted :root from themes.scss to globals.scss
182+
- Created a combineClasses function to clean up conditional class handling
183+

components/buttons/ButtonLink/index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import styles from './ButtonLink.module.scss';
2+
import { combineClasses } from '@/utils/classnames';
23

34
export default function ButtonLink({
45
link,
56
children,
67
customBtnClass,
78
openNewTab,
89
}) {
9-
const buttonClass = customBtnClass
10-
? `${styles.buttonLink} ${styles[customBtnClass]}`
11-
: styles.buttonLink;
12-
10+
const buttonClass = combineClasses(styles.buttonLink, customBtnClass, styles);
1311
return (
1412
<a
1513
href={link}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.wrapper {
2+
padding: 1rem 0;
3+
4+
&.primary__accent {
5+
background-color: var(--color-primary-accent);
6+
}
7+
}
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import S from './styles';
1+
import styles from './Wrapper.module.scss';
2+
import { combineClasses } from '@/utils/classnames';
23

34
export default function Wrapper({ customClass, children }) {
4-
return <S.Wrapper $colorVarient={customClass}>{children}</S.Wrapper>;
5+
const wrapperClass = combineClasses(styles.wrapper, customClass, styles);
6+
return <div className={wrapperClass}>{children}</div>;
57
}

components/containers/Wrapper/styles.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

styles/globals.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
--color-grey: #d9d9d9;
88
--color-white: #ffffff;
99
--color-light-bg: #8cd5e8;
10+
--color-primary-accent: #ffcc4c;
1011
--color-primary-content: #292929;
1112
--color-transparent: transparent;
1213
--color-box-shadow: rgba(0, 0, 0, 0.08);

utils/classnames.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export function combineClasses(baseClass, customClassName, styles) {
2+
return customClassName && styles[customClassName]
3+
? `${baseClass} ${styles[customClassName]}`
4+
: baseClass;
5+
}

0 commit comments

Comments
 (0)