Date Divider

View as Markdown

The line that splits a feed by day, such as Today or Yesterday, and a helper that groups items by day.

  • Lena Fischer10:02

    Happy new year in advance, everyone.

  • Wei Chen09:15

    Q4 targets are in the planning doc.

  • Priya Raman14:40

    Northwind signed the renewal.

  • Tomás García15:05

    Nice. I'll send the onboarding plan.

  • Ada Okafor08:50

    Exports are failing for a few customers; looking now.

  • Ada Okafor09:12

    Fixed: a timeout on the ledger API. Exports are back.

  • Priya Raman09:20

    Thank you! Telling the customers now.

When to use

The line that splits a feed by day, such as Today or Yesterday, and a helper that groups items by day. Use Group Header instead when rows are grouped by something other than the day.

Usage

import { DateDivider, groupByDay } from "./ui/uicontext/components/DateDivider.ts"
export const Feed = <M>(h: Html.H<M>, messages: ReadonlyArray<{ readonly id: string; readonly sentAt: string; readonly text: string }>, now: string) =>	groupByDay(messages, (m) => m.sentAt, { now }).map(({ label, items }) => [DateDivider(h, { label }), ...items.map((m) => h.p.key(m.id).children(m.text))])

Examples

Activity, in the reader's time zone

align: "start" puts the day at the line's start. timeZone decides which day an instant falls on.

  • Ada Okafor closed the issue10:10 AM
  • Deploy 3f9a2c reached production8:00 PM
  • Tomás García linked a pull request9:30 AM
  • Priya Raman set priority to High11:00 AM
  • Wei Chen opened the issue8:20 AM

API reference

DateDividerView function

Options

DateDivider options
NameTypeDescription
labelrequiredstringThe day: from dayLabel, or any words.
align"center" | "start"The label at the start of the line rather than in the middle.
stickybooleanSticks to the top of its scrolling feed, on a pill, while the day's items pass under it.
styleStyle—

DayView function

Options

Day options
NameTypeDescription
nowrequiredstringThe instant it is now, ISO: days are counted back from its day.
timeZonestringThe reader's IANA time zone, such as "Europe/London": it decides which day an instant falls on.
localestringWrites weekdays and dates in this language.

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/date-divider

Source