cisco-sbg-ui / magna-react

magna-react.vercel.app
5 stars 0 forks source link

Introduce and start using "classnames" for class construction in components #326

Open bredy opened 1 year ago

bredy commented 1 year ago

Is your feature request related to a problem? Please describe.

Currently in library there is lots of lines of code concatenating class names. Code is often unnecessarily long and unclear. Is could be later difficult to refactor or add some new classes.

Describe the solution you'd like

I'd like to start using classnames library. It's simple and small library focused to solve this kind of issues. This library is not tied to any specific framework or library and can be used in a wide range of contexts. It is compatible with React. Also is optimised for performance and has a small footprint.

Describe alternatives you've considered

We can alternatively start using clsx or create our own utility with the same (or simplier) interface. There are some pros/cons related to clsx - we could discuss it further if there will be interest to continue with any of these libraries.

Additional context

I've randomly chosen two components and modified their code to provide examples how the code changes with classnames.

AListItem Example

ALoader Example

Use code examples are available in jp-classnames branch.

rwharrisjr commented 1 year ago

By design magna-react doesn't have any dependencies. I'd like to keep it this way for simplicity sake.

The "after" with classNames usage is nice though, so I'd lean toward implementing our own utility for the features we want. @androche