<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Asef Ratul</title>
    <description>The latest articles on DEV Community by Asef Ratul (@asef_ratul_39de51d6fc05e6).</description>
    <link>https://dev.to/asef_ratul_39de51d6fc05e6</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3990616%2F1c9c2d91-0ea7-449d-8f74-4f99478054e8.png</url>
      <title>DEV Community: Asef Ratul</title>
      <link>https://dev.to/asef_ratul_39de51d6fc05e6</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/asef_ratul_39de51d6fc05e6"/>
    <language>en</language>
    <item>
      <title>Building a timezone-safe 52-week planning grid in React</title>
      <dc:creator>Asef Ratul</dc:creator>
      <pubDate>Thu, 18 Jun 2026 13:30:00 +0000</pubDate>
      <link>https://dev.to/asef_ratul_39de51d6fc05e6/building-a-timezone-safe-52-week-planning-grid-in-react-1438</link>
      <guid>https://dev.to/asef_ratul_39de51d6fc05e6/building-a-timezone-safe-52-week-planning-grid-in-react-1438</guid>
      <description>&lt;p&gt;A while ago I had to build a year-at-a-glance planning board: 52 weeks across the&lt;br&gt;
top, grouped program rows down the side, each cell showing whether something is&lt;br&gt;
scheduled that week. The kind of grid a field-service team, an agronomist, or a&lt;br&gt;
maintenance crew plans a whole year on.&lt;/p&gt;

&lt;p&gt;It looks like a table. It is not a table. It ate the better part of three weeks,&lt;br&gt;
and almost none of that time went where I expected. Here are the parts that are&lt;br&gt;
genuinely hard, with the approaches that finally worked — useful whether you're&lt;br&gt;
building one yourself or just curious why "just a grid" is a trap.&lt;/p&gt;
&lt;h2&gt;
  
  
  1. There is no such thing as "52 weeks"
&lt;/h2&gt;

&lt;p&gt;The first instinct is to render 52 columns. But a planning year is organised by&lt;br&gt;
&lt;em&gt;month&lt;/em&gt;, and months don't divide into weeks cleanly. You immediately hit two&lt;br&gt;
different, equally valid models:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;ISO-8601 weeks&lt;/strong&gt; — real weeks, Monday-start, where a week belongs to the
month that holds its Thursday. Accurate, but months get 4 or 5 weeks
unevenly, and it shifts year to year.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A simple 4-4-5 pattern&lt;/strong&gt; — the accounting-style calendar where each quarter
is 4 + 4 + 5 weeks (52 total), identical every year. Predictable, but not
"real" dates.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Different users want different ones, so the week count per month has to be a&lt;br&gt;
&lt;em&gt;strategy&lt;/em&gt;, not a constant:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;WeekStrategy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;iso&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;simple&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;weeksInMonth&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;monthIndex&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;cfg&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;PlannerConfig&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;cfg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;weekStrategy&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;simple&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;pattern&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;cfg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;simplePattern&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;pattern&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;monthIndex&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="nx"&gt;pattern&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;isoWeeksInMonth&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;cfg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;year&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;monthIndex&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// 4 or 5, computed from dates&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The moment "52" stops being hard-coded, the rest of the grid has to stop&lt;br&gt;
assuming it too — column widths, headers, and cell lookups all derive from this.&lt;/p&gt;
&lt;h2&gt;
  
  
  2. The year doesn't start in January
&lt;/h2&gt;

&lt;p&gt;Plenty of planning years don't start in January. A Southern-Hemisphere turf&lt;br&gt;
program starts in July. A retailer's fiscal year might start in February. So the&lt;br&gt;
column order can't be a fixed &lt;code&gt;['Jan', 'Feb', ...]&lt;/code&gt; array — it has to rotate from&lt;br&gt;
a configurable start month:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;PlannerConfig&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;year&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;
  &lt;span class="nx"&gt;startMonth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;        &lt;span class="c1"&gt;// 1–12&lt;/span&gt;
  &lt;span class="nx"&gt;weekStrategy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;WeekStrategy&lt;/span&gt;
  &lt;span class="nx"&gt;simplePattern&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt;
  &lt;span class="nx"&gt;locale&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;buildColumns&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;cfg&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;PlannerConfig&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;cols&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
  &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;monthOffset&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;cfg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;startMonth&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;month&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;monthOffset&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;year&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;cfg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;year&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;monthOffset&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// rolls into next year&lt;/span&gt;
    &lt;span class="nx"&gt;cols&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;month&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;year&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;weeks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;weeksInMonth&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;cfg&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;cols&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the month &lt;em&gt;labels&lt;/em&gt; should never be a hand-typed array either — that's a&lt;br&gt;
localisation bug waiting to happen. Let the platform do it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;label&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Intl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;DateTimeFormat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;cfg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;locale&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;en&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;month&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;short&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;year&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;month&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now "July-start, en-AU" and "February-start, de-DE" both just work, and you&lt;br&gt;
haven't written a single month name.&lt;/p&gt;
&lt;h2&gt;
  
  
  3. Never read the clock inside your logic
&lt;/h2&gt;

&lt;p&gt;Here's the bug that will bite you in production but never in development:&lt;br&gt;
highlighting the current week.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// ❌ reads the clock deep inside a pure-looking function&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;isCurrentWeek&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;week&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Week&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;week&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;start&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;week&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;end&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This breaks two ways. On the server (SSR / React Server Components) it computes a&lt;br&gt;
different "now" than the client, and you get a hydration mismatch. And it makes&lt;br&gt;
the function impossible to test deterministically — you can't unit-test "what&lt;br&gt;
does week 12 look like on this date" if the function secretly asks the OS.&lt;/p&gt;

