From 03edc20bb16cf848898d5fcf4379b729f2db4da8 Mon Sep 17 00:00:00 2001 From: Andrew Holloway Date: Mon, 10 Jun 2024 19:27:05 -0500 Subject: [PATCH] refactor(Radio): address component QA feedback (#1986) - stop using radio icons which can now be removed - replace with styling using in-DOM elements (future proof for transitions) - better application of color tokens - add tests - update snapshots --- .../Checkbox/Checkbox-v2.stories.tsx | 1 + src/components/Checkbox/Checkbox-v2.tsx | 16 +- src/components/Radio/Radio-v2.module.css | 179 ++++++--- src/components/Radio/Radio-v2.stories.tsx | 6 +- src/components/Radio/Radio-v2.test.tsx | 41 ++ src/components/Radio/Radio-v2.tsx | 99 ++--- .../__snapshots__/Radio-v2.test.tsx.snap | 357 ++++++++++++++++++ 7 files changed, 576 insertions(+), 123 deletions(-) create mode 100644 src/components/Radio/Radio-v2.test.tsx create mode 100644 src/components/Radio/__snapshots__/Radio-v2.test.tsx.snap diff --git a/src/components/Checkbox/Checkbox-v2.stories.tsx b/src/components/Checkbox/Checkbox-v2.stories.tsx index 4232ce91c..e55e1459e 100644 --- a/src/components/Checkbox/Checkbox-v2.stories.tsx +++ b/src/components/Checkbox/Checkbox-v2.stories.tsx @@ -1,5 +1,6 @@ import type { StoryObj, Meta } from '@storybook/react'; import React from 'react'; + import { Checkbox } from './Checkbox-v2'; const meta: Meta = { diff --git a/src/components/Checkbox/Checkbox-v2.tsx b/src/components/Checkbox/Checkbox-v2.tsx index e0e16737f..85d34098d 100644 --- a/src/components/Checkbox/Checkbox-v2.tsx +++ b/src/components/Checkbox/Checkbox-v2.tsx @@ -1,16 +1,16 @@ import clsx from 'clsx'; import React, { forwardRef } from 'react'; import type { ReactNode } from 'react'; + +import { FieldLabelV2 as FieldLabel } from '../..'; import useForwardedRef from '../../util/useForwardedRef'; import { useId } from '../../util/useId'; import type { EitherInclusive } from '../../util/utility-types'; -import { InputLabel, type InputLabelProps } from '../InputLabel/InputLabel'; import Text from '../Text'; import styles from './Checkbox-v2.module.css'; -type CheckboxLabelProps = InputLabelProps; type CheckboxHTMLElementProps = Omit< React.InputHTMLAttributes, 'checked' | 'id' | 'size' @@ -98,12 +98,6 @@ const CheckboxInput = React.forwardRef( }, ); -const CheckboxLabel = ({ className, ...other }: CheckboxLabelProps) => { - const componentClassName = clsx(className); - - return ; -}; - /** * `import {Checkbox} from "@chanzuckerberg/eds";` * @@ -137,9 +131,9 @@ export const Checkbox = Object.assign( />
{label && ( - + {label} - + )} {subLabel && (