mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-14 10:35:11 +00:00
alerts: use shorthand return
This commit is contained in:
committed by
David Lechner
parent
95199e44c1
commit
9fe62467d5
@@ -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'),
|
||||
});
|
||||
|
||||
@@ -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'),
|
||||
});
|
||||
|
||||
@@ -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'),
|
||||
});
|
||||
|
||||
@@ -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'),
|
||||
});
|
||||
|
||||
@@ -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'),
|
||||
});
|
||||
|
||||
@@ -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'),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user