PhoenixLiveCalendar.Widgets (PhoenixLiveCalendar v0.3.0)

Copy Markdown View Source

The most compressed genuinely-useful form of each calendar surface — for dashboard cells, sidebars, and anywhere a full view has no room (~200×150px and up).

Below panel size the ENCODING has to change, not just the type scale, so these are dedicated components rather than shrunken grids:

  • next_events/1 — the viewer's next N events as a compact list. The single highest-value calendar widget.
  • week_strip/1 — seven day cells with event dots/counts; replaces an illegible miniature time grid.
  • activity_grid/1 — the GitHub-style contributions strip (weeks × weekdays) over Heatmap data.
  • activity_month/1 — the same square encoding for ONE month, in calendar orientation (weekday columns, week rows).
  • mini_timeline/1 — a preset-compressed Timeline (fitted window, no labels, tiny slots) for a peek at today's sessions.

For a compact MONTH, use PhoenixLiveCalendar.Components.MiniCalendar (optionally with heatmap markers_by_date) — it already is the widget form.

Summary

Functions

A GitHub-contributions strip: weeks columns × 7 weekday rows of tiny intensity squares over Heatmap data (Date => number).

One month of activity squares in calendar orientation — the activity_grid/1 encoding at month scale: weekday columns, one row per week, out-of-month days blank, today ringed.

A preset-compressed Timeline: fitted window, no time axis, no bar labels (tooltips remain), tiny slots, at most max_rows resources.

The next limit events, soonest first, as a compact list.

Seven day cells — narrow day letter, day number, up to three event dots; busier days collapse to a +N TOTAL count. The week-at-a-glance replacement for a time grid that would be illegible at widget size.

Functions

activity_grid(assigns)

A GitHub-contributions strip: weeks columns × 7 weekday rows of tiny intensity squares over Heatmap data (Date => number).

  • data — the per-day numbers; palette/scale/max behave as in PhoenixLiveCalendar.Heatmap.markers/2
  • to — last day shown (default: today); the strip covers the weeks * 7 days ending there, aligned to week_start
  • Each active square carries a title tooltip with the date and value.

Attributes

  • data (:any) (required)
  • to (Date) - Defaults to nil.
  • weeks (:integer) - Defaults to 26.
  • week_start (:integer) - Defaults to 1.
  • palette (:any) - Defaults to :success.
  • scale (:atom) - Defaults to :linear.
  • max (:any) - Defaults to nil.
  • cell_class (:string) - Defaults to "w-1.5 h-1.5 rounded-[2px]".
  • translations (:map) - Defaults to %{}.
  • class (:string) - Defaults to "".

activity_month(assigns)

One month of activity squares in calendar orientation — the activity_grid/1 encoding at month scale: weekday columns, one row per week, out-of-month days blank, today ringed.

  • data — per-day numbers; palette/scale/max as in PhoenixLiveCalendar.Heatmap.markers/2
  • date — any date inside the month (default: today)
  • show_day_initials — narrow weekday initials above the columns (default true)

Attributes

  • data (:any) (required)
  • date (Date) - Defaults to nil.
  • today (:any) - Date | nil (server today) | :none (no today highlight). Defaults to nil.

  • week_start (:integer) - Defaults to 1.
  • palette (:any) - Defaults to :success.
  • scale (:atom) - Defaults to :linear.
  • max (:any) - Defaults to nil.
  • cell_class (:string) - Defaults to "w-3 h-3 rounded-[3px]".
  • show_day_initials (:boolean) - Defaults to true.
  • translations (:map) - Defaults to %{}.
  • class (:string) - Defaults to "".

mini_timeline(assigns)

A preset-compressed Timeline: fitted window, no time axis, no bar labels (tooltips remain), tiny slots, at most max_rows resources.

Attributes

  • id (:string) - Defaults to "mini-timeline".
  • date (Date) (required)
  • resources (:list) (required)
  • events (:list) - Defaults to [].
  • max_rows (:integer) - Defaults to 3.
  • resource_width (:string) - Defaults to "6rem".
  • today (:any) - Date | nil (server today) | :none (no today highlight). Defaults to nil.

  • now (Time) - Defaults to nil.
  • on_event_click (:any) - Defaults to nil.
  • class (:string) - Defaults to "".

next_events(assigns)

The next limit events, soonest first, as a compact list.

  • events — the pool to pick from (pass whatever you have; ended events are dropped: timed ones by comparing effective_end to now, all-day ones once their last date is past)
  • now — the reference instant (default DateTime.utc_now()); pass the viewer's local time for timezone-correct "Today" grouping
  • within_days — horizon (default 14)
  • Each row: color dot (the event's resolved color), truncated title, and a short when-label — the time for today's events, the weekday within a week, the date beyond that.

Attributes

  • events (:list) (required)
  • now (DateTime) - Defaults to nil.
  • limit (:integer) - Defaults to 3.
  • within_days (:integer) - Defaults to 14.
  • on_event_click (:any) - Defaults to nil.
  • time_format (:atom) - Defaults to :h24.
  • translations (:map) - Defaults to %{}.
  • class (:string) - Defaults to "".

week_strip(assigns)

Seven day cells — narrow day letter, day number, up to three event dots; busier days collapse to a +N TOTAL count. The week-at-a-glance replacement for a time grid that would be illegible at widget size.

Attributes

  • date (Date) - any date inside the week (default: today). Defaults to nil.
  • events (:list) - Defaults to [].
  • today (:any) - Date | nil (server today) | :none (no today highlight). Defaults to nil.

  • week_start (:integer) - Defaults to 1.
  • on_date_click (:any) - Defaults to nil.
  • translations (:map) - Defaults to %{}.
  • class (:string) - Defaults to "".