Skip to content

Commit 298fbe7

Browse files
committed
Added compiler and confirmed styled components works in Title
1 parent 7852941 commit 298fbe7

File tree

3 files changed

+49
-9
lines changed

3 files changed

+49
-9
lines changed

components/snippets/Title.js

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,30 @@
1-
import styles from '@/styles/Title.module.scss';
1+
// import styles from '@/styles/Title.module.scss';
2+
import styled from 'styled-components';
23

3-
const Title = ({ title, customClass }) => {
4+
export const TitleStyle = styled.h2`
5+
color: red;
6+
`;
7+
8+
const Title = ({ title }) => {
49
return (
5-
<h2
6-
className={
7-
customClass ? `${styles.title} ${styles[customClass]}` : styles.title
8-
}
9-
>
10-
{title}
11-
</h2>
10+
<div>
11+
<TitleStyle>{title}</TitleStyle>
12+
</div>
1213
);
1314
};
1415

1516
export default Title;
17+
18+
// const Title = ({ title, customClass }) => {
19+
// return (
20+
// <h2
21+
// className={
22+
// customClass ? `${styles.title} ${styles[customClass]}` : styles.title
23+
// }
24+
// >
25+
// {title}
26+
// </h2>
27+
// );
28+
// };
29+
30+
// export default Title;

next.config.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,26 @@ module.exports = withPWA({
1919
},
2020
],
2121
},
22+
compiler: {
23+
// see https://styled-components.com/docs/tooling#babel-plugin for more info on the options.
24+
styledComponents:
25+
true |
26+
{
27+
// Enabled by default in development, disabled in production to reduce file size,
28+
// setting this will override the default for all environments.
29+
displayName: true,
30+
// Enabled by default.
31+
ssr: true,
32+
// Enabled by default.
33+
fileName: true,
34+
// Empty by default.
35+
topLevelImportPaths: '',
36+
// Defaults to ["index"].
37+
meaninglessFileNames: '',
38+
// Enabled by default.
39+
cssProp: true,
40+
// Empty by default.
41+
namespace: '',
42+
},
43+
},
2244
});

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,8 @@
3737
"lint-staged": "^13.0.3",
3838
"prettier": "^2.7.1",
3939
"prettylint": "^1.0.0"
40+
},
41+
"resolutions": {
42+
"styled-components": "^5"
4043
}
4144
}

0 commit comments

Comments
 (0)