PhoenixKitDashboards.Layout (PhoenixKitDashboards v0.1.0)

Copy Markdown View Source

Read/write a widget instance's geometry in the embedded item shape:

%{
  "id" => "…", "widget_key" => "…", "settings" => %{}, "view" => "…",
  "pixel" => %{"fx" => .., "fy" => .., "fw" => .., "fh" => ..},   # pixel canvas
  "bp"    => %{"desktop" => %{"w" => .., "h" => .., "hidden" => ..}}  # grid, per breakpoint
}

Pixel dashboards use pixel; grid dashboards use bp[<breakpoint>] (flow order = list position). Keeping geometry embedded per widget means add/remove is atomic — no separate placement map to keep in sync.

Accessors default missing values and fall back to the legacy flat shape ("fx"/"w"/"h"… directly on the item) so pre-refactor local dashboards keep rendering; a put_* write upgrades that widget to the nested shape.

Summary

Functions

Whether the widget is hidden on a breakpoint.

The widget's pixel-canvas geometry (fx/fy/fw/fh), defaulted.

The widget's grid placement (w/h/hidden) for a breakpoint, defaulted.

Set pixel geometry (string-keyed attrs), upgrading the item to nested shape.

Set a breakpoint's grid placement, upgrading the item to nested shape.

Functions

hidden?(item, bp)

@spec hidden?(map(), String.t()) :: boolean()

Whether the widget is hidden on a breakpoint.

pixel(item)

@spec pixel(map()) :: %{optional(String.t()) => term()}

The widget's pixel-canvas geometry (fx/fy/fw/fh), defaulted.

placement(item, bp)

@spec placement(map(), String.t()) :: %{optional(String.t()) => term()}

The widget's grid placement (w/h/hidden) for a breakpoint, defaulted.

put_pixel(item, attrs)

@spec put_pixel(map(), map()) :: map()

Set pixel geometry (string-keyed attrs), upgrading the item to nested shape.

put_placement(item, bp, attrs)

@spec put_placement(map(), String.t(), map()) :: map()

Set a breakpoint's grid placement, upgrading the item to nested shape.