// SPDX-License-Identifier: MIT // Copyright (c) 2022 The Pybricks Authors import { Intent, ProgressBar } from '@blueprintjs/core'; import React from 'react'; import { CreateToast } from '../../i18nToaster'; import { useI18n } from './i18n'; type FlashProgressProps = { action: 'erase' | 'flash'; progress: number | undefined; }; const FlashProgress: React.VoidFunctionComponent = ({ action, progress, }) => { const i18n = useI18n(); return ( <> {action === 'erase' && (

{i18n.translate('flashProgress.erasing', { percent: progress ? i18n.formatPercentage(progress) : '', })}

)} {action === 'flash' && (

{i18n.translate('flashProgress.flashing', { percent: progress ? i18n.formatPercentage(progress) : '', })}

)} ); }; export const flashProgress: CreateToast = (onAction, props) => { return { message: , icon: 'download', intent: Intent.PRIMARY, // close one second after progress is complete timeout: (props.progress ?? 0) < 1 ? 0 : 1000, onDismiss: () => onAction('dismiss'), }; };