alerts: use shorthand return

This commit is contained in:
David Lechner
2022-11-22 15:56:56 -06:00
committed by David Lechner
parent 95199e44c1
commit 9fe62467d5
17 changed files with 109 additions and 140 deletions
+6 -8
View File
@@ -23,11 +23,9 @@ const DfuError: React.VoidFunctionComponent<DfuErrorProps> = ({ onTryAgain }) =>
);
};
export const dfuError: CreateToast<never, 'dismiss' | 'tryAgain'> = (onAction) => {
return {
message: <DfuError onTryAgain={() => onAction('tryAgain')} />,
icon: 'error',
intent: Intent.DANGER,
onDismiss: () => onAction('dismiss'),
};
};
export const dfuError: CreateToast<never, 'dismiss' | 'tryAgain'> = (onAction) => ({
message: <DfuError onTryAgain={() => onAction('tryAgain')} />,
icon: 'error',
intent: Intent.DANGER,
onDismiss: () => onAction('dismiss'),
});
+8 -10
View File
@@ -40,13 +40,11 @@ const FlashProgress: React.VoidFunctionComponent<FlashProgressProps> = ({
);
};
export const flashProgress: CreateToast<FlashProgressProps> = (onAction, props) => {
return {
message: <FlashProgress {...props} />,
icon: 'download',
intent: Intent.PRIMARY,
// close one second after progress is complete
timeout: (props.progress ?? 0) < 1 ? 0 : 1000,
onDismiss: () => onAction('dismiss'),
};
};
export const flashProgress: CreateToast<FlashProgressProps> = (onAction, props) => ({
message: <FlashProgress {...props} />,
icon: 'download',
intent: Intent.PRIMARY,
// close one second after progress is complete
timeout: (props.progress ?? 0) < 1 ? 0 : 1000,
onDismiss: () => onAction('dismiss'),
});
+6 -8
View File
@@ -33,11 +33,9 @@ const NoDfuHub: React.VoidFunctionComponent = () => {
);
};
export const noDfuHub: CreateToast = (onAction) => {
return {
message: <NoDfuHub />,
icon: 'info-sign',
intent: Intent.PRIMARY,
onDismiss: () => onAction('dismiss'),
};
};
export const noDfuHub: CreateToast = (onAction) => ({
message: <NoDfuHub />,
icon: 'info-sign',
intent: Intent.PRIMARY,
onDismiss: () => onAction('dismiss'),
});
+6 -8
View File
@@ -11,11 +11,9 @@ const NoDfuInterface: React.VoidFunctionComponent = () => {
return <p>{i18n.translate('noDfuInterface.message')}</p>;
};
export const noDfuInterface: CreateToast = (onAction) => {
return {
message: <NoDfuInterface />,
icon: 'error',
intent: Intent.DANGER,
onDismiss: () => onAction('dismiss'),
};
};
export const noDfuInterface: CreateToast = (onAction) => ({
message: <NoDfuInterface />,
icon: 'error',
intent: Intent.DANGER,
onDismiss: () => onAction('dismiss'),
});
+6 -8
View File
@@ -16,11 +16,9 @@ const NoWebUsb: React.VoidFunctionComponent = () => {
);
};
export const noWebUsb: CreateToast = (onAction) => {
return {
message: <NoWebUsb />,
icon: 'error',
intent: Intent.DANGER,
onDismiss: () => onAction('dismiss'),
};
};
export const noWebUsb: CreateToast = (onAction) => ({
message: <NoWebUsb />,
icon: 'error',
intent: Intent.DANGER,
onDismiss: () => onAction('dismiss'),
});
+6 -8
View File
@@ -11,11 +11,9 @@ const ReleaseButton: React.VoidFunctionComponent = () => {
return <p>{i18n.translate('releaseButton.message')}</p>;
};
export const releaseButton: CreateToast = (onAction) => {
return {
message: <ReleaseButton />,
icon: 'info-sign',
intent: Intent.PRIMARY,
onDismiss: () => onAction('dismiss'),
};
};
export const releaseButton: CreateToast = (onAction) => ({
message: <ReleaseButton />,
icon: 'info-sign',
intent: Intent.PRIMARY,
onDismiss: () => onAction('dismiss'),
});