-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #227 from wwWallet/refactor/buttons-focus
Enhancing UI Consistency and Accessibility in Button Components with Dark Mode Integration
- Loading branch information
Showing
27 changed files
with
1,154 additions
and
840 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from 'react'; | ||
|
||
const GetButton = ({ type = 'button', content, onClick, variant = 'custom', additionalClassName = '', disabled = false, ariaLabel, title }) => { | ||
|
||
const getVariantClassName = () => { | ||
const commonClasses = 'rounded-lg shadow-sm text-sm px-4 py-2 text-center flex flex-row flex-nowrap items-center justify-center'; | ||
switch (variant) { | ||
case 'primary': | ||
return `${commonClasses} text-white ${!disabled ? "bg-primary hover:bg-primary-hover dark:text-white dark:hover:bg-primary-light-hover dark:bg-primary-light" : "bg-gray-300 cursor-not-allowed hover:bg-gray-300"}`; | ||
case 'secondary': | ||
return `${commonClasses} text-white ${!disabled ? "bg-primary-light hover:bg-primary-light-hover dark:bg-extra-light dark:hover:bg-primary-light" : "bg-gray-300 cursor-not-allowed hover:bg-gray-300"}`; | ||
case 'tertiary': | ||
return `${commonClasses} text-gray-700 bg-gray-100 hover:bg-gray-200`; | ||
case 'cancel': | ||
return `${commonClasses} ${!disabled ? "text-gray-900 bg-gray-300 hover:bg-gray-400" : "text-white bg-gray-300 cursor-not-allowed hover:bg-gray-300"}`; | ||
case 'delete': | ||
return `${commonClasses} ${!disabled ? "text-white bg-red-600 hover:bg-red-700" : "text-red-400 bg-gray-300 hover:bg-gray-300 cursor-not-allowed"}`; | ||
case 'custom': | ||
return `${commonClasses}`; | ||
} | ||
}; | ||
|
||
const focusVisibleClasses = 'focus-visible:outline-2 focus-visible:outline-offset-2'; | ||
const className = `${getVariantClassName()} ${focusVisibleClasses} ${additionalClassName}`; | ||
|
||
return ( | ||
<button | ||
type={type} | ||
{...(onClick && { onClick: onClick })} | ||
{...(disabled && { disabled })} | ||
className={className} | ||
{...(ariaLabel && { 'aria-label': ariaLabel })} | ||
{...(title && { title })} | ||
> | ||
{content} | ||
</button> | ||
); | ||
}; | ||
|
||
export default GetButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.