import * as React from 'react' ; import { Text } from 'ink' ; import { BarData } from '../types' ; export const SectionedBar = ( { data } ) => { const barTick = '■' ; const randomColor = '#' + Math . floor ( Math . random ( ) * 16777215 ) . toString ( 16 ) ; const width = 50 ; const normalizeSegment = function ( amount ) { return Math . ceil ( data . total < width ? amount * ( width / data . total ) : amount / ( data . total / width ) ) ; } ; return ( < Text > < Text color = { randomColor } > { barTick . repeat ( normalizeSegment ( data . value ) ) } < /Text> {data.name} ( { data . value } ) < /Text>); } ;