-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor feedback, one component for publish & edit
- Loading branch information
1 parent
8c822db
commit e973ae1
Showing
7 changed files
with
96 additions
and
172 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
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,76 @@ | ||
import Alert from '../atoms/Alert' | ||
import Button from '../atoms/Button' | ||
import Loader from '../atoms/Loader' | ||
import React, { ReactElement } from 'react' | ||
import styles from './MetadataFeedback.module.css' | ||
import SuccessConfetti from '../atoms/SuccessConfetti' | ||
|
||
interface SuccessAction { | ||
name: string | ||
onClick?: () => void | ||
to?: string | ||
} | ||
|
||
function ActionSuccess({ successAction }: { successAction: SuccessAction }) { | ||
return ( | ||
<Button | ||
style="primary" | ||
size="small" | ||
onClick={successAction.onClick ? successAction.onClick : null} | ||
to={successAction.to ? successAction.to : null} | ||
className={styles.action} | ||
> | ||
successAction.name | ||
</Button> | ||
) | ||
} | ||
|
||
function ActionError({ setError }: { setError: (error: string) => void }) { | ||
return ( | ||
<Button | ||
style="primary" | ||
size="small" | ||
className={styles.action} | ||
onClick={() => setError(undefined)} | ||
> | ||
Try Again | ||
</Button> | ||
) | ||
} | ||
|
||
export default function MetadataFeedback({ | ||
title, | ||
error, | ||
success, | ||
loading, | ||
successAction, | ||
setError | ||
}: { | ||
title: string | ||
error: string | ||
success: string | ||
loading: string | ||
successAction: SuccessAction | ||
setError: (error: string) => void | ||
}): ReactElement { | ||
return ( | ||
<div className={styles.feedback}> | ||
<div className={styles.box}> | ||
<h3>{title}</h3> | ||
{error ? ( | ||
<> | ||
<Alert text={error} state="error" /> | ||
<ActionError setError={setError} /> | ||
</> | ||
) : success ? ( | ||
<SuccessConfetti | ||
success={success} | ||
action={<ActionSuccess successAction={successAction} />} | ||
/> | ||
) : ( | ||
<Loader message={loading} /> | ||
)} | ||
</div> | ||
</div> | ||
) | ||
} |
40 changes: 0 additions & 40 deletions
40
src/components/organisms/AssetActions/Edit/Feedback.module.css
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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