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 ( -