Skip to content

Commit fbd7fc9

Browse files
authored
Remove CSS modules feature flag from VisuallyHidden (#5785)
1 parent fc10f29 commit fbd7fc9

File tree

4 files changed

+20
-59
lines changed

4 files changed

+20
-59
lines changed

.changeset/gold-ducks-grin.md

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 CSS modules feature flag from VisuallyHidden

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

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

33
exports[`CounterLabel renders with secondary scheme when no "scheme" prop is provided 1`] = `
4-
.c0:not(:focus):not(:active):not(:focus-within) {
5-
-webkit-clip-path: inset(50%);
6-
clip-path: inset(50%);
7-
height: 1px;
8-
overflow: hidden;
9-
position: absolute;
10-
white-space: nowrap;
11-
width: 1px;
12-
}
13-
144
<div>
155
<span
166
aria-hidden="true"
@@ -20,7 +10,7 @@ exports[`CounterLabel renders with secondary scheme when no "scheme" prop is pro
2010
1234
2111
</span>
2212
<span
23-
class="c0"
13+
class="VisuallyHidden"
2414
>
2515
 (
2616
1234
@@ -30,16 +20,6 @@ exports[`CounterLabel renders with secondary scheme when no "scheme" prop is pro
3020
`;
3121

3222
exports[`CounterLabel respects the primary "scheme" prop 1`] = `
33-
.c0:not(:focus):not(:active):not(:focus-within) {
34-
-webkit-clip-path: inset(50%);
35-
clip-path: inset(50%);
36-
height: 1px;
37-
overflow: hidden;
38-
position: absolute;
39-
white-space: nowrap;
40-
width: 1px;
41-
}
42-
4323
<div>
4424
<span
4525
aria-hidden="true"
@@ -49,7 +29,7 @@ exports[`CounterLabel respects the primary "scheme" prop 1`] = `
4929
1234
5030
</span>
5131
<span
52-
class="c0"
32+
class="VisuallyHidden"
5333
>
5434
 (
5535
1234

packages/react/src/VisuallyHidden/VisuallyHidden.tsx

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
import styled from 'styled-components'
21
import type {SxProp} from '../sx'
3-
import sx from '../sx'
4-
import {toggleStyledComponent} from '../internal/utils/toggleStyledComponent'
52
import {clsx} from 'clsx'
6-
import {useFeatureFlag} from '../FeatureFlags'
73
import React, {type HTMLAttributes} from 'react'
84
import classes from './VisuallyHidden.module.css'
9-
10-
const CSS_MODULES_FEATURE_FLAG = 'primer_react_css_modules_ga'
5+
import {defaultSxProp} from '../utils/defaultSxProp'
6+
import Box from '../Box'
117

128
/**
139
* Provides a component that implements the "visually hidden" technique. This is
@@ -19,29 +15,19 @@ const CSS_MODULES_FEATURE_FLAG = 'primer_react_css_modules_ga'
1915
*
2016
* @see https://www.scottohara.me/blog/2023/03/21/visually-hidden-hack.html
2117
*/
22-
const StyledVisuallyHidden = toggleStyledComponent(
23-
CSS_MODULES_FEATURE_FLAG,
24-
'span',
25-
styled.span<SxProp>`
26-
&:not(:focus):not(:active):not(:focus-within) {
27-
clip-path: inset(50%);
28-
height: 1px;
29-
overflow: hidden;
30-
position: absolute;
31-
white-space: nowrap;
32-
width: 1px;
33-
}
34-
35-
${sx}
36-
`,
37-
)
18+
export const VisuallyHidden = ({className, children, sx: sxProp = defaultSxProp, ...rest}: VisuallyHiddenProps) => {
19+
if (sxProp !== defaultSxProp) {
20+
return (
21+
<Box sx={sxProp} className={clsx(className, classes.VisuallyHidden)} {...rest}>
22+
{children}
23+
</Box>
24+
)
25+
}
3826

39-
export const VisuallyHidden = ({className, children, ...rest}: VisuallyHiddenProps) => {
40-
const enabled = useFeatureFlag(CSS_MODULES_FEATURE_FLAG)
4127
return (
42-
<StyledVisuallyHidden className={clsx(className, enabled && classes.VisuallyHidden)} {...rest}>
28+
<span className={clsx(className, classes.VisuallyHidden)} {...rest}>
4329
{children}
44-
</StyledVisuallyHidden>
30+
</span>
4531
)
4632
}
4733

packages/react/src/__tests__/__snapshots__/Autocomplete.test.tsx.snap

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -539,16 +539,6 @@ exports[`snapshots renders a loading state 1`] = `
539539
justify-content: center;
540540
}
541541
542-
.c2:not(:focus):not(:active):not(:focus-within) {
543-
-webkit-clip-path: inset(50%);
544-
clip-path: inset(50%);
545-
height: 1px;
546-
overflow: hidden;
547-
position: absolute;
548-
white-space: nowrap;
549-
width: 1px;
550-
}
551-
552542
.c0 {
553543
position: absolute;
554544
width: 1px;
@@ -603,7 +593,7 @@ exports[`snapshots renders a loading state 1`] = `
603593
/>
604594
</svg>
605595
<span
606-
className="c2"
596+
className="VisuallyHidden"
607597
id=":r2h:"
608598
>
609599
Loading

0 commit comments

Comments
 (0)