From 14ac268165cb72d4147a4b9498e4db6feda15794 Mon Sep 17 00:00:00 2001 From: count0 Date: Wed, 15 Oct 2025 16:39:36 +0200 Subject: [PATCH] add flame anim --- src/components/MiniGrid.jsx | 45 ++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/src/components/MiniGrid.jsx b/src/components/MiniGrid.jsx index 40d80e9..8c6e819 100644 --- a/src/components/MiniGrid.jsx +++ b/src/components/MiniGrid.jsx @@ -20,9 +20,10 @@ import { toggleCompletion } from '../lib/storage'; const MiniGrid = ({ habit, onUpdate }) => { const today = new Date(); - // Show fewer days on mobile for better aspect ratio - const isMobile = window.innerWidth < 640; // Tailwind 'sm' breakpoint - const numDays = isMobile ? 11 : 28; + // Dynamically calculate number of days that fit based on window width and cell size, max 28 + const CELL_SIZE = 42; // px, matches w-8 h-8 + const PADDING = 16; // px, for grid padding/margin + const numDays = Math.min(28, Math.max(5, Math.floor((window.innerWidth - PADDING) / CELL_SIZE))); const days = []; const scrollRef = React.useRef(null); @@ -45,7 +46,7 @@ const MiniGrid = ({ habit, onUpdate }) => { }; return ( -
+
{(() => { const frozenDays = getFrozenDays(habit.completions); return days.map((date, index) => { @@ -78,7 +79,41 @@ const MiniGrid = ({ habit, onUpdate }) => { )} {/* Flame icon for full streak days */} {isCompleted && intensity >= 1 && ( - + {}, + } + }} + whileHover={{ scale: 1.5, rotate: 10 }} + whileTap={{ scale: 1.2, rotate: 0 }} + > + + + + )} {dayLetter}