Skip to content

Commit

Permalink
Add support for aria-disabled in Button (#5126)
Browse files Browse the repository at this point in the history
* add support for aria-disabled

* fix

* Create grumpy-hairs-look.md
  • Loading branch information
langermank authored Oct 16, 2024
1 parent c1e27c3 commit f574372
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/grumpy-hairs-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": patch
---

Add support for `aria-disabled` in `Button`
6 changes: 6 additions & 0 deletions packages/react/src/Button/Button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ Playground.argTypes = {
type: 'boolean',
},
},
'aria-disabled': {
control: {
type: 'boolean',
},
},
inactive: {
control: {
type: 'boolean',
Expand Down Expand Up @@ -79,6 +84,7 @@ Playground.args = {
leadingVisual: null,
trailingAction: null,
labelWrap: false,
'aria-disabled': false,
}

export const Default = () => <Button>Default</Button>
18 changes: 12 additions & 6 deletions packages/react/src/Button/ButtonBase.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
transition: none;
}

&:disabled {
&:disabled,
&[aria-disabled='true']:not([data-loading='true']) {
cursor: not-allowed;
box-shadow: none;

Expand Down Expand Up @@ -263,7 +264,8 @@
border-color: var(--button-default-borderColor-active);
}

&:disabled {
&:disabled,
&[aria-disabled='true']:not([data-loading='true']) {
color: var(--control-fgColor-disabled);
background-color: var(--button-default-bgColor-disabled);
border-color: var(--button-default-borderColor-disabled);
Expand Down Expand Up @@ -306,7 +308,8 @@
box-shadow: var(--button-primary-shadow-selected);
}

&:disabled {
&:disabled,
&[aria-disabled='true']:not([data-loading='true']) {
color: var(--button-primary-fgColor-disabled);
background-color: var(--button-primary-bgColor-disabled);
border-color: var(--button-primary-borderColor-disabled);
Expand Down Expand Up @@ -374,7 +377,8 @@
}
}

&:disabled {
&:disabled,
&[aria-disabled='true']:not([data-loading='true']) {
color: var(--button-danger-fgColor-disabled);
background-color: var(--button-danger-bgColor-disabled);
border-color: var(--button-default-borderColor-disabled);
Expand Down Expand Up @@ -423,7 +427,8 @@
}
}

&:disabled {
&:disabled,
&[aria-disabled='true']:not([data-loading='true']) {
color: var(--button-invisible-fgColor-disabled);
background-color: var(--button-invisible-bgColor-disabled);
border-color: var(--button-invisible-borderColor-disabled);
Expand Down Expand Up @@ -464,7 +469,8 @@
outline-offset: 2px;
}

&:disabled {
&:disabled,
&[aria-disabled='true']:not([data-loading='true']) {
color: var(--control-fgColor-disabled);
background-color: transparent;
border-color: transparent;
Expand Down

0 comments on commit f574372

Please sign in to comment.