-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add dependency phx_gen_auth to Authentication
- Loading branch information
Showing
5 changed files
with
54 additions
and
2 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<input | ||
type="text" | ||
name="q" | ||
value="<%= @query %>" | ||
placeholder="Live dependency search" | ||
list="results" | ||
autocomplete="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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
defmodule PentoWeb.WrongLive do | ||
use PentoWeb, :live_view | ||
|
||
def mount(_params, _session, socket) do | ||
{ | ||
:ok, | ||
assign(socket, score: 0, message: "Guess a number") | ||
} | ||
end | ||
|
||
def render(assigns) do | ||
~L""" | ||
<h1>Your score: <%= @score %></h1> | ||
<h2> | ||
<%= @message %> | ||
</h2> | ||
<h2> | ||
<%= for n <- 1..10 do %> | ||
<a href="#" phx-click="guess" phx-value-number="<%= n %>"><%= n %></a> | ||
<% end %> | ||
</h2> | ||
<h2> | ||
<%= @message %> | ||
It's <%= time() %> | ||
</h2> | ||
""" | ||
end | ||
|
||
def handle_event("guess", %{"number" => guess} = data, socket) do | ||
IO.inspect(data) | ||
message = "Your guess: #{guess}. Wrong. Guess again. " | ||
score = socket.assigns.score - 1 | ||
|
||
{ | ||
:noreply, | ||
assign(socket, message: message, score: score) | ||
} | ||
end | ||
|
||
def time() do | ||
DateTime.utc_now() |> to_string() | ||
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
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