11import React from 'react' ;
22
33import type { TextProps } from '@gravity-ui/uikit' ;
4- import { Text } from '@gravity-ui/uikit' ;
4+ import { Flex , HelpMark , Text } from '@gravity-ui/uikit' ;
55
66import { cn } from '../../utils/cn' ;
77import type { ProgressStatus } from '../../utils/progress' ;
@@ -13,18 +13,23 @@ const b = cn('ydb-doughnut-metrics');
1313interface LegendProps {
1414 children ?: React . ReactNode ;
1515 variant ?: TextProps [ 'variant' ] ;
16+ color ?: TextProps [ 'color' ] ;
17+ note ?: React . ReactNode ;
1618}
1719
18- function Legend ( { children, variant = 'subheader-3' } : LegendProps ) {
20+ function Legend ( { children, variant = 'subheader-3' , color = 'primary' , note } : LegendProps ) {
1921 return (
20- < Text variant = { variant } color = "secondary" className = { b ( 'legend' ) } >
21- { children }
22- </ Text >
22+ < Flex gap = { 1 } alignItems = "center" >
23+ < Text variant = { variant } color = { color } className = { b ( 'legend' ) } as = "div" >
24+ { children }
25+ </ Text >
26+ { note && < HelpMark className = { b ( 'legend-note' ) } > { note } </ HelpMark > }
27+ </ Flex >
2328 ) ;
2429}
2530function Value ( { children, variant = 'subheader-2' } : LegendProps ) {
2631 return (
27- < Text variant = { variant } color = "secondary" className = { b ( 'value' ) } >
32+ < Text variant = { variant } className = { b ( 'value' ) } >
2833 { children }
2934 </ Text >
3035 ) ;
@@ -38,19 +43,21 @@ interface DoughnutProps {
3843}
3944
4045export function DoughnutMetrics ( { status, fillWidth, children, className} : DoughnutProps ) {
41- let gradientFill = 'var(--g-color-line-generic-solid)' ;
42- let filledDegrees = fillWidth * 3.6 - 90 ;
46+ let filledDegrees = fillWidth * 3.6 ;
47+ let doughnutFillVar = 'var(--doughnut-color)' ;
48+ let doughnutBackdropVar = 'var(--doughnut-backdrop-color)' ;
4349
44- if ( fillWidth > 50 ) {
45- gradientFill = 'var(--doughnut-color)' ;
46- filledDegrees = fillWidth * 3.6 + 90 ;
50+ if ( filledDegrees > 360 ) {
51+ filledDegrees -= 360 ;
52+ doughnutBackdropVar = 'var(--doughnut-color)' ;
53+ doughnutFillVar = 'var(--doughnut-overlap-color)' ;
4754 }
48- const gradientDegrees = filledDegrees ;
55+
4956 return (
5057 < div className = { b ( null , className ) } >
5158 < div
5259 style = { {
53- backgroundImage : `linear -gradient(${ gradientDegrees } deg, transparent 50% , ${ gradientFill } 50%), linear-gradient(-90deg, var(--g-color-line-generic-solid) 50%, transparent 50% )` ,
60+ background : `conic -gradient(${ doughnutFillVar } 0deg ${ filledDegrees } deg , ${ doughnutBackdropVar } ${ filledDegrees } deg 360deg )` ,
5461 } }
5562 className = { b ( 'doughnut' , { status} ) }
5663 >
0 commit comments