&lt;p&gt;The fix is boring and powerful: &lt;strong&gt;inject "today" as a parameter.&lt;/strong&gt; Your entire&lt;br&gt;
date/week engine becomes pure — same inputs, same output, forever.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// ✅ deterministic and SSR-safe&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;isCurrentWeek&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;week&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Week&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;today&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;week&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;start&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nx"&gt;today&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;today&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;week&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;end&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Push the single &lt;code&gt;new Date()&lt;/code&gt; to the very edge of the app (one prop at the top),&lt;br&gt;
and everything below it is testable and timezone-safe.&lt;/p&gt;
&lt;h2&gt;
  
  
  4. Season bands wrap around the year boundary
&lt;/h2&gt;

&lt;p&gt;If you colour the header by season, you hit a subtle one. In a July-start year,&lt;br&gt;
"Winter" might be June–August. But June is the &lt;em&gt;last&lt;/em&gt; column and July–August are&lt;br&gt;
the &lt;em&gt;first&lt;/em&gt; two. So a single season band has to render as &lt;strong&gt;two segments&lt;/strong&gt; — one&lt;br&gt;
at each end of the grid — without you special-casing it.&lt;/p&gt;

&lt;p&gt;The trick is to define a band by the set of months it covers, then let the&lt;br&gt;
column builder place segments wherever those months landed after rotation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;SeasonBand&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;label&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;months&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;[];&lt;/span&gt; &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// After buildColumns(), group *contiguous runs* of columns whose month is in the&lt;/span&gt;
&lt;span class="c1"&gt;// band. A band split by the fiscal boundary naturally yields two runs.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Define seasons as data, derive the visual segments from the rotated columns, and&lt;br&gt;
the wrap-around handles itself. Hard-code the spans and you'll be patching edge&lt;br&gt;
cases forever.&lt;/p&gt;
&lt;h2&gt;
  
  
  5. Sticky headers, and not re-rendering 4,000 cells
&lt;/h2&gt;

&lt;p&gt;Two performance/UX notes that cost real time:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Sticky in two axes at once.&lt;/strong&gt; Row labels stick left, the season/month/week
header sticks top, and they have to cooperate while scrolling. Getting
&lt;code&gt;position: sticky&lt;/code&gt; to behave in both directions across Chrome, Safari, and
Firefox is fiddlier than it sounds — test all three early.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Don't re-render the whole grid on one cell change.&lt;/strong&gt; A 60-row × 64-week
board is ~4,000 cells. If toggling one cell re-renders all of them, dragging
feels awful. Memoise at the row level and key cells stably so a single edit
touches a single row.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  6. Print is a feature, not an afterthought
&lt;/h2&gt;

&lt;p&gt;The thing users actually asked for, that I budgeted zero time for: a printable&lt;br&gt;
&lt;strong&gt;wall chart&lt;/strong&gt;. A superintendent wants to pin the whole year to the shed wall.&lt;/p&gt;

&lt;p&gt;Print is its own layout problem. You want an &lt;code&gt;@page&lt;/code&gt; setup for A3/A4 in portrait&lt;br&gt;
&lt;em&gt;and&lt;/em&gt; landscape, column density tuned so a full year fits the page width, and&lt;br&gt;
section rows that &lt;strong&gt;never split across a page break&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="n"&gt;print&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;@page&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;A3&lt;/span&gt; &lt;span class="nb"&gt;landscape&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nc"&gt;.section-group&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;break-inside&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;avoid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nc"&gt;.app-chrome&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;   &lt;span class="c"&gt;/* hide nav/buttons; print only the board */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It demos beautifully and it's the part people remember — but it's a day of work&lt;br&gt;
on its own, separate from the on-screen grid.&lt;/p&gt;

&lt;h2&gt;
  
  
  The principle underneath all of it
&lt;/h2&gt;

&lt;p&gt;The thing that made the whole build sane: &lt;strong&gt;separate the logic from the&lt;br&gt;
presentation.&lt;/strong&gt; All the week math, column rotation, season banding, and status&lt;br&gt;
logic live in pure functions with no JSX, no DOM, and no clock reads. The React&lt;br&gt;
components are a thin rendering layer on top. That split is what makes the engine&lt;br&gt;
testable (I got the core to ~99% coverage), SSR-safe, and reusable across totally&lt;br&gt;
different domains — the same grid renders a turf program, a pest-control route&lt;br&gt;
schedule, or a maintenance plan, just from different data.&lt;/p&gt;

&lt;p&gt;If you're building one of these, budget for the six things above — they're where&lt;br&gt;
the time actually goes.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;I packaged this grid engine as a commercial Next.js template called&lt;br&gt;
&lt;strong&gt;SeasonBoard&lt;/strong&gt; — config-driven, type-safe, with the print layout and headless core described here.&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🔗 &lt;strong&gt;Live demo&lt;/strong&gt; (click around, switch datasets, hit Print): &lt;a href="https://seasonboard.vercel.app/" rel="noopener noreferrer"&gt;https://seasonboard.vercel.app/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;📦 &lt;strong&gt;Get it on Gumroad&lt;/strong&gt; (Solo &amp;amp; Team licences): &lt;a href="https://5376434736463.gumroad.com/l/djdfba/osvog2b" rel="noopener noreferrer"&gt;https://5376434736463.gumroad.com/l/djdfba/osvog2b&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;If you'd rather not spend the three weeks, it'll save you most of them. Either&lt;br&gt;
way, I hope the breakdown above saves you some pain.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>react</category>
      <category>typescript</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
