This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule LiveViewStudioWeb.LightLive do | |
use LiveViewStudioWeb, :live_view | |
def mount(_params, _session, socket) do | |
socket = assign(socket, :brightness, 10) | |
{:ok, socket} | |
end | |
def render(assigns) do | |
~L""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def handle_event("on", _metadata, socket) do | |
socket = assign(socket, :brigthness, 100) | |
{:noreply, socket} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def render(assigns) do | |
~L""" | |
<h1>Front Porch Light</h1> | |
<div id="light"> | |
<div class="meter"> | |
<span style="width: <%= @brigthness %>%"> | |
<%= @brigthness %> | |
</div> | |
<button phx-click="off"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def render(assigns) do | |
~L""" | |
<h1>Front Porch Light</h1> | |
<div id="light"> | |
<div class="meter"> | |
<span style="width: <%= @brigthness %>%"> | |
<%= @brigthness %> | |
</div> | |
<button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def render(assigns) do | |
~L""" | |
<h1>Front Porch Light</h1> | |
<%= @brigthness %> | |
""" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule DigitalNumbers do | |
@moduledoc """ | |
DigitalNumbers module provides an API to convert integer to LCD styled string integer | |
""" | |
@digital_numbers %{ | |
0 => """ | |
_ | |
| | | |
|_| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule LiveViewStudioWeb.LightLive do | |
use LiveViewStudioWeb, :live_view | |
def mount(_params, _session, socket) do | |
socket = assign(socket, :brigthness, 10) | |
{:ok, socket} | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule LiveViewStudioWeb.Router do | |
use LiveViewStudioWeb, :router | |
pipeline :browser do | |
plug :accepts, ["html"] | |
plug :fetch_session | |
plug :fetch_live_flash | |
plug :put_root_layout, {LiveViewStudioWeb.LayoutView, :root} | |
plug :protect_from_forgery | |
plug :put_secure_browser_headers |