LedgerUI.Components.PixelCard (LedgerUI v0.2.0)

Copy Markdown View Source

The pixel card: a card to choose from (a model, a module, an integration) that, on hover or keyboard focus, lights up a matrix of pixels in its top right corner, in the card's colour.

<.pixel_card navigate={~p"/novo/loja"} color="red" icon="huge-shopping-cart-01"
  title="Loja" description="PDV, estoque, NFC-e" />
<.pixel_card phx-click="pick" phx-value-id="agenda" color="ink" icon="huge-calendar-03"
  title="Agenda" description="Horários e lembretes" />

With href, navigate or patch the card is a link; with none it is a <button type="button"> that takes phx-click and the other events through rest. The keyboard focus does what the hover does: the pixels, the stronger outline and the arrow (arrow={false} leaves the arrow out).

color takes a palette name (red, rose, green, teal, blue, violet, amber, ink); without it the card takes the accent. Any other colour goes through the --px custom property (style="--px: #f97316").

The pixel matrix is drawn by the LedgerUI.PixelCard hook (three random patterns that swap every 0.3s, from lu-px in the stylesheet). The hook needs a DOM id: pass id, or it is derived from the title.

Summary

Functions

pixel_card(assigns)

Attributes

  • id (:string) - The hook's DOM id; derived from the title when omitted. Defaults to nil.
  • title (:string) (required) - The bold name of the option.
  • description (:string) - The muted line under the name. Defaults to nil.
  • icon (:string) - An icon, drawn white in a round chip of the colour. Defaults to nil.
  • color (:string) - Defaults to nil.Must be one of nil, "red", "rose", "green", "teal", "blue", "violet", "amber", or "ink".
  • arrow (:boolean) - Defaults to true.
  • class (:any) - Defaults to nil.
  • Global attributes are accepted. Supports all globals plus: ["href", "navigate", "patch", "method", "disabled"].

Slots

  • inner_block - Extra content under the description.