惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
A
About on SuperTechFans
小众软件
小众软件
Hugging Face - Blog
Hugging Face - Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 叶小钗
博客园 - 聂微东
博客园 - Franky
Apple Machine Learning Research
Apple Machine Learning Research
罗磊的独立博客
量子位
博客园 - 三生石上(FineUI控件)
Recent Announcements
Recent Announcements
The GitHub Blog
The GitHub Blog
B
Blog RSS Feed
T
The Blog of Author Tim Ferriss
GbyAI
GbyAI
云风的 BLOG
云风的 BLOG
Last Week in AI
Last Week in AI
宝玉的分享
宝玉的分享
B
Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Stack Overflow Blog
Stack Overflow Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
A Notion-Style Calendar Is Just One CSS Grid
Devanshu Biswas · 2026-06-14 · via DEV Community

Devanshu Biswas

Notion's calendar looks like a polished, complicated component. Build one and you'll find it's a 7-column CSS grid plus about three lines of date arithmetic. No date library, no calendar package.

This is Day 5 of my DesignFromZero series — recreate a slick UI from scratch and learn why it works.

Seven columns. That's the layout.

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

Drop your day cells in and the browser wraps them into weeks automatically. You never position a single cell by hand.

Where does the month start?

The 1st isn't always a Sunday. Ask JavaScript which weekday it is:

const startDay = new Date(year, month, 1).getDay(); // 0=Sun … 6=Sat

That number is exactly how many blank cells you prepend so dates line up under the right weekday header.

How many days this month?

The classic JS trick — day 0 of next month rolls back to the last day of this month:

const daysInMonth = new Date(year, month + 1, 0).getDate(); // 28/29/30/31

Leap years handled for free.

Pad both ends so rows never look ragged

This is the detail that makes it read as "Notion" and not a school worksheet:

// leading: the previous month's last few days, dimmed grey
for (let i = startDay - 1; i >= 0; i--) addCell(prevMonthDays - i, /* dim */ true);

// this month
for (let d = 1; d <= daysInMonth; d++) addCell(d, false, new Date(year, month, d));

// trailing: next month's first days, so the final row is full
const trailing = (7 - (startDay + daysInMonth) % 7) % 7;

Those grey overflow days are 90% of the "this looks professional" effect.

Today + events

Highlight today by comparing each cell's ISO date string to new Date(). Events live in a plain object keyed by date — render whatever sits under that key as colored chips:

const events = { "2026-06-21": [{ t: "Ship v2 🚀" }] };

const key = iso(date); // "2026-06-21"
(events[key] || []).forEach(e => {
  const chip = document.createElement("div");
  chip.textContent = e.t;
  cell.appendChild(chip);
});

That's Notion's "database on a calendar" in miniature.

Month navigation

prevBtn.onclick = () => { view.setMonth(view.getMonth() - 1); render(); };

Re-render and you're done. The built-in Date object does all the arithmetic — no moment, no date-fns for a clean month view.

🗓️ See it live + click any day to add an event: https://dev48v.infy.uk/design/day5-notion-calendar.html

Day 5 of DesignFromZero. A new UI clone every day, built from scratch.