fix colors (#6)
Browse files- Fix custom colors in heatmaps and consistent empty dot theming (372711a02f76d8d2262947cba80b4161c1fa59ff)
- fix color gradients (dbb3299038de20c360c1b2fc3043e5ef0ce4723d)
- Merge pr/5: Fix custom colors and intensity levels for both daily and weekly heatmaps (2165322700e1ea20105f20c63c31915c201824ee)
- src/components/Heatmap.tsx +12 -3
- src/components/HeatmapGrid.tsx +3 -8
src/components/Heatmap.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import { Tooltip, Avatar } from "@mui/material";
|
|
| 4 |
import Link from "next/link";
|
| 5 |
import { aggregateToWeeklyData } from "../utils/weeklyCalendar";
|
| 6 |
import WeeklyHeatmap from "./WeeklyHeatmap";
|
| 7 |
-
import { getHeatmapTheme } from "../utils/heatmapColors";
|
| 8 |
|
| 9 |
type ViewMode = 'daily' | 'weekly';
|
| 10 |
|
|
@@ -56,6 +56,15 @@ const Heatmap: React.FC<HeatmapProps> = ({
|
|
| 56 |
// Use theme-aware colors
|
| 57 |
const emptyColor = isDarkMode ? "#374151" : "#d1d5db";
|
| 58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
return (
|
| 60 |
<div className="flex flex-col items-center w-full mx-auto">
|
| 61 |
{showHeader && (
|
|
@@ -84,8 +93,8 @@ const Heatmap: React.FC<HeatmapProps> = ({
|
|
| 84 |
<ActivityCalendar
|
| 85 |
data={processedData}
|
| 86 |
theme={{
|
| 87 |
-
light:
|
| 88 |
-
dark:
|
| 89 |
}}
|
| 90 |
blockSize={11}
|
| 91 |
blockMargin={2}
|
|
|
|
| 4 |
import Link from "next/link";
|
| 5 |
import { aggregateToWeeklyData } from "../utils/weeklyCalendar";
|
| 6 |
import WeeklyHeatmap from "./WeeklyHeatmap";
|
| 7 |
+
import { getHeatmapTheme, getHeatmapColorIntensity } from "../utils/heatmapColors";
|
| 8 |
|
| 9 |
type ViewMode = 'daily' | 'weekly';
|
| 10 |
|
|
|
|
| 56 |
// Use theme-aware colors
|
| 57 |
const emptyColor = isDarkMode ? "#374151" : "#d1d5db";
|
| 58 |
|
| 59 |
+
// Create intensity levels for daily view (same as weekly)
|
| 60 |
+
const intensityColors = [
|
| 61 |
+
emptyColor, // level 0
|
| 62 |
+
getHeatmapColorIntensity(1, color), // level 1 (40% intensity)
|
| 63 |
+
getHeatmapColorIntensity(2, color), // level 2 (60% intensity)
|
| 64 |
+
getHeatmapColorIntensity(3, color), // level 3 (80% intensity)
|
| 65 |
+
getHeatmapColorIntensity(4, color) // level 4 (100% intensity)
|
| 66 |
+
].filter((color): color is string => color !== null); // Remove any null values and type guard
|
| 67 |
+
|
| 68 |
return (
|
| 69 |
<div className="flex flex-col items-center w-full mx-auto">
|
| 70 |
{showHeader && (
|
|
|
|
| 93 |
<ActivityCalendar
|
| 94 |
data={processedData}
|
| 95 |
theme={{
|
| 96 |
+
light: intensityColors,
|
| 97 |
+
dark: intensityColors
|
| 98 |
}}
|
| 99 |
blockSize={11}
|
| 100 |
blockMargin={2}
|
src/components/HeatmapGrid.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import React, { useState
|
| 2 |
import { ProviderInfo, CalendarData } from "../types/heatmap";
|
| 3 |
import OrganizationCard from "./OrganizationCard";
|
| 4 |
import ProviderHeatmapSkeleton from "./ProviderHeatmapSkeleton";
|
|
@@ -15,11 +15,6 @@ interface HeatmapGridProps {
|
|
| 15 |
const HeatmapGrid: React.FC<HeatmapGridProps> = ({ sortedProviders, calendarData, isLoading }) => {
|
| 16 |
const [viewMode, setViewMode] = useState<ViewMode>('weekly');
|
| 17 |
|
| 18 |
-
// Memoize the toggle handler to prevent unnecessary re-renders
|
| 19 |
-
const handleViewModeToggle = useCallback((newMode: ViewMode) => {
|
| 20 |
-
setViewMode(newMode);
|
| 21 |
-
}, []);
|
| 22 |
-
|
| 23 |
if (isLoading) {
|
| 24 |
return (
|
| 25 |
<div className="flex flex-col gap-8 max-w-4xl mx-auto mb-16">
|
|
@@ -36,7 +31,7 @@ const HeatmapGrid: React.FC<HeatmapGridProps> = ({ sortedProviders, calendarData
|
|
| 36 |
<div className="flex justify-center">
|
| 37 |
<ViewToggle
|
| 38 |
viewMode={viewMode}
|
| 39 |
-
onToggle={
|
| 40 |
/>
|
| 41 |
</div>
|
| 42 |
|
|
@@ -54,4 +49,4 @@ const HeatmapGrid: React.FC<HeatmapGridProps> = ({ sortedProviders, calendarData
|
|
| 54 |
);
|
| 55 |
};
|
| 56 |
|
| 57 |
-
export default
|
|
|
|
| 1 |
+
import React, { useState } from "react";
|
| 2 |
import { ProviderInfo, CalendarData } from "../types/heatmap";
|
| 3 |
import OrganizationCard from "./OrganizationCard";
|
| 4 |
import ProviderHeatmapSkeleton from "./ProviderHeatmapSkeleton";
|
|
|
|
| 15 |
const HeatmapGrid: React.FC<HeatmapGridProps> = ({ sortedProviders, calendarData, isLoading }) => {
|
| 16 |
const [viewMode, setViewMode] = useState<ViewMode>('weekly');
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
if (isLoading) {
|
| 19 |
return (
|
| 20 |
<div className="flex flex-col gap-8 max-w-4xl mx-auto mb-16">
|
|
|
|
| 31 |
<div className="flex justify-center">
|
| 32 |
<ViewToggle
|
| 33 |
viewMode={viewMode}
|
| 34 |
+
onToggle={setViewMode}
|
| 35 |
/>
|
| 36 |
</div>
|
| 37 |
|
|
|
|
| 49 |
);
|
| 50 |
};
|
| 51 |
|
| 52 |
+
export default HeatmapGrid;
|