This file contains hidden or 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
module.exports = { | |
config: { | |
// default font size in pixels for all tabs | |
fontSize: 12, | |
// font family with optional fallbacks | |
fontFamily: 'Menlo, "DejaVu Sans Mono", Consolas, "Lucida Console", monospace', | |
// terminal cursor background color and opacity (hex, rgb, hsl, hsv, hwb or cmyk) | |
cursorColor: 'rgba(248,28,229,0.8)', |
This file contains hidden or 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 YourAppWeb.PersonRegistrationLive.New do | |
use Phoenix.LiveView | |
alias YourAppWeb.Router.Helpers, as: Routes | |
alias YourApp.Accounts | |
alias YourApp.Accounts.Person | |
def mount(_params, _session, socket) do | |
changeset = Accounts.change_person_registration(%Person{}) | |
{:ok, assign(socket, changeset: changeset)} |
This file contains hidden or 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 YourAppWeb.PersonRegistrationLive.New do | |
use Phoenix.LiveView | |
alias YourAppWeb.Router.Helpers, as: Routes | |
alias YourApp.Accounts | |
alias YourApp.Accounts.Person | |
def mount(_params, _session, socket) do | |
changeset = Accounts.change_person_registration(%Person{}) | |
{:ok, |
This file contains hidden or 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
<%= f = form_for @changeset, "#", [phx_change: :validate, phx_submit: :save] %> | |
<div class="<%= unless @current_step === 1, do: "hidden" %>"> | |
<!-- Step 1 form fields here --> | |
</div> | |
<div class="<%= unless @current_step === 2, do: "hidden" %>"> | |
<!-- Step 2 form fields here --> | |
</div> | |
<div class="<%= unless @current_step === 3, do: "hidden" %>"> | |
<!-- Step 3 form fields here --> |
This file contains hidden or 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 YourApp.Extensions.PhoneNumber do | |
@moduledoc """ | |
Functions for implementing phone number validations and formatting | |
using [ex_phone_number](https://hex.pm/packages/ex_phone_number). | |
""" | |
@doc """ | |
Parses a given phone number string. | |
## Example |
This file contains hidden or 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 YourApp.Accounts.Person do | |
... | |
alias YourApp.Encrypted # optional encryption | |
alias YourApp.Extensions.PhoneNumber | |
... | |
schema "people" do | |
... | |
field :phone_number, Encrypted.Binary, redact: true | |
... |
This file contains hidden or 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 YourAppWeb.PersonRegistrationLive.New do | |
... | |
def handle_event("next-step", _value, socket) do | |
current_step = socket.assigns.current_step | |
changeset = socket.assigns.changeset | |
step_invalid = | |
case current_step do | |
1 -> Enum.any?(Keyword.keys(changeset.errors), fn k -> k in [:name] end) |
This file contains hidden or 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
<%= f = form_for @changeset, "#", [phx_change: :validate, phx_submit: :save] %> | |
<div class="<%= unless @current_step === 1, do: "hidden" %>"> | |
<!-- Step 1 form fields here --> | |
</div> | |
<div class="<%= unless @current_step === 2, do: "hidden" %>"> | |
<!-- Step 2 form fields here --> | |
</div> | |
<div class="<%= unless @current_step === 3, do: "hidden" %>"> | |
<!-- Step 3 form fields here --> |
This file contains hidden or 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
... | |
import 'alpinejs' // Optional (we don't actually use alpine in this example) | |
... | |
let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content") | |
... | |
let Hooks = {} | |
Hooks.PhoneNumber = { | |
mounted() { |
This file contains hidden or 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 | |
~H""" | |
<.form let={f} for={@changeset} url="#" phx_change="validate" phx_submit="save"> | |
<div class={unless @current_step === 1, do: "hidden"}> | |
<!-- Step 1 form fields here --> | |
</div> | |
<div class={unless @current_step === 2, do: "hidden"}> | |
<!-- Step 2 form fields here --> | |
</div> |
OlderNewer