2. Create Main Structure

Create the main structure

Let's structure the project as follows:

  • assets/: to keep all the styles and images

  • app/: for the App component and Routing

  • components/: for reusable React components

  • features/: to group React components by feature

  • utils/: to keep the helper functions

Let's create the assets/, app/, components/, utils/ and features/ folders in the src/ folder. And move the App.js, App.css and App.test.js in the src/app/ folder.

The src/ folder structure should now look like this:

β”‚   β”œβ”€β”€β”€app/
β”‚   β”‚   β”œβ”€β”€β”€App.css
β”‚   β”‚   β”œβ”€β”€β”€App.js
β”‚   β”‚   └───App.test.js
β”‚   β”œβ”€β”€β”€assets/
β”‚   β”œβ”€β”€β”€components/
β”‚   β”œβ”€β”€β”€features/
β”‚   β”œβ”€β”€β”€utils/
β”‚   β”œβ”€β”€β”€index.css
β”‚   β”œβ”€β”€β”€index.js
β”‚   β”œβ”€β”€β”€logo.svg
β”‚   β”œβ”€β”€β”€serviceWorker.js
β”‚   └───setupTests.js


You can download the compressed folder with basic assets from here. This includes the background image and the basic CSS styles to use across the project.

Unzip folder and paste the files into the assets/ folder.

The images/ and the styles/ folder should look like this:

β”‚   β”œβ”€β”€β”€assets/
β”‚   β”‚   β”œβ”€β”€β”€images/
β”‚   β”‚   β”‚   └───background-image.jpg
β”‚   β”‚   └───styles/
β”‚   β”‚       β”œβ”€β”€β”€main.scss
β”‚   β”‚       β”œβ”€β”€β”€_base.scss
β”‚   β”‚       β”œβ”€β”€β”€_branding.scss
β”‚   β”‚       β”œβ”€β”€β”€_buttons.scss
β”‚   β”‚       β”œβ”€β”€β”€_flex.scss
β”‚   β”‚       β”œβ”€β”€β”€_inputs.scss
β”‚   β”‚       └───_texts.scss

Install the node-sass to use Sass and SCSS:

npm install node-sass

And add this line in the index.js:

// /index.js
import './assets/styles/main.scss';

Also, include the material icons in the index.html file which is located in the public/ folder:

// public/index.html
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">

Last updated