Skip to content

Commit

Permalink
Merge pull request #1 from rishav-jha-mech/adminUI-redesign
Browse files Browse the repository at this point in the history
Updated CODE_STYLE.md
  • Loading branch information
rishav-jha-mech authored Jun 1, 2023
2 parents da669e2 + a0a4bd9 commit e154a30
Showing 1 changed file with 61 additions and 1 deletion.
62 changes: 61 additions & 1 deletion CODE_STYLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,67 @@ code style should not be changed and must be followed.

- All the Return fragment should be closed in empty tag

- Use of classes is refrained
- Use of custom classes directly are refrained, use of modular css is encouraged along with bootstrap classes

**Wrong way ❌**
```
<div className="myCustomClass">...</div>
<div className={`${styles.myCustomClass1} myCustomClass2`}>...</div> // No using personal custom classes directly, here you should not use myCustomClass2
.container{...} // No changing the property of already existing classes reserved by boostrap directly in css files
```

**Correct ways ✅**
```
<div className={styles.myCustomClass}>...</div> // Use custom class defined in modular css file
<div className={`${styles.myCustomClass} relative bg-danger`}>...</div> // Use classes already defined in Bootstrap
<div className={styles.myCustomClass + ' relative bg-danger' }>...</div> // Use classes already defined in Bootstrap
```

- All components should be either imported from React-Bootstrap library or Material UI library, components should not be written using plain Bootstrap classes and attributes without leveraging the React-Bootstrap library.

**Example: Bootstrap Dropdown**

**Wrong way ❌**

Using plain Bootstrap classes and attributes without leveraging the React-Bootstrap library should be refrained. While it may work for basic functionality, it doesn't fully integrate with React and may cause issues when dealing with more complex state management or component interactions.
```
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
Dropdown button
</button>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
</ul>
</div>
```


**Correct way ✅**

It's recommended to use the React-Bootstrap library for seamless integration of Bootstrap components in a React application.
```
import Dropdown from 'react-bootstrap/Dropdown';
function BasicExample() {
return (
<Dropdown>
<Dropdown.Toggle variant="success" id="dropdown-basic">
Dropdown Button
</Dropdown.Toggle>
<Dropdown.Menu>
<Dropdown.Item href="#/action-1">Action</Dropdown.Item>
<Dropdown.Item href="#/action-2">Another action</Dropdown.Item>
<Dropdown.Item href="#/action-3">Something else</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
);
}
export default BasicExample;
```


## Test and Code Linting
Expand Down

0 comments on commit e154a30

Please sign in to comment.