/** * External dependencies */ import classnames from 'classnames'; /** * Internal dependencies */ import './style.scss'; import Title from '../title'; interface StepHeadingProps { title: string; stepHeadingContent?: JSX.Element; } const StepHeading = ( { title, stepHeadingContent }: StepHeadingProps ) => (
{ !! stepHeadingContent && ( { stepHeadingContent } ) }
); export interface FormStepProps { id?: string; className?: string; title?: string; legend?: string; description?: string; children?: React.ReactNode; disabled?: boolean; showStepNumber?: boolean; stepHeadingContent?: () => JSX.Element | undefined; } const FormStep = ( { id, className, title, legend, description, children, disabled = false, showStepNumber = true, stepHeadingContent = () => undefined, }: FormStepProps ): JSX.Element => { // If the form step doesn't have a legend or title, render a
instead // of a
. const Element = legend || title ? 'fieldset' : 'div'; return ( { !! ( legend || title ) && ( { legend || title } ) } { !! title && ( ) }
{ !! description && (

{ description }

) }
{ children }
); }; export default FormStep;