@@ -51,9 +51,20 @@ const atomicComponent = (
5151 let styledComponentsType = "styled-components" ;
5252 let baseComponent = "div" ;
5353 let testId = "data-testid" ;
54- let withClassNameClassName = `className={${
55- IS_FUNCTIONAL ? "" : "this."
56- } props.className} `;
54+
55+ let classNames = [ ] ;
56+ classNames . push ( `${ IS_FUNCTIONAL ? "" : "this." } props.className` ) ;
57+
58+ if ( ! WITH_STYLED_COMPONENTS ) {
59+ classNames . push ( "styles.root" ) ;
60+ }
61+
62+ let withClassNameClassName = `className={[${ classNames } ].join()} ` ;
63+
64+ if ( WITH_STYLED_COMPONENTS ) {
65+ withClassNameClassName = `className={${ classNames } } ` ;
66+ }
67+
5768 let withClassNameProps = "interface Props extends PropsWithClassName" ;
5869 let withClassNameImport = `import {PropsWithClassName} from '${ fullConfig . withClassnameInterfaceImportPath } '` ;
5970
@@ -105,9 +116,11 @@ const atomicComponent = (
105116 let templateBaseComponent = "Root" ;
106117
107118 if ( ! WITH_STYLED_COMPONENTS ) {
108- styleImport = "" ;
119+ styleImport = `import * as styles from './${ formattedFileName } .module.scss'` ;
120+
109121 templateBaseComponent = "div" ;
110122 if ( IS_NATIVE ) {
123+ styleImport = "" ;
111124 templateBaseComponent = "Text" ;
112125 }
113126 }
@@ -219,6 +232,9 @@ const atomicComponent = (
219232 } ) ;
220233 }
221234 let stylesTemplateFile = CURRENT_DIR + "/templates/styles.hbs" ;
235+ if ( WITH_STYLED_COMPONENTS ) {
236+ stylesTemplateFile = CURRENT_DIR + "/templates/stylesStyledComponents.hbs" ;
237+ }
222238
223239 if ( fullConfig . templateStyles !== undefined ) {
224240 if ( fs . existsSync ( fullConfig . templateStyles ) ) {
@@ -230,7 +246,9 @@ const atomicComponent = (
230246 type : "add" ,
231247 path :
232248 fullConfig . basePath +
233- `/${ formattedType } /${ formattedDirName } /${ formattedFileName } .styles.ts` ,
249+ `/${ formattedType } /${ formattedDirName } /${ formattedFileName } .${
250+ WITH_STYLED_COMPONENTS ? "styles.ts" : "module.scss"
251+ } `,
234252 templateFile : stylesTemplateFile ,
235253 data,
236254 } ) ;
0 commit comments