defmodule DemoWeb.ImageView do
use Phoenix.LiveView
def render(assigns) do
~L"""
<%= @width %>px
White <%= radio_tag(name: :bg, value: "white", checked: @bg) %>
Black <%= radio_tag(name: :bg, value: "black", checked: @bg) %>
Blue <%= radio_tag(name: :bg, value: "blue", checked: @bg) %>

"""
end
def radio_tag(assigns) do
~L"""
/>
"""
end
def mount(_session, socket) do
{:ok, assign(socket, width: 100, bg: "white")}
end
def handle_event("update", %{"width" => width, "bg" => bg}, socket) do
{:noreply, assign(socket, width: String.to_integer(width), bg: bg)}
end
end
18 / 27