Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Maartz Maartz

🎯
Focusing
  • Isolated in my process
View GitHub Profile
View livelight.ex
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"""
View livelight.ex
def handle_event("on", _metadata, socket) do
socket = assign(socket, :brigthness, 100)
{:noreply, socket}
end
View livelight.ex
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">
View livelight.ex
def render(assigns) do
~L"""
<h1>Front Porch Light</h1>
<div id="light">
<div class="meter">
<span style="width: <%= @brigthness %>%">
<%= @brigthness %>
</div>
<button>
View livelight.ex
def render(assigns) do
~L"""
<h1>Front Porch Light</h1>
<%= @brigthness %>
"""
end
View digital_numbers.ex
defmodule DigitalNumbers do
@moduledoc """
DigitalNumbers module provides an API to convert integer to LCD styled string integer
"""
@digital_numbers %{
0 => """
_
| |
|_|
View livelight.ex
defmodule LiveViewStudioWeb.LightLive do
use LiveViewStudioWeb, :live_view
def mount(_params, _session, socket) do
socket = assign(socket, :brigthness, 10)
{:ok, socket}
end
end
@Maartz
Maartz / router.ex
Created May 19, 2020
liveview router
View router.ex
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