11import { clsx } from 'clsx'
22import type { HTMLAttributes } from 'react'
33import React , { forwardRef } from 'react'
4- import styled from 'styled-components'
5- import { get } from '../constants'
6- import sx from '../sx'
74import type { SxProp } from '../sx'
85import { VisuallyHidden } from '../VisuallyHidden'
96import { defaultSxProp } from '../utils/defaultSxProp'
10- import { useFeatureFlag } from '../FeatureFlags'
117import Box from '../Box'
128import classes from './CounterLabel.module.css'
139
@@ -20,7 +16,6 @@ export type CounterLabelProps = React.PropsWithChildren<
2016
2117const 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 > ({ 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-
9348CounterLabel . displayName = 'CounterLabel'
9449
9550export default CounterLabel
0 commit comments