From 9a7127733433378e0632f70b8a3ba0039488658e Mon Sep 17 00:00:00 2001 From: Jenna Badanowski <29607818+jbadan@users.noreply.github.com> Date: Fri, 21 Aug 2020 14:40:46 -0700 Subject: [PATCH] feat: BREAKING CHANGE: checkbox replace state with validation states (#1176) Breaking change: Checkbox: replace `state` property with `validationState` --- src/Forms/Checkbox.js | 32 ++- src/Forms/Checkbox.test.js | 10 + src/Forms/__stories__/Checkbox.stories.js | 20 +- .../__snapshots__/Checkbox.stories.storyshot | 186 ++++++++++++------ 4 files changed, 169 insertions(+), 79 deletions(-) diff --git a/src/Forms/Checkbox.js b/src/Forms/Checkbox.js index 56408d0cd..4100b6af9 100644 --- a/src/Forms/Checkbox.js +++ b/src/Forms/Checkbox.js @@ -3,6 +3,7 @@ import classnames from 'classnames'; import { FORM_MESSAGE_TYPES } from '../utils/constants'; import FormItem from './FormItem'; import FormLabel from './FormLabel'; +import FormValidationOverlay from './_FormValidationOverlay'; import PropTypes from 'prop-types'; import useUniqueId from '../utils/useUniqueId'; import React, { useEffect, useRef } from 'react'; @@ -21,13 +22,14 @@ const Checkbox = React.forwardRef(({ id, indeterminate, inline, + inputClassName, inputProps, labelClassName, labelProps, name, onChange, value, - state, + validationState, ...props }, ref) => { @@ -38,12 +40,13 @@ const Checkbox = React.forwardRef(({ }); - const inputClassName = classnames( + const inputClassNames = classnames( 'fd-checkbox', { - [`is-${state}`]: state, + [`is-${validationState?.state}`]: validationState?.state, 'fd-checkbox--compact': compact - } + }, + inputClassName ); const labelClasses = classnames( @@ -60,7 +63,7 @@ const Checkbox = React.forwardRef(({ ) : children; - return ( + const checkbox = ( ); + + return validationState ? ( + + ) : checkbox; }); Checkbox.displayName = 'Checkbox'; @@ -122,6 +131,8 @@ Please ensure you are either using a visible \`FormLabel\` or an \`aria-label\` indeterminate: PropTypes.bool, /** Internal use only */ inline: PropTypes.bool, + /** Class name to be added to the component `` element */ + inputClassName: PropTypes.string, /** Additional props to be spread to the `` element */ inputProps: PropTypes.object, /** Class name to be added to the component `