Skip to content

Adds Classes utility component with documentation#128

Merged
DavidHDev merged 8 commits intoDavidHDev:mainfrom
timothyokooboh:feat/127-add-classes-utility
Aug 12, 2025
Merged

Adds Classes utility component with documentation#128
DavidHDev merged 8 commits intoDavidHDev:mainfrom
timothyokooboh:feat/127-add-classes-utility

Conversation

@timothyokooboh
Copy link
Copy Markdown
Contributor

@timothyokooboh timothyokooboh commented Jun 29, 2025

Overview

This PR relates to issue 127.

This PR introduces a new utility component called Classes that simplifies conditional class name management in React components. The component provides a clean and type-safe way to conditionally apply multiple classes based on different conditions. It serves as an enhancement to the limitations of the Class utility component.

Features

  • Type-safe implementation with TypeScript.
  • Support for multiple conditional classes using object mapping.
  • Automatic class name deduplication.
  • Flexible element type support through the as prop.

Usage Example

<Classes
  as="button"
  className="base-class"
  toggleClasses={{
    'error': hasError,
    'squared': isSquared,
    'disabled': isDisabled
  }}
>
  Click me
</Classes>

Testing

  • Added demo implementation that showcases all features.
  • Added unit tests inside lib/tests/utils/Classes.test.tsx.

Breaking Changes

None

Dependencies

None

Class-tests classes-screenshot

@timothyokooboh
Copy link
Copy Markdown
Contributor Author

@DavidHDev, could you help review my PR when you get a chance? Thanks!

Comment thread docs/docs/utilities/classes.mdx Outdated
Copy link
Copy Markdown
Owner

@DavidHDev DavidHDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I'll merge this in before the next release

@DavidHDev DavidHDev merged commit c3f3e0c into DavidHDev:main Aug 12, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants