Skip to content

Commit 6f50b15

Browse files
authored
Decrease invisible button icon CSS specifity (#2925)
* make color overridable * snaps * Create .changeset/metal-ants-punch.md * missed one * tests
1 parent b827b17 commit 6f50b15

File tree

6 files changed

+30
-6
lines changed

6 files changed

+30
-6
lines changed

.changeset/metal-ants-punch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@primer/react": patch
3+
---
4+
5+
Decrease `invisible` button icon CSS specifity

src/Button/Button.dev.stories.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {SearchIcon, TriangleDownIcon, EyeIcon} from '@primer/octicons-react'
22
import React from 'react'
3-
import {Button} from '.'
3+
import {Button, IconButton} from '.'
44

55
export default {
66
title: 'Components/Button/DevOnly',
@@ -29,6 +29,7 @@ export const InvisibleVariants = () => {
2929
Button
3030
<Button.Counter>{count}</Button.Counter>
3131
</Button>
32+
<IconButton icon={TriangleDownIcon} variant="invisible" aria-label="Invisible" />
3233
</div>
3334
)
3435
}

src/Button/IconButton.dev.stories.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ export const CustomSizeWithMedia = () => {
2121
/>
2222
)
2323
}
24+
25+
export const CustomIconColor = () => (
26+
<IconButton aria-label="Expand" variant="invisible" size="small" icon={ChevronDownIcon} sx={{color: 'red'}} />
27+
)

src/Button/styles.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,13 @@ export const getVariantStyles = (variant: VariantType = 'default', theme?: Theme
121121
'&[aria-expanded=true]': {
122122
backgroundColor: 'btn.selectedBg',
123123
},
124-
svg: {
124+
'&[data-component="IconButton"][data-no-visuals]': {
125+
color: 'fg.muted',
126+
},
127+
'[data-component="trailingAction"]': {
128+
color: 'fg.muted',
129+
},
130+
'[data-component="leadingVisual"]': {
125131
color: 'fg.muted',
126132
},
127133
'&[data-no-visuals]': {

src/__tests__/__snapshots__/Button.test.tsx.snap

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1565,6 +1565,7 @@ exports[`Button styles invisible button appropriately 1`] = `
15651565
15661566
.c0 [data-component="leadingVisual"] {
15671567
grid-area: leadingVisual;
1568+
color: fg.muted;
15681569
}
15691570
15701571
.c0 [data-component="text"] {
@@ -1579,6 +1580,7 @@ exports[`Button styles invisible button appropriately 1`] = `
15791580
15801581
.c0 [data-component="trailingAction"] {
15811582
margin-right: -4px;
1583+
color: fg.muted;
15821584
}
15831585
15841586
.c0 [data-component="buttonContent"] {
@@ -1613,7 +1615,7 @@ exports[`Button styles invisible button appropriately 1`] = `
16131615
background-color: btn.selectedBg;
16141616
}
16151617
1616-
.c0 svg {
1618+
.c0[data-component="IconButton"][data-no-visuals] {
16171619
color: fg.muted;
16181620
}
16191621

src/__tests__/__snapshots__/TextInput.test.tsx.snap

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,6 +1408,7 @@ exports[`TextInput renders trailingAction icon button 1`] = `
14081408
14091409
.c4 [data-component="leadingVisual"] {
14101410
grid-area: leadingVisual;
1411+
color: #57606a;
14111412
}
14121413
14131414
.c4 [data-component="text"] {
@@ -1422,6 +1423,7 @@ exports[`TextInput renders trailingAction icon button 1`] = `
14221423
14231424
.c4 [data-component="trailingAction"] {
14241425
margin-right: -4px;
1426+
color: #57606a;
14251427
}
14261428
14271429
.c4 [data-component="buttonContent"] {
@@ -1456,7 +1458,7 @@ exports[`TextInput renders trailingAction icon button 1`] = `
14561458
background-color: hsla(220,14%,94%,1);
14571459
}
14581460
1459-
.c4 svg {
1461+
.c4[data-component="IconButton"][data-no-visuals] {
14601462
color: #57606a;
14611463
}
14621464
@@ -2046,6 +2048,7 @@ exports[`TextInput renders trailingAction text button 1`] = `
20462048
20472049
.c3 [data-component="leadingVisual"] {
20482050
grid-area: leadingVisual;
2051+
color: #57606a;
20492052
}
20502053
20512054
.c3 [data-component="text"] {
@@ -2060,6 +2063,7 @@ exports[`TextInput renders trailingAction text button 1`] = `
20602063
20612064
.c3 [data-component="trailingAction"] {
20622065
margin-right: -4px;
2066+
color: #57606a;
20632067
}
20642068
20652069
.c3 [data-component="buttonContent"] {
@@ -2094,7 +2098,7 @@ exports[`TextInput renders trailingAction text button 1`] = `
20942098
background-color: hsla(220,14%,94%,1);
20952099
}
20962100
2097-
.c3 svg {
2101+
.c3[data-component="IconButton"][data-no-visuals] {
20982102
color: #57606a;
20992103
}
21002104
@@ -2438,6 +2442,7 @@ exports[`TextInput renders trailingAction text button with a tooltip 1`] = `
24382442
24392443
.c4 [data-component="leadingVisual"] {
24402444
grid-area: leadingVisual;
2445+
color: #57606a;
24412446
}
24422447
24432448
.c4 [data-component="text"] {
@@ -2452,6 +2457,7 @@ exports[`TextInput renders trailingAction text button with a tooltip 1`] = `
24522457
24532458
.c4 [data-component="trailingAction"] {
24542459
margin-right: -4px;
2460+
color: #57606a;
24552461
}
24562462
24572463
.c4 [data-component="buttonContent"] {
@@ -2486,7 +2492,7 @@ exports[`TextInput renders trailingAction text button with a tooltip 1`] = `
24862492
background-color: hsla(220,14%,94%,1);
24872493
}
24882494
2489-
.c4 svg {
2495+
.c4[data-component="IconButton"][data-no-visuals] {
24902496
color: #57606a;
24912497
}
24922498

0 commit comments

Comments
 (0)