Skip to content
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
6 changes: 6 additions & 0 deletions .changeset/healthy-dots-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@primer/react": patch
---

- Update styles for default variant of Button's active state
- Use active state for Button when it is used to open an Overlay
27 changes: 25 additions & 2 deletions src/Button/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ export const getVariantStyles = (variant: VariantType = 'default', theme?: Theme
boxShadow: `${theme?.shadows.btn.focusShadow}`
},
'&:active:not([disabled])': {
backgroundColor: 'btn.selectedBg',
boxShadow: `${theme?.shadows.btn.shadowActive}`
backgroundColor: 'btn.activeBg',
borderColor: 'btn.activeBorder'
},
'&:disabled': {
color: 'primer.fg.disabled',
backgroundColor: 'btn.disabledBg'
},
'&[aria-expanded=true]': {
backgroundColor: 'btn.activeBg',
borderColor: 'btn.activeBorder'
}
},
primary: {
Expand All @@ -49,6 +53,10 @@ export const getVariantStyles = (variant: VariantType = 'default', theme?: Theme
'[data-component="ButtonCounter"]': {
backgroundColor: 'btn.primary.counterBg',
color: 'btn.primary.text'
},
'&[aria-expanded=true]': {
backgroundColor: 'btn.primary.selectedBg',
boxShadow: `${theme?.shadows.btn.primary.selectedShadow}`
}
},
danger: {
Expand Down Expand Up @@ -87,6 +95,12 @@ export const getVariantStyles = (variant: VariantType = 'default', theme?: Theme
'[data-component="ButtonCounter"]': {
color: 'btn.danger.text',
backgroundColor: 'btn.danger.counterBg'
},
'&[aria-expanded=true]': {
color: 'btn.danger.selectedText',
backgroundColor: 'btn.danger.selectedBg',
boxShadow: `${theme?.shadows.btn.danger.selectedShadow}`,
borderColor: 'btn.danger.selectedBorder'
}
},
invisible: {
Expand All @@ -106,6 +120,9 @@ export const getVariantStyles = (variant: VariantType = 'default', theme?: Theme
},
'&:disabled': {
color: 'primer.fg.disabled'
},
'&[aria-expanded=true]': {
backgroundColor: 'btn.selectedBg'
}
},
outline: {
Expand Down Expand Up @@ -146,6 +163,12 @@ export const getVariantStyles = (variant: VariantType = 'default', theme?: Theme
'[data-component="ButtonCounter"]': {
backgroundColor: 'btn.outline.counterBg',
color: 'btn.outline.text'
},
'&[aria-expanded=true]': {
color: 'btn.outline.selectedText',
backgroundColor: 'btn.outline.selectedBg',
boxShadow: `${theme?.shadows.btn.outline.selectedShadow}`,
borderColor: 'btn.outline.selectedBorder'
}
}
}
Expand Down
9 changes: 7 additions & 2 deletions src/__tests__/__snapshots__/ActionMenu.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,13 @@ exports[`ActionMenu renders consistently 1`] = `
}

.c1:active:not([disabled]) {
background-color: hsla(220,14%,94%,1);
box-shadow: inset 0 0.15em 0.3em rgba(27,31,36,0.15);
background-color: hsla(220,14%,93%,1);
border-color: rgba(27,31,36,0.15);
}

.c1[aria-expanded=true] {
background-color: hsla(220,14%,93%,1);
border-color: rgba(27,31,36,0.15);
}

<div
Expand Down
32 changes: 30 additions & 2 deletions src/__tests__/__snapshots__/Button.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,13 @@ exports[`Button renders consistently 1`] = `
}

.c0:active:not([disabled]) {
background-color: hsla(220,14%,94%,1);
box-shadow: inset 0 0.15em 0.3em rgba(27,31,36,0.15);
background-color: hsla(220,14%,93%,1);
border-color: rgba(27,31,36,0.15);
}

.c0[aria-expanded=true] {
background-color: hsla(220,14%,93%,1);
border-color: rgba(27,31,36,0.15);
}

<button
Expand Down Expand Up @@ -182,6 +187,13 @@ exports[`Button styles danger button appropriately 1`] = `
border-color: btn.danger.selectedBorder;
}

.c0[aria-expanded=true] {
color: btn.danger.selectedText;
background-color: btn.danger.selectedBg;
box-shadow: undefined;
border-color: btn.danger.selectedBorder;
}

<button
class="c0"
>
Expand Down Expand Up @@ -270,6 +282,10 @@ exports[`Button styles invisible button appropriately 1`] = `
background-color: btn.selectedBg;
}

.c0[aria-expanded=true] {
background-color: btn.selectedBg;
}

<button
class="c0"
>
Expand Down Expand Up @@ -377,6 +393,13 @@ exports[`Button styles outline button appropriately 1`] = `
border-color: btn.outline.selectedBorder;
}

.c0[aria-expanded=true] {
color: btn.outline.selectedText;
background-color: btn.outline.selectedBg;
box-shadow: undefined;
border-color: btn.outline.selectedBorder;
}

<button
class="c0"
>
Expand Down Expand Up @@ -471,6 +494,11 @@ exports[`Button styles primary button appropriately 1`] = `
box-shadow: undefined;
}

.c0[aria-expanded=true] {
background-color: btn.primary.selectedBg;
box-shadow: undefined;
}

<button
class="c0"
>
Expand Down
4 changes: 2 additions & 2 deletions src/stories/ActionMenu/examples.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export function GroupsAndDescription(): JSX.Element {
paddingX: 0,
gridTemplateColumns: 'min-content 1fr min-content',
textAlign: 'left',
':hover, :focus': {background: 'none !important', color: 'accent.fg'}
':hover, :focus, &[aria-expanded=true]': {background: 'none !important', color: 'accent.fg'}
}}
>
Milestone
Expand Down Expand Up @@ -260,7 +260,7 @@ export function MultipleSelection(): JSX.Element {
paddingX: 0,
gridTemplateColumns: 'min-content 1fr min-content',
textAlign: 'left',
':hover, :focus': {background: 'none !important', color: 'accent.fg'}
':hover, :focus, &[aria-expanded=true]': {background: 'none !important', color: 'accent.fg'}
}}
>
Assignees
Expand Down