Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/gold-ducks-grin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": minor
---

Remove CSS modules feature flag from VisuallyHidden
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`CounterLabel renders with secondary scheme when no "scheme" prop is provided 1`] = `
.c0:not(:focus):not(:active):not(:focus-within) {
-webkit-clip-path: inset(50%);
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}

<div>
<span
aria-hidden="true"
Expand All @@ -20,7 +10,7 @@ exports[`CounterLabel renders with secondary scheme when no "scheme" prop is pro
1234
</span>
<span
class="c0"
class="VisuallyHidden"
>
 (
1234
Expand All @@ -30,16 +20,6 @@ exports[`CounterLabel renders with secondary scheme when no "scheme" prop is pro
`;

exports[`CounterLabel respects the primary "scheme" prop 1`] = `
.c0:not(:focus):not(:active):not(:focus-within) {
-webkit-clip-path: inset(50%);
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}

<div>
<span
aria-hidden="true"
Expand All @@ -49,7 +29,7 @@ exports[`CounterLabel respects the primary "scheme" prop 1`] = `
1234
</span>
<span
class="c0"
class="VisuallyHidden"
>
 (
1234
Expand Down
38 changes: 12 additions & 26 deletions packages/react/src/VisuallyHidden/VisuallyHidden.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import styled from 'styled-components'
import type {SxProp} from '../sx'
import sx from '../sx'
import {toggleStyledComponent} from '../internal/utils/toggleStyledComponent'
import {clsx} from 'clsx'
import {useFeatureFlag} from '../FeatureFlags'
import React, {type HTMLAttributes} from 'react'
import classes from './VisuallyHidden.module.css'

const CSS_MODULES_FEATURE_FLAG = 'primer_react_css_modules_ga'
import {defaultSxProp} from '../utils/defaultSxProp'
import Box from '../Box'

/**
* Provides a component that implements the "visually hidden" technique. This is
Expand All @@ -19,29 +15,19 @@ const CSS_MODULES_FEATURE_FLAG = 'primer_react_css_modules_ga'
*
* @see https://www.scottohara.me/blog/2023/03/21/visually-hidden-hack.html
*/
const StyledVisuallyHidden = toggleStyledComponent(
CSS_MODULES_FEATURE_FLAG,
'span',
styled.span<SxProp>`
&:not(:focus):not(:active):not(:focus-within) {
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}

${sx}
`,
)
export const VisuallyHidden = ({className, children, sx: sxProp = defaultSxProp, ...rest}: VisuallyHiddenProps) => {
if (sxProp !== defaultSxProp) {
return (
<Box sx={sxProp} className={clsx(className, classes.VisuallyHidden)} {...rest}>
{children}
</Box>
)
}

export const VisuallyHidden = ({className, children, ...rest}: VisuallyHiddenProps) => {
const enabled = useFeatureFlag(CSS_MODULES_FEATURE_FLAG)
return (
<StyledVisuallyHidden className={clsx(className, enabled && classes.VisuallyHidden)} {...rest}>
<span className={clsx(className, classes.VisuallyHidden)} {...rest}>
{children}
</StyledVisuallyHidden>
</span>
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,16 +539,6 @@ exports[`snapshots renders a loading state 1`] = `
justify-content: center;
}

.c2:not(:focus):not(:active):not(:focus-within) {
-webkit-clip-path: inset(50%);
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}

.c0 {
position: absolute;
width: 1px;
Expand Down Expand Up @@ -603,7 +593,7 @@ exports[`snapshots renders a loading state 1`] = `
/>
</svg>
<span
className="c2"
className="VisuallyHidden"
id=":r2h:"
>
Loading
Expand Down
Loading