-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: extract standard form actions into component
- Loading branch information
Showing
7 changed files
with
61 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.submitButtonLoadingIcon { | ||
display: block; | ||
margin-right: 8px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Button, ButtonStrip, CircularLoader } from '@dhis2/ui' | ||
import React from 'react' | ||
import classes from './StandardFormActions.module.css' | ||
|
||
function LoadingIcon() { | ||
return ( | ||
<span className={classes.submitButtonLoadingIcon}> | ||
<CircularLoader small /> | ||
</span> | ||
) | ||
} | ||
|
||
export function StandardFormActions({ | ||
cancelLabel, | ||
submitLabel, | ||
submitting, | ||
onCancelClick, | ||
}: { | ||
cancelLabel: string | ||
submitLabel: string | ||
submitting: boolean | ||
onCancelClick: () => void | ||
}) { | ||
return ( | ||
<ButtonStrip> | ||
<Button primary disabled={submitting} type="submit"> | ||
{submitting && <LoadingIcon />} | ||
{submitLabel} | ||
</Button> | ||
|
||
<Button disabled={submitting} onClick={onCancelClick}> | ||
{cancelLabel} | ||
</Button> | ||
</ButtonStrip> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters