-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dear 138 readd insights tests refactor a bit (#55)
* DEAR-138 clean up, add darkmode * DEAR-138 fix darkmode
- Loading branch information
1 parent
9abd88d
commit 8940971
Showing
8 changed files
with
77 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
app/(main)/insights/components/CustomChartComponents/ContributionToolTip.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import * as React from 'react'; | ||
import { Annoyed, Frown, Laugh, Smile } from 'lucide-react'; | ||
import { TooltipProps } from 'recharts'; | ||
|
||
interface CustomToolTipProps extends TooltipProps<number, string> { | ||
payload?: { value: number }[]; | ||
} | ||
|
||
const ContributionToolTip: React.FC<CustomToolTipProps> = ({ active, payload, label }) => { | ||
if (active && payload && payload.length) { | ||
const userAverage = payload[0] ? payload[0].value : 0; | ||
const contributions = payload[1] ? payload[1].value : 0; | ||
|
||
const getIcon = (value: number) => { | ||
if (value >= 17) { | ||
return <Laugh className="h-6 w-6" />; | ||
} | ||
if (value >= 11) { | ||
return <Smile className="h-6 w-6" />; | ||
} | ||
if (value >= 6) { | ||
return <Annoyed className="h-6 w-6" />; | ||
} | ||
if (value >= 2) { | ||
return <Frown className="h-6 w-6" />; | ||
} | ||
return null; | ||
}; | ||
|
||
return ( | ||
<div className="custom-tooltip rounded border bg-white p-2 shadow-lg dark:bg-primaryBG-dark"> | ||
<p className="label font-bold">{`${label}`}</p> | ||
{userAverage > 0 && ( | ||
<div className="tooltip-item mt-2 flex items-center"> | ||
<span className="icon mr-2">{getIcon(userAverage)}</span> | ||
<span className="value">{`Personal (${userAverage})`}</span> | ||
</div> | ||
)} | ||
<div className="tooltip-item mt-2 flex items-center"> | ||
<span className="value">{`Contributions: ${contributions}`}</span> | ||
</div> | ||
</div> | ||
); | ||
} | ||
return null; | ||
}; | ||
|
||
export default ContributionToolTip; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters