Skip to content

Latest commit

Β 

History

History
324 lines (296 loc) Β· 11.8 KB

conventions.md

File metadata and controls

324 lines (296 loc) Β· 11.8 KB

Conventions to be followed while working on the project (frontend)

Index

  1. Folder Structure
  2. React Component Conventions
  3. CSS Conventions
  4. Steps to refactor the codebase

Folder Structure

frontend
└── src
    β”œβ”€β”€ components
    |    β”œβ”€β”€ ErrorHandlerPages
    |    |    β”œβ”€β”€ 404
    |    |    |   β”œβ”€β”€ NotFound.jsx
    |    |    |   β”œβ”€β”€ index.js
    |    |    |   β”œβ”€β”€ not-found.module.scss
    |    |    β”œβ”€β”€ LoggedIn
    |    |    |   β”œβ”€β”€ LoggedIn.jsx
    |    |    |   β”œβ”€β”€ index.js
    |    |    |   β”œβ”€β”€ logged-in.module.scss
    |    β”œβ”€β”€ Footer
    |    |    β”œβ”€β”€ Footer.jsx
    |    |    |── footer.module.scss
    |    |    |── index.js
    |    β”œβ”€β”€ Navbar
    |    |    β”œβ”€β”€ Navbar.jsx
    |    |    |── navbar.module.scss
    |    |    |── index.js
    |    β”œβ”€β”€ util
    |    |    β”œβ”€β”€ Button
    |    |    |   β”œβ”€β”€ Button.jsx
    |    |    |   β”œβ”€β”€ index.js
    |    |    |   β”œβ”€β”€ button.module.scss
    |    |    β”œβ”€β”€ DropMenu
    |    |    |   β”œβ”€β”€ DropMenu.jsx
    |    |    |   β”œβ”€β”€ index.js
    |    |    |   β”œβ”€β”€ drop-menu.module.scss
    |    |    β”œβ”€β”€ Dropdown
    |    |    |   β”œβ”€β”€ Dropdown.jsx
    |    |    |   β”œβ”€β”€ MenuItems.js
    |    |    |   β”œβ”€β”€ index.js
    |    |    |   β”œβ”€β”€ dropdown.module.scss
    |    |    β”œβ”€β”€ ScrollToTop
    |    |    |   β”œβ”€β”€ LoggedIn.jsx
    |    |    |   β”œβ”€β”€ index.js
    |    |    |   β”œβ”€β”€ logged-in.module.scss
    |    |    β”œβ”€β”€ Toast
    |    |    |   β”œβ”€β”€ Toast.jsx
    |    |    |   β”œβ”€β”€ index.js
    |    |    |   β”œβ”€β”€ toast.module.scss
    |    |    β”œβ”€β”€ Toggle
    |    |    |   β”œβ”€β”€ Toggle.jsx
    |    |    |   β”œβ”€β”€ index.js
    |    |    |   β”œβ”€β”€ toggle.module.scss
    β”œβ”€β”€ config
    |    β”œβ”€β”€ api.js
    β”œβ”€β”€ fonts
    |    β”œβ”€β”€ FuturaLT-Book.ttf
    β”œβ”€β”€ test_data
    |    β”œβ”€β”€ broadcast_text.json
    |    β”œβ”€β”€ superadmin_credential.json
    |    β”œβ”€β”€ team-roles.json
    |    β”œβ”€β”€ teams.js
    β”œβ”€β”€ store
    |    β”œβ”€β”€ actions
    |    |    β”œβ”€β”€ actions.js
    |    |    β”œβ”€β”€ auth.js
    |    β”œβ”€β”€ reducers
    |    |    β”œβ”€β”€ reducer.js
    β”œβ”€β”€ pages
    β”‚    β”œβ”€β”€ Home
    |    β”‚    β”œβ”€β”€ components
    |    |    |    β”œβ”€β”€ JoinUs
    |    |    |    |   β”œβ”€β”€ JoinUs.jsx
    |    |    |    |   β”œβ”€β”€ index.js
    |    |    |    |   β”œβ”€β”€ join-us.module.scss
    |    |    |    β”œβ”€β”€ Carousel
    |    |    |    |   β”œβ”€β”€ Carousel.jsx
    |    |    |    |   β”œβ”€β”€ index.js
    |    |    |    |   β”œβ”€β”€ carousel.module.scss
    |    |    |    |   β”œβ”€β”€ owl-carousel-styles.css
    |    |    |    β”œβ”€β”€ JoinUsForm
    |    |    |    |   β”œβ”€β”€ Form.jsx
    |    |    |    |   β”œβ”€β”€ index.js
    |    |    |    |   β”œβ”€β”€ form.module.scss
    |    |    |    β”œβ”€β”€ Motive
    |    |    |    |   β”œβ”€β”€ Motive.jsx
    |    |    |    |   β”œβ”€β”€ index.js
    |    |    |    |   β”œβ”€β”€ motive.module.scss
    |    |    |    β”œβ”€β”€ Overview
    |    |    |    |   β”œβ”€β”€ Overview.jsx
    |    |    |    |   β”œβ”€β”€ index.js
    |    |    |    |   β”œβ”€β”€ overview.module.scss
    |    β”‚    β”œβ”€β”€ index.js
    |    β”‚    β”œβ”€β”€ Home.jsx
    |    β”‚    └── home.module.scss
    |    β”‚    └── nav-icon.png
    β”‚    β”œβ”€β”€ About
    β”‚    β”‚    β”œβ”€β”€ About.jsx
    β”‚    β”‚    β”œβ”€β”€ index.js
    β”‚    β”‚    β”œβ”€β”€ about.module.scss
    β”‚    β”‚    β”œβ”€β”€ about.scss
    β”‚    └── Login
    β”‚    |     β”œβ”€β”€ Login.jsx
    β”‚    |     β”œβ”€β”€ index.js
    β”‚    |     └── login.module.scss
    β”‚    β”œβ”€β”€ Admin
    |    β”‚    β”œβ”€β”€ components
    |    |    |    β”œβ”€β”€ JoinUs
    |    |    |    |   β”œβ”€β”€ JoinUs.jsx
    |    |    |    |   β”œβ”€β”€ index.js
    |    |    |    β”œβ”€β”€ About
    |    |    |    |   β”œβ”€β”€ About.jsx
    |    |    |    |   β”œβ”€β”€ index.js
    |    |    |    |   β”œβ”€β”€ about-us.module.scss
    |    |    |    β”œβ”€β”€ AddTeamMember
    |    |    |    |   β”œβ”€β”€ AddTeamMember.jsx
    |    |    |    |   β”œβ”€β”€ index.js
    |    |    |    |   β”œβ”€β”€ add-team-member.module.scss
    |    |    |    β”œβ”€β”€ Broadcast
    |    |    |    |   β”œβ”€β”€ AddBroadcasts
    |    |    |    |   |   β”œβ”€β”€ AddBroadcasts.jsx
    |    |    |    |   |   β”œβ”€β”€ index.js
    |    |    |    |   |   β”œβ”€β”€ add-broadcasts.module.scss
    |    |    |    |   β”œβ”€β”€ Broadcast.jsx
    |    |    |    |   β”œβ”€β”€ index.js
    |    |    |    |   β”œβ”€β”€ broadcast.module.scss
    |    |    |    β”œβ”€β”€ Contact
    |    |    |    |   β”œβ”€β”€ Contact.jsx
    |    |    |    |   β”œβ”€β”€ index.js
    |    |    |    β”œβ”€β”€ Dashboard
    |    |    |    |   β”œβ”€β”€ Dashboard.jsx
    |    |    |    |   β”œβ”€β”€ index.js
    |    |    |    |   β”œβ”€β”€ dashboard.module.scss
    |    |    |    β”œβ”€β”€ Faq
    |    |    |    |   β”œβ”€β”€ AddFaq
    |    |    |    |   |   β”œβ”€β”€ AddFaq.jsx
    |    |    |    |   |   β”œβ”€β”€ index.js
    |    |    |    |   |   β”œβ”€β”€ add-faq.module.scss
    |    |    |    |   β”œβ”€β”€ Faq.jsx
    |    |    |    |   β”œβ”€β”€ index.js
    |    |    |    |   β”œβ”€β”€ faq.module.scss
    |    |    |    β”œβ”€β”€ MangeTeams
    |    |    |    |   β”œβ”€β”€ ManageTeams.jsx
    |    |    |    |   β”œβ”€β”€ index.js
    |    |    |    |   β”œβ”€β”€ manage-teams.module.scss
    |    |    |    β”œβ”€β”€ Profile
    |    |    |    |   β”œβ”€β”€ Profile.jsx
    |    |    |    |   β”œβ”€β”€ index.js
    |    |    |    |   β”œβ”€β”€ profile.module.scss
    |    |    |    β”œβ”€β”€ Resource
    |    |    |    |   β”œβ”€β”€ Resource.jsx
    |    |    |    |   β”œβ”€β”€ index.js\
    |    |    |    β”œβ”€β”€ Setting
    |    |    |    |   β”œβ”€β”€ Invite
    |    |    |    |   |   β”œβ”€β”€ Invite.jsx
    |    |    |    |   |   β”œβ”€β”€ index.js
    |    |    |    |   |   β”œβ”€β”€ Invite.module.scss
    |    |    |    |   β”œβ”€β”€ Manage
    |    |    |    |   |   β”œβ”€β”€ Manage.jsx
    |    |    |    |   |   β”œβ”€β”€ index.js
    |    |    |    |   |   β”œβ”€β”€ Manage.module.scss
    |    |    |    |   β”œβ”€β”€ ResetPassword
    |    |    |    |   |   β”œβ”€β”€ ResetPassword.jsx
    |    |    |    |   |   β”œβ”€β”€ index.js
    |    |    |    |   |   β”œβ”€β”€ Invite.module.scss
    |    |    |    |   β”œβ”€β”€ Setting.jsx
    |    |    |    |   β”œβ”€β”€ index.js
    |    |    |    |   β”œβ”€β”€ setting.module.scss
    |    β”‚    β”œβ”€β”€ index.js
    |    β”‚    β”œβ”€β”€ Admin.jsx
    |    β”‚    └── admin.module.scss
    β”‚    β”œβ”€β”€ Broadcast
    |    β”‚    β”œβ”€β”€ Component
    |    |    |    β”œβ”€β”€ AllBroadcasts
    |    |    |    |   β”œβ”€β”€ Card
    |    |    |    |   |   β”œβ”€β”€ Card.jsx
    |    |    |    |   |   β”œβ”€β”€ index.js
    |    |    |    |   |   β”œβ”€β”€ card.module.scss
    |    |    |    |   β”œβ”€β”€ Edit
    |    |    |    |   |   β”œβ”€β”€ Edit.jsx
    |    |    |    |   |   β”œβ”€β”€ index.js
    |    |    |    |   |   β”œβ”€β”€ edit.module.scss
    |    |    |    |   β”œβ”€β”€ AllBroadcasts.jsx
    |    |    |    |   β”œβ”€β”€ index.js
    |    |    |    |   β”œβ”€β”€ all-broadcasts.module.scss
    |    |    |    β”œβ”€β”€ Carousel
    |    |    |    |   β”œβ”€β”€ Edit
    |    |    |    |   |   β”œβ”€β”€ Card.jsx
    |    |    |    |   |   β”œβ”€β”€ index.js
    |    |    |    |   |   β”œβ”€β”€ card.module.scss
    |    |    |    |   β”œβ”€β”€ Modal
    |    |    |    |   |   β”œβ”€β”€ Edit.jsx
    |    |    |    |   |   β”œβ”€β”€ index.js
    |    |    |    |   |   β”œβ”€β”€ edit.module.scss
    |    |    |    |   β”œβ”€β”€ Carousel.jsx
    |    |    |    |   β”œβ”€β”€ index.js
    |    |    |    |   β”œβ”€β”€ carousel.module.scss
    |    |    |    |   β”œβ”€β”€ coustom-owl-carousel-style.scss
    |    β”‚    β”œβ”€β”€ index.js
    |    β”‚    β”œβ”€β”€ Broadcast.jsx
    |    β”‚    └── broadcast.module.scss
    β”‚    └── ContactUs
    β”‚    |     β”œβ”€β”€ Faq.jsx
    β”‚    |     β”œβ”€β”€ index.js
    β”‚    |     └── ContactUs.module.scss
    β”‚    └── Faq
    β”‚    |     β”œβ”€β”€ Faq.jsx
    β”‚    |     β”œβ”€β”€ index.js
    β”‚    |     └── faq.module.scss
    β”‚    └── ForgotPassword
    β”‚    |     β”œβ”€β”€ ForgotPassword.jsx
    β”‚    |     β”œβ”€β”€ index.js
    β”‚    |     └── ForgotPassword.module.scss
    β”‚    └── ForgotPasswordRecovery
    β”‚    |     β”œβ”€β”€ ForgotPasswordRecovery.jsx
    β”‚    |     β”œβ”€β”€ index.js
    β”‚    |     └── ForgotPasswordRecovery.module.scss
    β”‚    └── GetInvolved
    β”‚    |     β”œβ”€β”€ GetInvolved.jsx
    β”‚    |     β”œβ”€β”€ index.js
    β”‚    |     └── get-involved.module.scss
    β”‚    └── PrivacyPolicy
    β”‚    |     β”œβ”€β”€ PrivacyPolicy.jsx
    β”‚    |     β”œβ”€β”€ index.js
    β”‚    |     └── privacy-policy.module.scss
    β”‚    └── Terms
    β”‚    |     β”œβ”€β”€ Terms.jsx
    β”‚    |     β”œβ”€β”€ index.js
    β”‚    |     └── terms.module.css
    β”‚    β”œβ”€β”€ Resources
    |    β”‚    β”œβ”€β”€ Component
    |    |    |    β”œβ”€β”€ ResourceSharingForm
    |    |    |    |   β”œβ”€β”€ ResourceSharingForm.jsx
    |    |    |    |   β”œβ”€β”€ index.js
    |    |    |    |   β”œβ”€β”€ resource-sharing-form.module.scss
    |    β”‚    β”œβ”€β”€ index.js
    |    β”‚    β”œβ”€β”€ Resources.jsx
    |    β”‚    └── resources.module.scss
    β”œβ”€β”€ app.js
    β”œβ”€β”€ index.js
    β”œβ”€β”€ index.css
    β”œβ”€β”€ index.css



