Skip to content
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

Updates 'inactive' state for buttons #2379

Merged
merged 12 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .changeset/lovely-suits-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@primer/view-components": patch
---

Updates 'inactive' state for buttons based on feedback from the a11y team:
- inactive buttons need to meet the color contrast ratio minimum
- inactive buttons shouldn't have aria-disabled since they can still accept interactions such as:
- hover/focus to show a tooltip
- click/activate to show a dialog with more detailed info on why it's inactive

<!-- Changed components: Button -->
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 2 additions & 3 deletions app/components/primer/beta/base_button.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ def initialize(

@system_arguments[:classes] = class_names(
system_arguments[:classes],
"btn-block" => block
"btn-block" => block,
"Button--inactive" => inactive
)

@system_arguments[:"aria-disabled"] = true if inactive

@disabled = disabled
return unless @disabled

Expand Down
26 changes: 15 additions & 11 deletions app/components/primer/beta/button.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,9 @@
transition: none;
}

&:disabled {
cursor: not-allowed;
box-shadow: none;
}

&:disabled,
&[aria-disabled='true'] {
cursor: default;
cursor: not-allowed;
box-shadow: none;
}
}
Expand Down Expand Up @@ -170,7 +166,7 @@ summary.Button {
border-color: var(--button-primary-borderColor-rest);
box-shadow: var(--shadow-resting-small, var(--color-btn-primary-shadow));

&:hover:not(:disabled) {
&:hover:not(:disabled, .Button--inactive) {
background-color: var(--button-primary-bgColor-hover);
border-color: var(--button-primary-borderColor-hover);
}
Expand Down Expand Up @@ -219,7 +215,7 @@ summary.Button {
border-color: var(--button-default-borderColor-rest);
box-shadow: var(--button-default-shadow-resting), var(--button-default-shadow-inset);

&:hover:not(:disabled) {
&:hover:not(:disabled, .Button--inactive) {
background-color: var(--button-default-bgColor-hover);
border-color: var(--button-default-borderColor-hover);
}
Expand Down Expand Up @@ -250,7 +246,7 @@ summary.Button {
color: var(--button-invisible-iconColor-rest, var(--color-fg-muted));
}

&:hover:not(:disabled) {
&:hover:not(:disabled, .Button--inactive) {
background-color: var(--button-invisible-bgColor-hover);

& .Button-visual {
Expand Down Expand Up @@ -294,7 +290,7 @@ summary.Button {
height: unset;
padding: 0;

&:hover:not(:disabled) {
&:hover:not(:disabled, .Button--inactive) {
text-decoration: underline;
}

Expand All @@ -320,7 +316,7 @@ summary.Button {
border-color: var(--button-danger-borderColor-rest);
box-shadow: var(--button-default-shadow-resting), var(--button-default-shadow-inset);

&:hover:not(:disabled) {
&:hover:not(:disabled, .Button--inactive) {
color: var(--button-danger-fgColor-hover);
fill: var(--button-danger-fgColor-hover);
background-color: var(--button-danger-bgColor-hover);
Expand Down Expand Up @@ -375,3 +371,11 @@ summary.Button {
width: var(--control-large-size);
}
}

/* `disabled` takes precedence over `inactive` */
.Button--inactive:not([aria-disabled='true'], :disabled) {
background-color: var(--button-inactive-bgColor);
border: 0;
color: var(--button-inactive-fgColor);
cursor: default;
}
14 changes: 7 additions & 7 deletions demo/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"version": "0.1.0",
"dependencies": {
"@primer/css": "^21.0.9",
"@primer/primitives": "^7.15.2",
"@primer/primitives": "7.15.3",
"@rails/actioncable": "^7.1.2",
"@rails/ujs": "^7.1.2",
"turbolinks": "^5.2.0",
"webpack-dev-server": "^4.15.1"
}
}
}
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"@github/prettier-config": "0.0.6",
"@playwright/test": "^1.35.1",
"@primer/css": "21.0.9",
"@primer/primitives": "^7.14.0",
"@primer/primitives": "7.15.3",
"@primer/stylelint-config": "^12.7.2",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-typescript": "^8.3.3",
Expand Down Expand Up @@ -95,4 +95,4 @@
},
"prettier": "@github/prettier-config",
"browserslist": "extends @github/browserslist-config"
}
}
3 changes: 3 additions & 0 deletions static/classes.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@
"Button--iconOnly": [
"Primer::Beta::Button"
],
"Button--inactive": [
"Primer::Beta::Button"
],
"Button--invisible": [
"Primer::Beta::Button"
],
Expand Down
Loading