diff --git a/.changeset/afraid-pens-return.md b/.changeset/afraid-pens-return.md new file mode 100644 index 00000000000..3711c80a99c --- /dev/null +++ b/.changeset/afraid-pens-return.md @@ -0,0 +1,5 @@ +--- +'@primer/react': minor +--- + +Remove the CSS modules feature flag from the CheckboxOrRadioGroup component diff --git a/packages/react/src/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroup.tsx b/packages/react/src/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroup.tsx index 9072e0fa67b..e69139bb51d 100644 --- a/packages/react/src/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroup.tsx +++ b/packages/react/src/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroup.tsx @@ -1,8 +1,5 @@ import React from 'react' -import styled from 'styled-components' -import Box from '../../../Box' import ValidationAnimationContainer from '../ValidationAnimationContainer' -import {get} from '../../../constants' import {useId} from '../../../hooks/useId' import CheckboxOrRadioGroupCaption from './CheckboxOrRadioGroupCaption' import CheckboxOrRadioGroupLabel from './CheckboxOrRadioGroupLabel' @@ -12,10 +9,8 @@ import VisuallyHidden from '../../../_VisuallyHidden' import {useSlots} from '../../../hooks/useSlots' import type {SxProp} from '../../../sx' import classes from './CheckboxOrRadioGroup.module.css' -import {toggleStyledComponent} from '../../utils/toggleStyledComponent' -import {useFeatureFlag} from '../../../FeatureFlags' import {clsx} from 'clsx' -import {CSS_MODULES_FLAG} from './FeatureFlag' +import {BoxWithFallback} from '../BoxWithFallback' export type CheckboxOrRadioGroupProps = { /** Class name for custom styling */ @@ -39,22 +34,6 @@ export type CheckboxOrRadioGroupProps = { required?: boolean } & SxProp -const Body = toggleStyledComponent( - CSS_MODULES_FLAG, - 'div', - styled.div` - display: flex; - flex-direction: column; - list-style: none; - margin: 0; - padding: 0; - - > * + * { - margin-top: ${get('space.2')}; - } - `, -) - const CheckboxOrRadioGroup: React.FC> = ({ 'aria-labelledby': ariaLabelledby, children, @@ -91,150 +70,6 @@ const CheckboxOrRadioGroup: React.FC -
- - {labelChild ? ( - /* - Placing the caption text and validation text in the provides a better user - experience for more screenreaders. - - Reference: https://blog.tenon.io/accessible-validation-of-checkbox-and-radiobutton-groups/ - */ - - {slots.label} - {slots.caption} - {React.isValidElement(slots.validation) && slots.validation.props.children && ( - {slots.validation.props.children} - )} - - ) : ( - /* - If CheckboxOrRadioGroup.Label wasn't passed as a child, we don't render a - but we still want to render a caption - */ - slots.caption - )} - - - {React.Children.toArray(rest).filter(child => React.isValidElement(child))} - - - {validationChild && ( - - aria-hidden={Boolean(labelChild)} - show - > - {slots.validation} - - )} -
- - ) - } - return ( - -
-
- {labelChild ? ( - /* - Placing the caption text and validation text in the provides a better user - experience for more screenreaders. - - Reference: https://blog.tenon.io/accessible-validation-of-checkbox-and-radiobutton-groups/ - */ - - {slots.label} - {slots.caption} - {React.isValidElement(slots.validation) && slots.validation.props.children && ( - {slots.validation.props.children} - )} - - ) : ( - /* - If CheckboxOrRadioGroup.Label wasn't passed as a child, we don't render a - but we still want to render a caption - */ - slots.caption - )} - - - {React.Children.toArray(rest).filter(child => React.isValidElement(child))} - -
- {validationChild && ( - - aria-hidden={Boolean(labelChild)} - show - > - {slots.validation} - - )} -
-
- ) - } - return (
- {labelChild ? ( /* - Placing the caption text and validation text in the provides a better user - experience for more screenreaders. + Placing the caption text and validation text in the provides a better user + experience for more screenreaders. - Reference: https://blog.tenon.io/accessible-validation-of-checkbox-and-radiobutton-groups/ - */ - + Reference: https://blog.tenon.io/accessible-validation-of-checkbox-and-radiobutton-groups/ + */ + {slots.label} {slots.caption} {React.isValidElement(slots.validation) && slots.validation.props.children && ( {slots.validation.props.children} )} - + ) : ( /* - If CheckboxOrRadioGroup.Label wasn't passed as a child, we don't render a - but we still want to render a caption - */ + If CheckboxOrRadioGroup.Label wasn't passed as a child, we don't render a + but we still want to render a caption + */ slots.caption )} - {React.Children.toArray(rest).filter(child => React.isValidElement(child))} - - +
+ {validationChild && ( diff --git a/packages/react/src/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroupCaption.tsx b/packages/react/src/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroupCaption.tsx index 4e74d4fc6bb..bd7735d1fb3 100644 --- a/packages/react/src/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroupCaption.tsx +++ b/packages/react/src/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroupCaption.tsx @@ -3,32 +3,14 @@ import Text from '../../../Text' import type {SxProp} from '../../../sx' import CheckboxOrRadioGroupContext from './CheckboxOrRadioGroupContext' import classes from './CheckboxOrRadioGroup.module.css' -import {CSS_MODULES_FLAG} from './FeatureFlag' -import {useFeatureFlag} from '../../../FeatureFlags' import {clsx} from 'clsx' type CheckboxOrRadioGroupCaptionProps = React.PropsWithChildren & {className?: string} const CheckboxOrRadioGroupCaption: React.FC = ({className, children, sx}) => { - const {disabled, captionId} = React.useContext(CheckboxOrRadioGroupContext) - const enabled = useFeatureFlag(CSS_MODULES_FLAG) - if (enabled) { - if (sx) { - return ( - - {children} - - ) - } - return ( - - {children} - - ) - } - + const {captionId} = React.useContext(CheckboxOrRadioGroupContext) return ( - + {children} ) diff --git a/packages/react/src/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroupLabel.tsx b/packages/react/src/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroupLabel.tsx index 01de81a1d8e..674850cda4b 100644 --- a/packages/react/src/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroupLabel.tsx +++ b/packages/react/src/internal/components/CheckboxOrRadioGroup/CheckboxOrRadioGroupLabel.tsx @@ -1,10 +1,7 @@ import React from 'react' -import Box from '../../../Box' import VisuallyHidden from '../../../_VisuallyHidden' import type {SxProp} from '../../../sx' import CheckboxOrRadioGroupContext from './CheckboxOrRadioGroupContext' -import {CSS_MODULES_FLAG} from './FeatureFlag' -import {useFeatureFlag} from '../../../FeatureFlags' import classes from './CheckboxOrRadioGroup.module.css' import {Stack} from '../../../Stack' import {clsx} from 'clsx' @@ -25,67 +22,20 @@ const CheckboxOrRadioGroupLabel: React.FC { const {required, disabled} = React.useContext(CheckboxOrRadioGroupContext) - const enabled = useFeatureFlag(CSS_MODULES_FLAG) - - if (enabled) { - if (sx) { - return ( - - {required ? ( - -
{children}
- * -
- ) : ( - children - )} -
- ) - } - - return ( - - {required ? ( - -
{children}
- * -
- ) : ( - children - )} -
- ) - } return ( {required ? ( - - {children} + +
{children}
* -
+ ) : ( children )} diff --git a/packages/react/src/internal/components/CheckboxOrRadioGroup/FeatureFlag.tsx b/packages/react/src/internal/components/CheckboxOrRadioGroup/FeatureFlag.tsx deleted file mode 100644 index e6a5b8afae0..00000000000 --- a/packages/react/src/internal/components/CheckboxOrRadioGroup/FeatureFlag.tsx +++ /dev/null @@ -1 +0,0 @@ -export const CSS_MODULES_FLAG = 'primer_react_css_modules_ga'