From a84abc60b26e05aa50b690174ccf084468faa71f Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com> Date: Thu, 16 Mar 2023 15:53:49 +0530 Subject: [PATCH] style: workspace dashboard (#460) * style: workspace dashboard * feat: activity graph * chore: change tile colors for activity graph * fix: activity graph tiles order, color * style: activity intensity --- .../components/workspace/activity-graph.tsx | 97 +++++++++---------- 1 file changed, 46 insertions(+), 51 deletions(-) diff --git a/apps/app/components/workspace/activity-graph.tsx b/apps/app/components/workspace/activity-graph.tsx index 0d8be2039..39c96890d 100644 --- a/apps/app/components/workspace/activity-graph.tsx +++ b/apps/app/components/workspace/activity-graph.tsx @@ -52,7 +52,7 @@ export const ActivityGraph = () => { const date = new Date(year, month, 1); while (date.getMonth() === month && date < new Date()) { - dates.push(new Date(date)); + dates.push(renderDateFormat(new Date(date))); date.setDate(date.getDate() + 1); } @@ -68,22 +68,20 @@ export const ActivityGraph = () => { ...getDatesOfMonth(recentMonths[5]), ]; - const getDatesOnDay = (dates: Date[], day: number) => { - const datesOnDay = []; - - for (let i = 0; i < dates.length; i++) - if (dates[i].getDay() === day) datesOnDay.push(renderDateFormat(new Date(dates[i]))); - - return datesOnDay; - }; - const activitiesIntensity = (activityCount: number) => { - if (activityCount <= 3) return "opacity-50"; - else if (activityCount > 3 && activityCount <= 6) return "opacity-70"; - else if (activityCount > 6 && activityCount <= 9) return "opacity-90"; + if (activityCount <= 3) return "opacity-20"; + else if (activityCount > 3 && activityCount <= 6) return "opacity-40"; + else if (activityCount > 6 && activityCount <= 9) return "opacity-80"; else return ""; }; + const addPaddingTiles = () => { + const firstDateDay = new Date(recentDates[0]).getDay(); + + for (let i = 0; i < firstDateDay; i++) recentDates.unshift(""); + }; + addPaddingTiles(); + useEffect(() => { if (!ref.current) return; @@ -91,7 +89,7 @@ export const ActivityGraph = () => { }, [ref]); return ( -
+
{DAYS.map((day, index) => ( @@ -100,53 +98,50 @@ export const ActivityGraph = () => { ))}
-
+
- {recentMonths.map((month) => ( -
+ {recentMonths.map((month, index) => ( +
{MONTHS[month.getMonth()].substring(0, 3)}
))}
-
- {DAYS.map((day, index) => ( -
- {getDatesOnDay(recentDates, index).map((date) => { - const isActive = userActivity?.find((a) => a.created_date === date); +
+ {recentDates.map((date) => { + const isActive = userActivity?.find((a) => a.created_date === date); - return ( - -
- - ); - })} -
- ))} + return ( + +
+ + ); + })}
- {/*
- {recentDates.map((date) => ( -
- ))} -
*/}
Less - - - - + + + + More