From a93223b9df06e4dacff4b57059faf4eb33e48b8b Mon Sep 17 00:00:00 2001 From: Daniil Demidovich Date: Wed, 18 Sep 2024 14:41:14 +0200 Subject: [PATCH] Fix heat map cell size --- .../src/screens/Player/Calendar/HeatMap.tsx | 23 ++++++++++++++----- .../web/src/screens/Player/Calendar/index.tsx | 8 +++---- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/apps/web/src/screens/Player/Calendar/HeatMap.tsx b/apps/web/src/screens/Player/Calendar/HeatMap.tsx index aeff30d..0039999 100644 --- a/apps/web/src/screens/Player/Calendar/HeatMap.tsx +++ b/apps/web/src/screens/Player/Calendar/HeatMap.tsx @@ -11,10 +11,11 @@ export type DayData = { winrate: number } -export const cellSize = 20 -export const cellGap = 2 +const cellSize = 20 +const cellSizeCss = 'size-[20px]' +const cellGap = 2 export const monthGap = 8 -export const cellPlusGap = cellSize + cellGap +export const cellAndGap = cellSize + cellGap export const HeatMap = ({ monthesWithDays, @@ -26,7 +27,12 @@ export const HeatMap = ({ invisible?: boolean }) => { return ( -
+
{monthesWithDays.map((month, monthIndex) => { const firstDay = month[0] @@ -48,7 +54,12 @@ export const HeatMap = ({ {firstDay.date.format('MMM')}
-
+
{month.map((day, dayIndex) => { let daysToPad = 0 @@ -77,7 +88,7 @@ export const HeatMap = ({ } >
diff --git a/apps/web/src/screens/Player/Calendar/index.tsx b/apps/web/src/screens/Player/Calendar/index.tsx index 682253a..5d80070 100644 --- a/apps/web/src/screens/Player/Calendar/index.tsx +++ b/apps/web/src/screens/Player/Calendar/index.tsx @@ -8,7 +8,7 @@ import { Tooltip } from '~/components/ui/Tooltip' import { useElementWidth } from '~/hooks/useElementWidth' import { usePlayerPageContext } from '~/screens/Player/context' import { date, formatNumber, pluralize } from '~/utils' -import { cellPlusGap, DayData, HeatMap, monthGap } from './HeatMap' +import { cellAndGap, DayData, HeatMap, monthGap } from './HeatMap' import { HistoryDialog } from './HistoryDialog' export const Calendar = () => { @@ -16,7 +16,7 @@ export const Calendar = () => { const [ref, wrapperWidth] = useElementWidth() const days = useMemo(() => { - let widthLeft = wrapperWidth - cellPlusGap + let widthLeft = wrapperWidth - cellAndGap const result: dayjs.Dayjs[] = [] let current = date().startOf('day') @@ -27,9 +27,9 @@ export const Calendar = () => { const next = current.subtract(1, 'day') if (next.month() !== current.month()) { - widthLeft -= cellPlusGap + monthGap + widthLeft -= cellAndGap + monthGap } else if (next.week() !== current.week()) { - widthLeft -= cellPlusGap + widthLeft -= cellAndGap } current = next