Skip to content

Instantly share code, notes, and snippets.

View Maartz's full-sized avatar
🎯
Focusing

Maartz Maartz

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