|
|
@ -9,6 +9,15 @@ import dayjs from 'dayjs'; |
|
|
|
type UserActivityHeatmapProps = { |
|
|
|
type UserActivityHeatmapProps = { |
|
|
|
activity: UserActivityCount; |
|
|
|
activity: UserActivityCount; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const legends = [ |
|
|
|
|
|
|
|
{ count: '1-2', color: 'bg-gray-200' }, |
|
|
|
|
|
|
|
{ count: '3-4', color: 'bg-gray-300' }, |
|
|
|
|
|
|
|
{ count: '5-9', color: 'bg-gray-500' }, |
|
|
|
|
|
|
|
{ count: '10-19', color: 'bg-gray-600' }, |
|
|
|
|
|
|
|
{ count: '20+', color: 'bg-gray-800' }, |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
export function UserActivityHeatmap(props: UserActivityHeatmapProps) { |
|
|
|
export function UserActivityHeatmap(props: UserActivityHeatmapProps) { |
|
|
|
const { activity } = props; |
|
|
|
const { activity } = props; |
|
|
|
const data = Object.entries(activity.activityCount).map(([date, count]) => ({ |
|
|
|
const data = Object.entries(activity.activityCount).map(([date, count]) => ({ |
|
|
@ -20,7 +29,16 @@ export function UserActivityHeatmap(props: UserActivityHeatmapProps) { |
|
|
|
const endDate = dayjs().toDate(); |
|
|
|
const endDate = dayjs().toDate(); |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<> |
|
|
|
<div className="rounded-lg border bg-white p-4"> |
|
|
|
|
|
|
|
<div className="-mx-4 mb-8 flex justify-between border-b px-4 pb-3"> |
|
|
|
|
|
|
|
<div className=""> |
|
|
|
|
|
|
|
<h2 className="mb-0.5 font-semibold">Activity</h2> |
|
|
|
|
|
|
|
<p className="text-sm text-gray-500"> |
|
|
|
|
|
|
|
Progress updates over the past year |
|
|
|
|
|
|
|
</p> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
<span className="text-sm text-gray-400">Member since: June 2021</span> |
|
|
|
|
|
|
|
</div> |
|
|
|
<CalendarHeatmap |
|
|
|
<CalendarHeatmap |
|
|
|
startDate={startDate} |
|
|
|
startDate={startDate} |
|
|
|
endDate={endDate} |
|
|
|
endDate={endDate} |
|
|
@ -51,7 +69,7 @@ export function UserActivityHeatmap(props: UserActivityHeatmapProps) { |
|
|
|
const formattedDate = formatActivityDate(value.date); |
|
|
|
const formattedDate = formatActivityDate(value.date); |
|
|
|
return { |
|
|
|
return { |
|
|
|
'data-tooltip-id': 'user-activity-tip', |
|
|
|
'data-tooltip-id': 'user-activity-tip', |
|
|
|
'data-tooltip-content': `${value.count} Progress Update on ${formattedDate}`, |
|
|
|
'data-tooltip-content': `${value.count} Updates - ${formattedDate}`, |
|
|
|
}; |
|
|
|
}; |
|
|
|
}} |
|
|
|
}} |
|
|
|
/> |
|
|
|
/> |
|
|
@ -60,6 +78,30 @@ export function UserActivityHeatmap(props: UserActivityHeatmapProps) { |
|
|
|
id="user-activity-tip" |
|
|
|
id="user-activity-tip" |
|
|
|
className="!rounded-lg !bg-gray-900 !p-1 !px-2 !text-sm" |
|
|
|
className="!rounded-lg !bg-gray-900 !p-1 !px-2 !text-sm" |
|
|
|
/> |
|
|
|
/> |
|
|
|
</> |
|
|
|
|
|
|
|
|
|
|
|
<div className="mt-4 flex items-center justify-between"> |
|
|
|
|
|
|
|
<span className="text-sm text-gray-400"> |
|
|
|
|
|
|
|
Number of topics marked as learning, or completed by day |
|
|
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
<div className="flex items-center"> |
|
|
|
|
|
|
|
<span className="mr-2 text-xs text-gray-500">Less</span> |
|
|
|
|
|
|
|
{legends.map((legend) => ( |
|
|
|
|
|
|
|
<div |
|
|
|
|
|
|
|
key={legend.count} |
|
|
|
|
|
|
|
className="flex items-center" |
|
|
|
|
|
|
|
data-tooltip-id="user-activity-tip" |
|
|
|
|
|
|
|
data-tooltip-content={`${legend.count} Updates`} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<div className={`h-3 w-3 ${legend.color} mr-1 rounded-sm`}></div> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
))} |
|
|
|
|
|
|
|
<span className="ml-2 text-xs text-gray-500">More</span> |
|
|
|
|
|
|
|
<ReactTooltip |
|
|
|
|
|
|
|
id="user-activity-tip" |
|
|
|
|
|
|
|
className="!rounded-lg !bg-gray-900 !p-1 !px-2 !text-sm" |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
</div> |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|