11import { useEffect , useState } from "react" ;
2- import Text from "components/atoms/Typography/text" ;
3- import Tooltip from "components/atoms/Tooltip/tooltip" ;
42import colors from "../../../lib/utils/color.json" ;
53
64export interface AllSimpleColors {
@@ -19,22 +17,15 @@ export interface LanguageObject {
1917
2018interface CardHorizontalBarChartProps {
2119 languageList : LanguageObject [ ] ;
22- withDescription : boolean ;
2320}
2421
2522const languageToColor : AllSimpleColors = colors as AllSimpleColors ;
2623
27- const CardHorizontalBarChart = ( { languageList, withDescription } : CardHorizontalBarChartProps ) : JSX . Element => {
24+ const CardHorizontalBarChart = ( { languageList } : CardHorizontalBarChartProps ) : JSX . Element => {
2825 const sortedLangArray = languageList . sort ( ( a , b ) => b . percentageUsed - a . percentageUsed ) ;
2926 // used this state to calculate thte percentage of each language
3027 const [ percentage , setPercentage ] = useState < any > ( 0 ) ;
3128
32- const [ descriptText , setDescriptText ] = useState ( sortedLangArray [ 0 ] ?. languageName || "javascript" ) ;
33-
34- const handleChangeDescriptText = ( descriptText : string ) => {
35- setDescriptText ( descriptText ) ;
36- } ;
37-
3829 useEffect ( ( ) => {
3930 if ( sortedLangArray . length === 0 ) return ;
4031
@@ -54,7 +45,6 @@ const CardHorizontalBarChart = ({ languageList, withDescription }: CardHorizonta
5445 index < 5 && (
5546 < div
5647 key = { index }
57- onMouseOver = { ( ) => handleChangeDescriptText ( languageName ) }
5848 className = "h-2 transition-all duration-500 ease-in-out"
5949 style = { {
6050 width : `${ percentageUsed < 20 ? ( percentageUsed / percentage ) * 100 : percentageUsed } %` ,
@@ -67,21 +57,6 @@ const CardHorizontalBarChart = ({ languageList, withDescription }: CardHorizonta
6757 ) ;
6858 } ) }
6959 </ div >
70- { withDescription && (
71- < div className = "flex gap-2 w-32 items-baseline" >
72- < div
73- className = { "w-2 h-2 rounded-full" }
74- style = { {
75- backgroundColor : languageToColor [ descriptText ]
76- ? ( languageToColor [ descriptText ] . color as string )
77- : NOTSUPPORTED ,
78- } }
79- />
80- < Tooltip className = "max-w-[100px]" content = { descriptText } >
81- < Text className = "!text-xs !truncate !font-semibold !text-light-slate-11" > { descriptText } </ Text >
82- </ Tooltip >
83- </ div >
84- ) }
8560 </ div >
8661 ) ;
8762} ;
0 commit comments