Skip to content

Commit 7d9bb0c

Browse files
authored
chore(CounterLabel): Remove the CSS modules feature flag from the CounterLabel component (#5337)
* Remove the CSS modules feature flag * Create large-grasshoppers-work.md * Update snapshot
1 parent 05db651 commit 7d9bb0c

File tree

3 files changed

+16
-84
lines changed

3 files changed

+16
-84
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@primer/react": minor
3+
---
4+
5+
Remove the CSS modules feature flag from Checkbox
Lines changed: 5 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
import {clsx} from 'clsx'
22
import type {HTMLAttributes} from 'react'
33
import React, {forwardRef} from 'react'
4-
import styled from 'styled-components'
5-
import {get} from '../constants'
6-
import sx from '../sx'
74
import type {SxProp} from '../sx'
85
import {VisuallyHidden} from '../VisuallyHidden'
96
import {defaultSxProp} from '../utils/defaultSxProp'
10-
import {useFeatureFlag} from '../FeatureFlags'
117
import Box from '../Box'
128
import classes from './CounterLabel.module.css'
139

@@ -20,7 +16,6 @@ export type CounterLabelProps = React.PropsWithChildren<
2016

2117
const CounterLabel = forwardRef<HTMLSpanElement, CounterLabelProps>(
2218
({scheme = 'secondary', sx = defaultSxProp, className, children, ...rest}, forwardedRef) => {
23-
const enabled = useFeatureFlag('primer_react_css_modules_ga')
2419
const label = <VisuallyHidden>&nbsp;({children})</VisuallyHidden>
2520
const counterProps = {
2621
ref: forwardedRef,
@@ -29,67 +24,27 @@ const CounterLabel = forwardRef<HTMLSpanElement, CounterLabelProps>(
2924
...rest,
3025
}
3126

32-
if (enabled) {
33-
if (sx !== defaultSxProp) {
34-
return (
35-
<>
36-
<Box as="span" {...counterProps} className={clsx(className, classes.CounterLabel)} sx={sx}>
37-
{children}
38-
</Box>
39-
{label}
40-
</>
41-
)
42-
}
27+
if (sx !== defaultSxProp) {
4328
return (
4429
<>
45-
<span {...counterProps} className={clsx(className, classes.CounterLabel)}>
30+
<Box as="span" {...counterProps} className={clsx(className, classes.CounterLabel)} sx={sx}>
4631
{children}
47-
</span>
32+
</Box>
4833
{label}
4934
</>
5035
)
5136
}
52-
5337
return (
5438
<>
55-
<StyledCounterLabel {...counterProps} className={className} sx={sx}>
39+
<span {...counterProps} className={clsx(className, classes.CounterLabel)}>
5640
{children}
57-
</StyledCounterLabel>
41+
</span>
5842
{label}
5943
</>
6044
)
6145
},
6246
)
6347

64-
const StyledCounterLabel = styled.span`
65-
display: inline-block;
66-
padding: var(--base-size-2, 0.125rem) var(--base-size-6, 0.375rem);
67-
font-size: 12px;
68-
font-weight: var(--base-text-weight-semibold, bold);
69-
line-height: 1;
70-
border-radius: 20px;
71-
border: var(--borderWidth-thin, max(1px, 0.0625rem)) solid var(--counter-borderColor, var(--color-counter-border));
72-
73-
&:where([data-scheme='primary']) {
74-
background-color: ${get('colors.neutral.emphasis')};
75-
color: ${get('colors.fg.onEmphasis')};
76-
}
77-
78-
&:where([data-scheme='secondary']) {
79-
background-color: ${get('colors.neutral.muted')};
80-
color: ${get('colors.fg.default')};
81-
}
82-
83-
&:where(:empty) {
84-
display: none;
85-
}
86-
87-
/* Place the sx prop styles after previously inserted styles so that it will win out in specificity */
88-
& {
89-
${sx}
90-
}
91-
`
92-
9348
CounterLabel.displayName = 'CounterLabel'
9449

9550
export default CounterLabel

packages/react/src/CounterLabel/__snapshots__/CounterLabel.test.tsx.snap

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`CounterLabel renders with secondary scheme when no "scheme" prop is provided 1`] = `
4-
.c1:not(:focus):not(:active):not(:focus-within) {
4+
.c0:not(:focus):not(:active):not(:focus-within) {
55
-webkit-clip-path: inset(50%);
66
clip-path: inset(50%);
77
height: 1px;
@@ -11,30 +11,16 @@ exports[`CounterLabel renders with secondary scheme when no "scheme" prop is pro
1111
width: 1px;
1212
}
1313
14-
.c0 {
15-
display: inline-block;
16-
padding: var(--base-size-2,0.125rem) var(--base-size-6,0.375rem);
17-
font-size: 12px;
18-
font-weight: var(--base-text-weight-semibold,bold);
19-
line-height: 1;
20-
border-radius: 20px;
21-
border: var(--borderWidth-thin,max(1px,0.0625rem)) solid var(--counter-borderColor,var(--color-counter-border));
22-
}
23-
24-
.c0:where(:empty) {
25-
display: none;
26-
}
27-
2814
<div>
2915
<span
3016
aria-hidden="true"
31-
class="c0"
17+
class="CounterLabel"
3218
data-scheme="secondary"
3319
>
3420
1234
3521
</span>
3622
<span
37-
class="c1"
23+
class="c0"
3824
>
3925
 (
4026
1234
@@ -44,7 +30,7 @@ exports[`CounterLabel renders with secondary scheme when no "scheme" prop is pro
4430
`;
4531

4632
exports[`CounterLabel respects the primary "scheme" prop 1`] = `
47-
.c1:not(:focus):not(:active):not(:focus-within) {
33+
.c0:not(:focus):not(:active):not(:focus-within) {
4834
-webkit-clip-path: inset(50%);
4935
clip-path: inset(50%);
5036
height: 1px;
@@ -54,30 +40,16 @@ exports[`CounterLabel respects the primary "scheme" prop 1`] = `
5440
width: 1px;
5541
}
5642
57-
.c0 {
58-
display: inline-block;
59-
padding: var(--base-size-2,0.125rem) var(--base-size-6,0.375rem);
60-
font-size: 12px;
61-
font-weight: var(--base-text-weight-semibold,bold);
62-
line-height: 1;
63-
border-radius: 20px;
64-
border: var(--borderWidth-thin,max(1px,0.0625rem)) solid var(--counter-borderColor,var(--color-counter-border));
65-
}
66-
67-
.c0:where(:empty) {
68-
display: none;
69-
}
70-
7143
<div>
7244
<span
7345
aria-hidden="true"
74-
class="c0"
46+
class="CounterLabel"
7547
data-scheme="primary"
7648
>
7749
1234
7850
</span>
7951
<span
80-
class="c1"
52+
class="c0"
8153
>
8254
 (
8355
1234

0 commit comments

Comments
 (0)