Skip to content

Commit

Permalink
Format & Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
gcauchon committed Jun 19, 2023
1 parent 07dbe4d commit c4d24af
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
13 changes: 8 additions & 5 deletions assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@ import 'phoenix_html';
// Show progress bar on live navigation and form submits
import topbar from 'topbar';

const DELAY_IN_MILISECONDS = 200;

topbar.config({barColors: {0: '#29d'}, shadowColor: 'rgba(0, 0, 0, .3)'});
window.addEventListener('phx:page-loading-start', (info) =>
topbar.delayedShow(200)
window.addEventListener('phx:page-loading-start', (_info) =>
topbar.delayedShow(DELAY_IN_MILISECONDS)
);
window.addEventListener('phx:page-loading-stop', (info) => topbar.hide());
window.addEventListener('phx:page-loading-stop', (_info) => topbar.hide());

// Establish Phoenix Socket and LiveView configuration.
import {Socket} from 'phoenix';
import {LiveSocket} from 'phoenix_live_view';

let csrfToken = document
const csrfToken = document
.querySelector("meta[name='csrf-token']")
.getAttribute('content');
let liveSocket = new LiveSocket('/live', Socket, {
const liveSocket = new LiveSocket('/live', Socket, {
// eslint-disable-next-line camelcase
params: {_csrf_token: csrfToken}
});

Expand Down
2 changes: 2 additions & 0 deletions assets/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-env node */

// See the Tailwind configuration guide for advanced usage
// https://tailwindcss.com/docs/configuration

Expand Down
18 changes: 10 additions & 8 deletions lib/elixir_boilerplate_web/components/core.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ defmodule ElixirBoilerplateWeb.Components.Core do
"""
use Phoenix.Component

alias Phoenix.LiveView.JS
import ElixirBoilerplate.Gettext

alias Phoenix.HTML.Form
alias Phoenix.LiveView.JS

@doc """
Renders a modal.
Expand Down Expand Up @@ -207,7 +209,7 @@ defmodule ElixirBoilerplateWeb.Components.Core do
@doc """
Renders an input with label and error messages.
A `%Phoenix.HTML.Form{}` and field name may be passed to the input
A `%Form{}` and field name may be passed to the input
to build input names and error messages, or all the attributes and
errors may be passed explicitly.
Expand All @@ -226,11 +228,11 @@ defmodule ElixirBoilerplateWeb.Components.Core do
range radio search select tel text textarea time url week)

attr :value, :any
attr :field, :any, doc: "a %Phoenix.HTML.Form{}/field name tuple, for example: {f, :email}"
attr :field, :any, doc: "a %Form{}/field name tuple, for example: {f, :email}"
attr :errors, :list
attr :checked, :boolean, doc: "the checked flag for checkbox inputs"
attr :prompt, :string, default: nil, doc: "the prompt for select inputs"
attr :options, :list, doc: "the options to pass to Phoenix.HTML.Form.options_for_select/2"
attr :options, :list, doc: "the options to pass to Form.options_for_select/2"
attr :multiple, :boolean, default: false, doc: "the multiple flag for select inputs"
attr :rest, :global, include: ~w(autocomplete cols disabled form max maxlength min minlength
pattern placeholder readonly required rows size step)
Expand All @@ -240,11 +242,11 @@ defmodule ElixirBoilerplateWeb.Components.Core do
assigns
|> assign(field: nil)
|> assign_new(:name, fn ->
name = Phoenix.HTML.Form.input_name(f, field)
name = Form.input_name(f, field)
if assigns.multiple, do: name <> "[]", else: name
end)
|> assign_new(:id, fn -> Phoenix.HTML.Form.input_id(f, field) end)
|> assign_new(:value, fn -> Phoenix.HTML.Form.input_value(f, field) end)
|> assign_new(:id, fn -> Form.input_id(f, field) end)
|> assign_new(:value, fn -> Form.input_value(f, field) end)
|> assign_new(:errors, fn -> translate_errors(f.errors || [], field) end)
|> input()
end
Expand Down Expand Up @@ -273,7 +275,7 @@ defmodule ElixirBoilerplateWeb.Components.Core do
{@rest}
>
<option :if={@prompt} value=""><%= @prompt %></option>
<%= Phoenix.HTML.Form.options_for_select(@options, @value) %>
<%= Form.options_for_select(@options, @value) %>
</select>
<.error :for={msg <- @errors}><%= msg %></.error>
</div>
Expand Down

0 comments on commit c4d24af

Please sign in to comment.