diff --git a/.formatter.exs b/.formatter.exs index a78aed3cf..ae3e2f89e 100644 --- a/.formatter.exs +++ b/.formatter.exs @@ -1,4 +1,5 @@ [ + plugins: [Phoenix.LiveView.HTMLFormatter], import_deps: [:ecto, :ecto_sql, :phoenix], subdirectories: ["priv/*/migrations"], inputs: ["*.{heex,ex,exs}", "{config,lib,test}/**/*.{heex,ex,exs}", "priv/*/seeds.exs"] diff --git a/assets/js/app.js b/assets/js/app.js index 01d4640c1..51d51caae 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -29,7 +29,7 @@ window.addEventListener(`phx:update-value`, (e) => { window.addEventListener(`phx:hide`, (e) => { let el = document.getElementById(e.detail.id) - el.style.display = 'none' + el.classList.add('hidden') }) window.addEventListener(`phx:scroll-to`, (e) => { diff --git a/lib/plausible_web/live/funnel_settings.ex b/lib/plausible_web/live/funnel_settings.ex index 16f7913e2..0fb28fe5c 100644 --- a/lib/plausible_web/live/funnel_settings.ex +++ b/lib/plausible_web/live/funnel_settings.ex @@ -20,20 +20,34 @@ defmodule PlausibleWeb.Live.FunnelSettings do def render(assigns) do ~H""" <%= if @add_funnel? do %> - <.live_component module={PlausibleWeb.Live.FunnelSettings.Form} id="funnelForm" site={@site} form={to_form(Plausible.Funnel.changeset())} goals={@goals} /> + <.live_component + module={PlausibleWeb.Live.FunnelSettings.Form} + id="funnelForm" + site={@site} + form={to_form(Plausible.Funnel.changeset())} + goals={@goals} + /> <% else %>
= 2}> - <.live_component module={PlausibleWeb.Live.FunnelSettings.List} id="funnelsList" funnels={@funnels} site={@site} /> + <.live_component + module={PlausibleWeb.Live.FunnelSettings.List} + id="funnelsList" + funnels={@funnels} + site={@site} + />
- -
-

- You need to define at least two goals to create a funnel. Go ahead and <%= link "add goals", to: PlausibleWeb.Router.Helpers.site_path(@socket, :new_goal, @site.domain), class: "text-indigo-500 w-full text-center" %> to proceed. -

-
+
+

+ You need to define at least two goals to create a funnel. Go ahead and <%= link( + "add goals", + to: PlausibleWeb.Router.Helpers.site_path(@socket, :new_goal, @site.domain), + class: "text-indigo-500 w-full text-center" + ) %> to proceed. +

+
<% end %> """ end diff --git a/lib/plausible_web/live/funnel_settings/form.ex b/lib/plausible_web/live/funnel_settings/form.ex index e2ba53ee1..eec8867b6 100644 --- a/lib/plausible_web/live/funnel_settings/form.ex +++ b/lib/plausible_web/live/funnel_settings/form.ex @@ -16,11 +16,21 @@ defmodule PlausibleWeb.Live.FunnelSettings.Form do ~H"""
- <.form :let={f} for={@form} phx-change="validate" phx-submit="save" onkeydown="return event.key != 'Enter';"> - <%= label f, "Funnel name", class: "block text-sm font-medium text-gray-700 dark:text-gray-300" %> - <.input field={@form[:name]} /> + <.form + :let={f} + for={@form} + phx-change="validate" + phx-submit="save" + onkeydown="return event.key != 'Enter';" + > + <%= label(f, "Funnel name", + class: "block text-sm font-medium text-gray-700 dark:text-gray-300" + ) %> + <.input field={@form[:name]} /> - <%= label f, "Funnel Steps", class: "mt-6 block text-sm font-medium text-gray-700 dark:text-gray-300" %> + <%= label(f, "Funnel Steps", + class: "mt-6 block text-sm font-medium text-gray-700 dark:text-gray-300" + ) %> <.live_component :for={step_number <- 1..@step_count} @@ -29,13 +39,26 @@ defmodule PlausibleWeb.Live.FunnelSettings.Form do options={Enum.map(@goals, fn goal -> {goal.id, Plausible.Goal.display_name(goal)} end)} /> - + Add another step + + + Add another step +
- +
- +
""" @@ -45,7 +68,15 @@ defmodule PlausibleWeb.Live.FunnelSettings.Form do def input(assigns) do ~H""" - + """ end diff --git a/lib/plausible_web/live/funnel_settings/input_picker.ex b/lib/plausible_web/live/funnel_settings/input_picker.ex index 48d598009..5c19740ab 100644 --- a/lib/plausible_web/live/funnel_settings/input_picker.ex +++ b/lib/plausible_web/live/funnel_settings/input_picker.ex @@ -18,113 +18,154 @@ defmodule PlausibleWeb.Live.FunnelSettings.InputPicker do {:ok, socket} end - attr :placeholder, :string, default: "Select option or search by typing" - attr :id, :any, default: nil - attr :options, :list, required: true + attr(:placeholder, :string, default: "Select option or search by typing") + attr(:id, :any, default: nil) + attr(:options, :list, required: true) def render(assigns) do ~H"""
-
-
- - - - <.dropdown_anchor id={@id}/> - - +
+
+ + + <.dropdown_anchor id={@id} /> + + +
-
- <.dropdown ref={@id} options={@options} choices={@choices} target={@myself} candidate={@candidate} /> + <.dropdown + ref={@id} + options={@options} + choices={@choices} + target={@myself} + candidate={@candidate} + />
""" end - attr :id, :any, required: true + attr(:id, :any, required: true) def dropdown_anchor(assigns) do ~H""" -
-
+
""" end def open_dropdown(js \\ %JS{}, id) do - js |> close_all_dropdowns() |> JS.show(to: "#dropdown-#{id}") + js + |> close_all_dropdowns() + |> JS.remove_class("hidden", to: "#dropdown-#{id}") end def close_dropdown(js \\ %JS{}, id) do - JS.hide(js, to: "#dropdown-#{id}") + JS.add_class(js, "hidden", to: "#dropdown-#{id}") end def close_all_dropdowns(js \\ %JS{}) do - JS.hide(js, to: ".dropdown") + JS.add_class(js, "hidden", to: ".dropdown") end - attr :ref, :string, required: true - attr :options, :list, default: [] - attr :choices, :list, default: [] - attr :candidate, :integer, required: true - attr :target, :any + attr(:ref, :string, required: true) + attr(:options, :list, default: []) + attr(:choices, :list, default: []) + attr(:candidate, :integer, required: true) + attr(:target, :any) def dropdown(assigns) do ~H""" """ end - attr :display_value, :string, required: true - attr :submit_value, :integer, required: true - attr :ref, :string, required: true - attr :target, :any - attr :idx, :integer, required: true - attr :candidate, :integer, required: true + attr(:display_value, :string, required: true) + attr(:submit_value, :integer, required: true) + attr(:ref, :string, required: true) + attr(:target, :any) + attr(:idx, :integer, required: true) + attr(:candidate, :integer, required: true) def option(assigns) do assigns = assign(assigns, :max_options_displayed, @max_options_displayed) ~H""" -
  • - - +
  • + <%= @display_value %>
  • -
  • Max results reached. Refine your search by typing in goal name.
  • +
  • + Max results reached. Refine your search by typing in goal name. +
  • """ end diff --git a/lib/plausible_web/live/funnel_settings/list.ex b/lib/plausible_web/live/funnel_settings/list.ex index ec3e1aeec..08f4bb8a4 100644 --- a/lib/plausible_web/live/funnel_settings/list.ex +++ b/lib/plausible_web/live/funnel_settings/list.ex @@ -5,20 +5,37 @@ defmodule PlausibleWeb.Live.FunnelSettings.List do def render(assigns) do ~H"""
    - <%= if Enum.count(@funnels) > 0 do %> -
    - <%= for funnel <- @funnels do %> -
    - <%= funnel.name %> - <%= button(to: "", method: :delete, class: "text-sm text-red-600", data: [confirm: "Are you sure you want to remove funnel '#{funnel.name}'? This will just affect the UI, all of your analytics data will stay intact."]) do %> - - <% end %> -
    - <% end %> -
    - <% else %> -
    No funnels configured for this site yet
    - <% end %> + <%= if Enum.count(@funnels) > 0 do %> +
    + <%= for funnel <- @funnels do %> +
    + + <%= funnel.name %> + + <%= button(to: "", method: :delete, class: "text-sm text-red-600", data: [confirm: "Are you sure you want to remove funnel '#{funnel.name}'? This will just affect the UI, all of your analytics data will stay intact."]) do %> + + + + + + + + <% end %> +
    + <% end %> +
    + <% else %> +
    No funnels configured for this site yet
    + <% end %>
    """ end diff --git a/lib/plausible_web/views/site_view.ex b/lib/plausible_web/views/site_view.ex index 6c42db777..7086fe730 100644 --- a/lib/plausible_web/views/site_view.ex +++ b/lib/plausible_web/views/site_view.ex @@ -57,18 +57,50 @@ defmodule PlausibleWeb.SiteView do def google_logo(assigns \\ %{}) do ~H""" - - - - - - - - - + + + + + + + + + + + + + + - """ end