Skip to content

Commit

Permalink
fix: removed unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
nickytonline committed Oct 21, 2024
1 parent ba2dba5 commit 29ba81e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 149 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { useEffect, useState } from "react";
import Text from "components/atoms/Typography/text";
import Tooltip from "components/atoms/Tooltip/tooltip";
import colors from "../../../lib/utils/color.json";

export interface AllSimpleColors {
Expand All @@ -19,22 +17,15 @@ export interface LanguageObject {

interface CardHorizontalBarChartProps {
languageList: LanguageObject[];
withDescription: boolean;
}

const languageToColor: AllSimpleColors = colors as AllSimpleColors;

const CardHorizontalBarChart = ({ languageList, withDescription }: CardHorizontalBarChartProps): JSX.Element => {
const CardHorizontalBarChart = ({ languageList }: CardHorizontalBarChartProps): JSX.Element => {
const sortedLangArray = languageList.sort((a, b) => b.percentageUsed - a.percentageUsed);
// used this state to calculate thte percentage of each language
const [percentage, setPercentage] = useState<any>(0);

const [descriptText, setDescriptText] = useState(sortedLangArray[0]?.languageName || "javascript");

const handleChangeDescriptText = (descriptText: string) => {
setDescriptText(descriptText);
};

useEffect(() => {
if (sortedLangArray.length === 0) return;

Expand All @@ -54,34 +45,20 @@ const CardHorizontalBarChart = ({ languageList, withDescription }: CardHorizonta
index < 5 && (
<div
key={index}
onMouseOver={() => handleChangeDescriptText(languageName)}
className="h-2 transition-all duration-500 ease-in-out"
style={{
width: `${percentageUsed < 20 ? (percentageUsed / percentage) * 100 : percentageUsed}%`,
backgroundColor: languageToColor[languageName]
? (languageToColor[languageName].color as string)
: NOTSUPPORTED,
}}
/>
>
<span className="sr-only">{`languageName ${percentageUsed}%`}</span>
</div>
)
);
})}
</div>
{withDescription && (
<div className="flex gap-2 w-32 items-baseline">
<div
className={"w-2 h-2 rounded-full"}
style={{
backgroundColor: languageToColor[descriptText]
? (languageToColor[descriptText].color as string)
: NOTSUPPORTED,
}}
/>
<Tooltip className="max-w-[100px]" content={descriptText}>
<Text className="!text-xs !truncate !font-semibold !text-light-slate-11">{descriptText}</Text>
</Tooltip>
</div>
)}
</div>
);
};
Expand Down

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion components/organisms/ContributorCard/contributor-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const ContributorCard = ({
</div>
</div>
<div className="flex flex-col items-end gap-2">
<CardHorizontalBarChart withDescription={false} languageList={languageList} />
<CardHorizontalBarChart languageList={languageList} />
{!!isMaintainer && <Badge text="maintainer" />}
</div>
</div>
Expand Down

0 comments on commit 29ba81e

Please sign in to comment.