-
Notifications
You must be signed in to change notification settings - Fork 62
aria-disabled for Button #269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
stephannv
merged 2 commits into
ruby-ui:main
from
pierry01:jean/use-aria-disabled-button
May 7, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -36,42 +36,66 @@ def size_classes | |
|
|
||
| def primary_classes | ||
| [ | ||
| "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 bg-primary text-primary-foreground shadow hover:bg-primary/90", | ||
| "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors bg-primary text-primary-foreground shadow", | ||
| "hover:bg-primary/90", | ||
| "disabled:pointer-events-none disabled:opacity-50", | ||
| "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", | ||
| "aria-disabled:pointer-events-none aria-disabled:opacity-50 aria-disabled:cursor-not-allowed", | ||
| size_classes | ||
| ] | ||
| end | ||
|
|
||
| def link_classes | ||
| [ | ||
| "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 text-primary underline-offset-4 hover:underline", | ||
| "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors text-primary underline-offset-4", | ||
| "hover:underline", | ||
| "disabled:pointer-events-none disabled:opacity-50", | ||
| "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", | ||
| "aria-disabled:pointer-events-none aria-disabled:opacity-50 aria-disabled:cursor-not-allowed", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the code responsible for style de disable look and feel is getting repetead all over the different variants. It would be nice to define a private constant to define the code and add it here. Something like: DISABLED_CLASSES = [
"disabled:pointer-events-none disabled:opacity-50",
"aria-disabled:pointer-events-none aria-disabled:opacity-50 aria-disabled:cursor-not-allowed"
] def primary_classes
[
"whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors bg-primary text-primary-foreground shadow",
"hover:bg-primary/90",
size_classes,
DISABLED_CLASSES |
||
| size_classes | ||
| ] | ||
| end | ||
|
|
||
| def secondary_classes | ||
| [ | ||
| "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 bg-secondary text-secondary-foreground hover:bg-opacity-80", | ||
| "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors bg-secondary text-secondary-foreground", | ||
| "hover:bg-opacity-80", | ||
| "disabled:pointer-events-none disabled:opacity-50", | ||
| "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", | ||
| "aria-disabled:pointer-events-none aria-disabled:opacity-50 aria-disabled:cursor-not-allowed", | ||
| size_classes | ||
| ] | ||
| end | ||
|
|
||
| def destructive_classes | ||
| [ | ||
| "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90", | ||
| "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors bg-destructive text-destructive-foreground shadow-sm", | ||
| "hover:bg-destructive/90", | ||
| "disabled:pointer-events-none disabled:opacity-50", | ||
| "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", | ||
| "aria-disabled:pointer-events-none aria-disabled:opacity-50 aria-disabled:cursor-not-allowed", | ||
| size_classes | ||
| ] | ||
| end | ||
|
|
||
| def outline_classes | ||
| [ | ||
| "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground", | ||
| "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors border border-input bg-background shadow-sm", | ||
| "hover:bg-accent hover:text-accent-foreground", | ||
| "disabled:pointer-events-none disabled:opacity-50", | ||
| "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", | ||
| "aria-disabled:pointer-events-none aria-disabled:opacity-50 aria-disabled:cursor-not-allowed", | ||
| size_classes | ||
| ] | ||
| end | ||
|
|
||
| def ghost_classes | ||
| [ | ||
| "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 hover:bg-accent hover:text-accent-foreground", | ||
| "whitespace-nowrap inline-flex items-center justify-center rounded-md font-medium transition-colors", | ||
| "hover:bg-accent hover:text-accent-foreground", | ||
| "disabled:pointer-events-none disabled:opacity-50", | ||
| "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", | ||
| "aria-disabled:pointer-events-none aria-disabled:opacity-50 aria-disabled:cursor-not-allowed", | ||
| size_classes | ||
| ] | ||
| end | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it'd be a good practice to separate the main classes from the pseudo classes triggers
it's more readable and maintainable