Skip to content
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
39 lines (34 sloc) 1.25 KB
defmodule DemoWeb.ImageLive do
use Phoenix.LiveView
alias DemoWeb.Router.Helpers, as: Routes
def radio_tag(assigns) do
assigns = Enum.into(assigns, %{})
<input type="radio" name="<%= @name %>" value="<%= @value %>"
<%= if @value == @checked, do: "checked" %> />
def render(assigns) do
<div style="margin-left: <%= @depth * 50 %>px;">
<form phx-change="update">
<input type="range" min="10" max="630" name="width" value="<%= @width %>" />
<%= @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) %>
<img phx-click="boom" src="<%= Routes.static_path(DemoWeb.Endpoint, "/images/phoenix.png") %>" width="<%= @width %>" style="background: <%= @bg %>;" />
def mount(_session, socket) do
{:ok, assign(socket, width: 100, bg: "white", depth: 0, max_depth: 0)}
def handle_event("update", %{"width" => width, "bg" => bg}, socket) do
{:noreply, assign(socket, width: String.to_integer(width), bg: bg)}
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.