defmodule MoonWeb.Examples.Design.TableExample.WithFooter do @moduledoc false use Moon.StatelessComponent use MoonWeb, :example alias Moon.Design.Table alias Moon.Design.Table.Column alias Moon.Design.Table.FooterColumn alias Moon.Components.Renderers.Datetime prop(models, :list, default: Enum.map(1..5, fn x -> %{ id: x, name: "Name #{x}", created_at: DateTime.utc_now(), counter: x } end) ) prop(footer_items, :list, default: [%{name: "Total", counter_total: 15}]) def render(assigns) do ~F"""
{model.id} {model.name} {model.counter} {footer_item.name} {footer_item.counter_total}
""" end def code() do """ alias Moon.Design.Table alias Moon.Design.Table.Column alias Moon.Components.Renderers.Datetime data(models, :list, default: Enum.map(1..5, fn x -> %{ id: x, name: "Name \#{x}", created_at: DateTime.utc_now(), counter: x } end) ) def render(assigns) do ~F\""" {model.id} {model.name} {model.counter} {footer_item.name} {footer_item.counter_total}
\""" end """ end end