Skip to content

Commit

Permalink
Refactor clsx handling in Button component for improved readability a…
Browse files Browse the repository at this point in the history
…nd flexibility

This commit refines the clsx handling in the Button component by simplifying the logic for conditional class assignment. Previously, the className prop was being assigned using the nullish coalescing operator (??), which could be simplified by directly utilizing clsx for combining default classes with the custom className provided.

Changes made:
- Replaced the ?? operator with direct usage of clsx to concatenate default classes with the custom className in a more readable and concise manner.
- Ensured that clsx effectively handles undefined or null values for className, reducing the need for explicit checks.

The refactor improves readability, reduces unnecessary checks, and ensures that the Button component continues to function as expected with the correct class names being applied.

This change does not affect the functionality or appearance of the component but enhances code clarity, making it easier to manage and extend the class names in the future.
  • Loading branch information
Bitcex authored Dec 19, 2024
1 parent 73267d0 commit d4efa93
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libs/base-ui/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ function Button({ onClick, disabled, children, className, variant = 'primary' }:
<button
type="button"
className={clsx(
className ??
'text-md flex items-center justify-center rounded-md p-4 font-sans font-bold uppercase',
variants[variant],
className
)}
onClick={onClick}
disabled={disabled}
Expand Down

0 comments on commit d4efa93

Please sign in to comment.