From 6356fad7ff192f852084a490278fe724ef61b739 Mon Sep 17 00:00:00 2001 From: phgrey Date: Wed, 13 Dec 2023 10:28:52 +0100 Subject: [PATCH] chore: one more table exampe --- lib/moon/design/dropdown/option_with_icon.ex | 2 +- .../examples/light/table_example/editable.exs | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 lib/moon_web/examples/light/table_example/editable.exs diff --git a/lib/moon/design/dropdown/option_with_icon.ex b/lib/moon/design/dropdown/option_with_icon.ex index af038e6a1..afe994b07 100644 --- a/lib/moon/design/dropdown/option_with_icon.ex +++ b/lib/moon/design/dropdown/option_with_icon.ex @@ -28,7 +28,7 @@ defmodule Moon.Design.Dropdown.IconOption do @doc "Additional values to be passed" prop(values, :map, from_context: :values) - @doc "Inner content of the option" + @doc "Inner content of the option, unused" slot(default) def render(assigns) do diff --git a/lib/moon_web/examples/light/table_example/editable.exs b/lib/moon_web/examples/light/table_example/editable.exs new file mode 100644 index 000000000..78a9206ad --- /dev/null +++ b/lib/moon_web/examples/light/table_example/editable.exs @@ -0,0 +1,30 @@ +defmodule MoonWeb.Examples.Light.TableExample.Editable do + @moduledoc false + use Moon.Light.LiveComponent + use MoonWeb, :example + + import Elixir.Moon.Light.Table + + attr(:models, :list, + default: + Enum.map(1..5, fn x -> + %{id: x, name: "Name #{x}", created_at: DateTime.add(DateTime.utc_now(), -3600 + x)} + end) + ) + + def render(assigns) do + ~H""" + <.table items={@models} selected={nil}> + <:cols :let={model} name="id" label="ID"> + <.input value={model.id} /> + + <:cols :let={model} name="name" label="First Name"> + <.input value={model.name} /> + + <:cols :let={model} name="created_at" label="Created at"> + <.input value={Timex.format!(model.created_at, "%b %d, %Y, %H:%M:%S", :strftime)} /> + + + """ + end +end