Skip to content

Commit

Permalink
fix(CounterLabel): update styles to work with sx overrides (#5111)
Browse files Browse the repository at this point in the history
* fix(CounterLabel): update styles to work with sx overrides

* test: update snapshots

---------

Co-authored-by: Josh Black <joshblack@users.noreply.github.com>
  • Loading branch information
joshblack and joshblack authored Oct 14, 2024
1 parent a8b17d8 commit 802568a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/spicy-pants-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

Update CSS styles for CounterLabel to allow overrides for color, background color
6 changes: 3 additions & 3 deletions packages/react/src/CounterLabel/CounterLabel.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
/* stylelint-disable-next-line primer/borders */
border-radius: 20px;

&[data-scheme='primary'] {
&:where([data-scheme='primary']) {
color: var(--fgColor-onEmphasis);
background-color: var(--bgColor-neutral-emphasis);
}

&[data-scheme='secondary'] {
&:where([data-scheme='secondary']) {
color: var(--fgColor-default);
background-color: var(--bgColor-neutral-muted);
}

&:empty {
&:where(:empty) {
display: none;
}
}
11 changes: 7 additions & 4 deletions packages/react/src/CounterLabel/CounterLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,24 @@ const StyledCounterLabel = styled.span`
border-radius: 20px;
border: var(--borderWidth-thin, max(1px, 0.0625rem)) solid var(--counter-borderColor, var(--color-counter-border));
&[data-scheme='primary'] {
&:where([data-scheme='primary']) {
background-color: ${get('colors.neutral.emphasis')};
color: ${get('colors.fg.onEmphasis')};
}
&[data-scheme='secondary'] {
&:where([data-scheme='secondary']) {
background-color: ${get('colors.neutral.muted')};
color: ${get('colors.fg.default')};
}
&:empty {
&:where(:empty) {
display: none;
}
${sx}
/* Place the sx prop styles after previously inserted styles so that it will win out in specificity */
& {
${sx}
}
`

CounterLabel.displayName = 'CounterLabel'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ exports[`CounterLabel renders with secondary scheme when no "scheme" prop is pro
border: var(--borderWidth-thin,max(1px,0.0625rem)) solid var(--counter-borderColor,var(--color-counter-border));
}
.c0:empty {
.c0:where(:empty) {
display: none;
}
Expand Down Expand Up @@ -64,7 +64,7 @@ exports[`CounterLabel respects the primary "scheme" prop 1`] = `
border: var(--borderWidth-thin,max(1px,0.0625rem)) solid var(--counter-borderColor,var(--color-counter-border));
}
.c0:empty {
.c0:where(:empty) {
display: none;
}
Expand Down

0 comments on commit 802568a

Please sign in to comment.