-
Notifications
You must be signed in to change notification settings - Fork 356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(Wizard): ability to add props to WizardFooter buttons #9709
Changes from 4 commits
6326b29
c5ee199
0427f12
e971c99
541693e
b13ca84
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,15 @@ import React from 'react'; | |
import { css } from '@patternfly/react-styles'; | ||
import styles from '@patternfly/react-styles/css/components/Wizard/wizard'; | ||
|
||
import { Button, ButtonVariant } from '../Button'; | ||
import { Button, ButtonProps, ButtonVariant } from '../Button'; | ||
import { isCustomWizardFooter, WizardStepType } from './types'; | ||
|
||
/** | ||
* Hosts the standard structure of a footer with ties to the active step so that text for buttons can vary from step to step. | ||
*/ | ||
|
||
type FooterButtonProps = Omit<ButtonProps, 'children' | 'variant' | 'onClick'>; | ||
|
||
export interface WizardFooterProps { | ||
/** The active step */ | ||
activeStep: WizardStepType; | ||
|
@@ -33,6 +35,12 @@ export interface WizardFooterProps { | |
isBackHidden?: boolean; | ||
/** Flag to hide the cancel button */ | ||
isCancelHidden?: boolean; | ||
/** Additional props for the Next button. */ | ||
nextButtonProps?: Omit<FooterButtonProps, 'isDisabled' | 'type'>; | ||
/** Additional props for the Back button. */ | ||
backButtonProps?: Omit<FooterButtonProps, 'isDisabled'>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason for including There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am omitting that |
||
/** Additional props for the Cancel button. */ | ||
cancelButtonProps?: FooterButtonProps; | ||
} | ||
|
||
/** | ||
|
@@ -62,22 +70,31 @@ const InternalWizardFooter = ({ | |
isCancelHidden, | ||
nextButtonText = 'Next', | ||
backButtonText = 'Back', | ||
cancelButtonText = 'Cancel' | ||
cancelButtonText = 'Cancel', | ||
nextButtonProps, | ||
backButtonProps, | ||
cancelButtonProps | ||
}: Omit<WizardFooterProps, 'activeStep'>) => ( | ||
<WizardFooterWrapper> | ||
{!isBackHidden && ( | ||
<Button variant={ButtonVariant.secondary} onClick={onBack} isDisabled={isBackDisabled}> | ||
<Button variant={ButtonVariant.secondary} onClick={onBack} isDisabled={isBackDisabled} {...backButtonProps}> | ||
{backButtonText} | ||
</Button> | ||
)} | ||
|
||
<Button variant={ButtonVariant.primary} type="submit" onClick={onNext} isDisabled={isNextDisabled}> | ||
<Button | ||
variant={ButtonVariant.primary} | ||
type="submit" | ||
onClick={onNext} | ||
isDisabled={isNextDisabled} | ||
{...nextButtonProps} | ||
> | ||
{nextButtonText} | ||
</Button> | ||
|
||
{!isCancelHidden && ( | ||
<div className={styles.wizardFooterCancel}> | ||
<Button variant={ButtonVariant.link} onClick={onClose}> | ||
<Button variant={ButtonVariant.link} onClick={onClose} {...cancelButtonProps}> | ||
{cancelButtonText} | ||
</Button> | ||
</div> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be placed before line 9. That comment currently renders a description of the WizardFooter component, and placing this type here removes that description on the site.