Skip to content

Commit

Permalink
Merge pull request #2438 from anuradha9712/v4.x
Browse files Browse the repository at this point in the history
docs(README): add guideline to use module css in contributing guideli…
  • Loading branch information
anuradha9712 authored Nov 25, 2024
2 parents 9c0b9b6 + b431523 commit d7e116e
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,28 +279,28 @@ const AvatarAppearance =
appearance || colors[(initials.charCodeAt(0) + (initials.charCodeAt(1) || 0)) % 8] || DefaultAppearance;
```
- [ClassNames](https://www.npmjs.com/package/classnames) is a utility for conditionally joining CSS classNames together.
- CSS is added according to [BEM Convention](http://getbem.com/naming/).
- CSS Module has been used to define the class names.
1. Create a CSS file inside `css` directory with the file extension `module.css` (e.g `avatar.module.css`)
2. Import the CSS file inside your component's `.tsx` file using:
```jsx
import styles from './avatar.module.css';
```
3. Use [ClassNames](https://www.npmjs.com/package/classnames), a utility for conditionally joining CSS classNames together.
4. Follow the [BEM Convention](http://getbem.com/naming/) and use CSS Modules for naming CSS classes.
```jsx
const classes = classNames(
{
Avatar: true,
[`Avatar--${size}`]: size,
[`Avatar--${AvatarAppearance}`]: AvatarAppearance,
['Avatar--disabled']: !initials || !withTooltip,
[styles.Avatar]: true,
[styles[`Avatar--${size}`]]: size,
[styles[`Avatar--${AvatarAppearance}`]]: AvatarAppearance,
[styles['Avatar--disabled']]: !initials || !withTooltip,
},
className
);

const ContentClass = classNames({
[`Avatar-content--${size}`]: size,
[`Avatar-content--${AvatarAppearance}`]: AvatarAppearance,
});

const IconClass = classNames({
[`Avatar-content--${AvatarAppearance}`]: AvatarAppearance,
});
```
- Add rendering logic and `data-test` attribute.
Expand Down

0 comments on commit d7e116e

Please sign in to comment.