I really dislike have css code on the js pages themselves. Is it bad practice to write the css in js components in a style folder and then reference that on the page?
2 Likes
yes you can make 1 css file which is .js file and import it where you want.
1 Like
For reference you can check in frontity twenty twenty theme styles folder
1 Like
Hi @ekline ,
Welcome to the Community!
Frontity projects are like any other Isomorphic React Apps so you can organize your code in the way that makes more sense for you.
As a reference, here you have a project that uses separated files for the styles of each component
This is the fileβs structure of the project where you can see the combination of index.js
+ styles.js
for each component
packages
βββ bootstrap-theme
βββ CHANGELOG.md
βββ package.json
βββ src
βββ components
β βββ FeaturedMedia
β β βββ index.js
β β βββ styles.js
β βββ Header
β β βββ index.js
β β βββ styles.js
β βββ Link
β β βββ index.js
β βββ List
β β βββ index.js
β βββ ListBlock
β β βββ index.js
β β βββ styles.js
β βββ ListItem
β β βββ index.js
β β βββ styles.js
β βββ ListPagination
β β βββ index.js
β β βββ styles.js
β βββ Loading
β β βββ index.js
β β βββ styles.js
β βββ MenuIcons
β β βββ index.js
β βββ MenuModal
β β βββ index.js
β β βββ styles.js
β βββ MobileMenu
β β βββ index.js
β β βββ styles.js
β βββ Nav
β β βββ index.js
β β βββ styles.js
β βββ PageError
β β βββ index.js
β β βββ styles.js
β βββ Post
β β βββ index.js
β β βββ styles.js
β βββ Theme
β β βββ index.js
β β βββ styles.js
β βββ Title
β βββ index.js
βββ helpers
β βββ css.js
β βββ index.js
βββ index.js
As @harpreet.freelance suggests
the styles are imported (as React components generated with Styled Components) in the index.js
of each component
import {MenuOverlay, MenuContent, MenuLink} from './styles'
Hope this helps