Shared helpers + frame for the dashboard widgets phoenix_kit_projects
contributes to phoenix_kit_dashboards via phoenix_kit_widgets/0.
Each widget is a Phoenix.LiveComponent the dashboards host renders with
settings / view / size / scope assigns. These helpers centralize the
enablement guard, the lenient project resolver (widgets pick a project by a
free-text "project" setting, since a dashboard widget's settings schema is
static), the shared card frame, and small formatters.
Summary
Functions
True when the projects module is loaded and enabled.
A single-row instance renders dense (tighter frame, smaller title).
Format a datetime as YYYY-MM-DD, or —.
Pick the effective view: honor the selected view if it's one of valid,
else the first valid view. small? lets a widget force its most compact view.
A centered, iconed empty-state body (widgets must never look broken-empty).
A shared widget card frame: header (icon + title + optional link) + body slot.
compact (a single-row instance) tightens the paddings so the minimum box
fits without a scrollbar.
Format estimated hours compactly (e.g. 12h, 1.5h, —).
Resolve the "project" widget setting (a uuid, exact name, external id, or a
name substring) to a %Project{}. Falls back to the first running project (or
any project) when the setting is blank, so a freshly-added widget shows data.
The current user's uuid out of the host-provided scope assign, or nil.
A widget is small (force compact) when narrower than w or shorter than h.
The 'projects module is off' placeholder body.
Functions
@spec available?() :: boolean()
True when the projects module is loaded and enabled.
A single-row instance renders dense (tighter frame, smaller title).
@spec date(DateTime.t() | nil) :: String.t()
Format a datetime as YYYY-MM-DD, or —.
Pick the effective view: honor the selected view if it's one of valid,
else the first valid view. small? lets a widget force its most compact view.
A centered, iconed empty-state body (widgets must never look broken-empty).
Attributes
icon(:string) - Defaults to"hero-clipboard-document-list".message(:string) (required)
A shared widget card frame: header (icon + title + optional link) + body slot.
compact (a single-row instance) tightens the paddings so the minimum box
fits without a scrollbar.
Attributes
title(:string) (required)icon(:string) - Defaults to"hero-clipboard-document-list".href(:string) - Defaults tonil.compact(:boolean) - Defaults tofalse.
Slots
inner_block(required)actions
Format estimated hours compactly (e.g. 12h, 1.5h, —).
@spec resolve_project(term()) :: PhoenixKitProjects.Schemas.Project.t() | nil
Resolve the "project" widget setting (a uuid, exact name, external id, or a
name substring) to a %Project{}. Falls back to the first running project (or
any project) when the setting is blank, so a freshly-added widget shows data.
The current user's uuid out of the host-provided scope assign, or nil.
A widget is small (force compact) when narrower than w or shorter than h.