Files
Hugo Häggmark 119d5897ea i18n: imports use @grafana/i18n (#105177)
* i18n: everything should target @grafana/i18n

* wip

* chore: updates after PR feedback

* Trigger build

* Trigger build

* Trigger build

* chore: skip flaky tests

* chore: skip flaky tests

* chore: skip flaky tests

* chore: skip flaky tests

* chore: skip flaky tests

* chore: skip flaky tests

* chore: revert all flaky tests

* chore: some incorrect usages of useTranslate
2025-05-15 09:17:14 +02:00

46 lines
1.4 KiB
TypeScript

import { css } from '@emotion/css';
import { GrafanaTheme2 } from '@grafana/data';
import { Trans } from '@grafana/i18n';
import { Text, useStyles2 } from '@grafana/ui';
export function ProgressBar({ stepsDone, totalStepsToDo }: { stepsDone: number; totalStepsToDo: number }) {
const styles = useStyles2(getStyles);
if (totalStepsToDo === 0) {
return null;
}
return (
<div className={styles.containerStyles} role="progressbar" aria-valuenow={stepsDone} aria-valuemax={totalStepsToDo}>
<div className={styles.fillerStyles((stepsDone / totalStepsToDo) * 100)} />
</div>
);
}
export function StepsStatus({ stepsDone, totalStepsToDo }: { stepsDone: number; totalStepsToDo: number }) {
return (
<span>
<Trans i18nKey="gops.progress-bar.steps-status" values={{ stepsDone }}>
<Text color="success">{'{{stepsDone}}'}</Text> of {{ totalStepsToDo }}
</Trans>
</span>
);
}
function getStyles(theme: GrafanaTheme2) {
return {
containerStyles: css({
height: theme.spacing(2),
borderRadius: theme.shape.radius.pill,
backgroundColor: theme.colors.border.weak,
flex: 'auto',
}),
fillerStyles: (stepsDone: number) =>
css({
height: '100%',
width: `${stepsDone}%`,
backgroundColor: theme.colors.success.main,
borderRadius: theme.shape.radius.pill,
textAlign: 'right',
}),
};
}