another smol color bug
#8
by
evijit
HF Staff
- opened
- src/components/Heatmap.tsx +16 -17
src/components/Heatmap.tsx
CHANGED
|
@@ -56,22 +56,20 @@ const Heatmap: React.FC<HeatmapProps> = ({
|
|
| 56 |
// Use theme-aware colors
|
| 57 |
const emptyColor = isDarkMode ? "#374151" : "#d1d5db";
|
| 58 |
|
| 59 |
-
// Create
|
| 60 |
-
const
|
| 61 |
-
emptyColor
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
-
const
|
| 69 |
-
emptyColor, // level 0
|
| 70 |
-
getHeatmapColorIntensity(1, color, true), // level 1 (darker for dark mode)
|
| 71 |
-
getHeatmapColorIntensity(2, color, true), // level 2
|
| 72 |
-
getHeatmapColorIntensity(3, color, true), // level 3
|
| 73 |
-
getHeatmapColorIntensity(4, color, true) // level 4 (brightest for dark mode)
|
| 74 |
-
].filter((color): color is string => color !== null);
|
| 75 |
|
| 76 |
return (
|
| 77 |
<div className="flex flex-col items-center w-full mx-auto">
|
|
@@ -99,10 +97,11 @@ const Heatmap: React.FC<HeatmapProps> = ({
|
|
| 99 |
<WeeklyHeatmap data={processedData} color={color} />
|
| 100 |
) : (
|
| 101 |
<ActivityCalendar
|
|
|
|
| 102 |
data={processedData}
|
| 103 |
theme={{
|
| 104 |
-
light:
|
| 105 |
-
dark:
|
| 106 |
}}
|
| 107 |
blockSize={11}
|
| 108 |
blockMargin={2}
|
|
|
|
| 56 |
// Use theme-aware colors
|
| 57 |
const emptyColor = isDarkMode ? "#374151" : "#d1d5db";
|
| 58 |
|
| 59 |
+
// Create the correct color progression based on current theme
|
| 60 |
+
const getThemeAwareColors = () => {
|
| 61 |
+
const colors = [emptyColor]; // level 0
|
| 62 |
+
|
| 63 |
+
for (let level = 1; level <= 4; level++) {
|
| 64 |
+
const intensity = getHeatmapColorIntensity(level, color, isDarkMode);
|
| 65 |
+
if (intensity) {
|
| 66 |
+
colors.push(intensity);
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
return colors;
|
| 70 |
+
};
|
| 71 |
|
| 72 |
+
const themeColors = getThemeAwareColors();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
return (
|
| 75 |
<div className="flex flex-col items-center w-full mx-auto">
|
|
|
|
| 97 |
<WeeklyHeatmap data={processedData} color={color} />
|
| 98 |
) : (
|
| 99 |
<ActivityCalendar
|
| 100 |
+
key={`${isDarkMode}-${color}`} // Force re-render on theme change
|
| 101 |
data={processedData}
|
| 102 |
theme={{
|
| 103 |
+
light: themeColors,
|
| 104 |
+
dark: themeColors
|
| 105 |
}}
|
| 106 |
blockSize={11}
|
| 107 |
blockMargin={2}
|