/
githubmirror
/
ydb-embedded-ui
Обзор
Документация
Войти
/
githubmirror
/
ydb-embedded-ui
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/components/PoolBar/PoolBar.tsx
37 строк
1021 B
Valerii Sidorenko
feat!: update to uikit 6 (#789)
10 апр 2024, 16:48
Не верифицирован
10 апр 2024, 16:48
1a3154d
Код
Авторство
О чём код?
import type {TPoolStats} from '../../types/api/nodes'; import {cn} from '../../utils/cn'; import {ContentWithPopup} from '../ContentWithPopup/ContentWithPopup'; import {PoolTooltipContent} from '../TooltipsContent'; import './PoolBar.scss'; const b = cn('ydb-pool-bar'); const getBarType = (usage: number) => { if (usage >= 75) { return 'danger'; } else if (usage >= 50 && usage < 75) { return 'warning'; } else { return 'normal'; } }; interface PoolBarProps { data?: TPoolStats; } export const PoolBar = ({data = {}}: PoolBarProps) => { const {Usage: usage = 0} = data; const usagePercents = Math.min(usage * 100, 100); const type = getBarType(usagePercents); return ( <ContentWithPopup className={b({type})} content={<PoolTooltipContent data={data} className={b('popup-content')} />} > <div style={{height: `${usagePercents}%`}} className={b('value', {type})} /> </ContentWithPopup> ); };