Meu primeiro aplicativo
Mix.install([
{:kino, "~> 0.10.0"}
])
Frame
frame = Kino.Frame.new()
name = Kino.Input.text("Nome")
message = Kino.Input.textarea("Mensagem")
form =
Kino.Control.form(
[name: name, message: message],
submit: "Envie",
reset_on_submit: [:message]
)
Kino.listen(
form,
fn %{data: %{name: name, message: message}, origin: origin} ->
if name != "" and message != "" do
content = Kino.Markdown.new("**#{name}:** #{message}")
Kino.Frame.append(frame, content)
else
content = Kino.Markdown.new("**Nome e mensagem são obrigatórios!**")
Kino.Frame.append(frame, content, to: origin)
end
end
)