React Component Conventions

Rules to follow

  1. Do not use default exports. Instead, use named exports throughout the project.
export class Header extends Components{

}

{/* For named exports, 'export' keyword should be used as shown above. There won't be any default export line anywhere in the code. */}
  1. Strictly follow PascalCase naming convention for naming React Components.
  2. Import CSS module file as style in all the pages and components. Example, import style from 'header.module.scss'
  3. Change all the class names. <p className={style["class-name"]}>Some content...</p>. Note - Keep the bootstrap classes like row, col-, container, etc, as they are.



CSS Conventions

The following convention should strictly be followed.


File names

DO NOT use camelCase, or PascalCase to name the CSS/SCSS files.
Strictly use Kebab-case

Example - codeOfConduct.module.scss will not be accepted. The right way is code-of-conduct.module.scss


Variable names

Use kebab-case for variable names while maintaing the BEM nomenclature. For example

/* wrong practice */
.blogCard__card--small {
  ...;
}

/* right practice */
.blog-card__card--small {
  ...;
}
/* wrong practice */
.submitButton__big--lightBlue {
  ...;
}

/* right practice */
.submit-button__big--light-blue {
  ...;
}



Summary

  1. Make a folder with the component name. If it is a page, make a folder inside frontend/pages folder. If it is a global component (like header, footer, navbar), component that is used in multiple pages, then make a folder inside frontend/components folder.
  2. Strictly follow the React rules mentioned above.
  3. Follow the CSS rules and edit all the classnames accoridingly. Note that bootstrap classes (row, col-, container) should be left as they are.
  4. Do not worry about BEM Nomenclature for now.