From c85fef007f7d3641af6bd889b1b89d1ebf62505a Mon Sep 17 00:00:00 2001 From: Sanne de Vries Date: Tue, 4 Nov 2025 10:14:22 +0100 Subject: [PATCH] Add static UI for adding a segment to a shared link - Update password UI to use a toogle switch to emphasize the optional nature of the feature - Add UI for limiting the link to a segment - Add toggle_field component for full-width label and toggle switch layout - Add optional link to the input component, showing below the input, which can be used for documentation links - Add eye icon to shared links list that indicates limited view - Add tooltips to icons in the shared links list --- lib/plausible_web/components/generic.ex | 55 +++++++- lib/plausible_web/live/components/form.ex | 23 +++- .../live/shared_link_settings.ex | 24 +++- .../live/shared_link_settings/form.ex | 121 +++++++++++++++++- 4 files changed, 203 insertions(+), 20 deletions(-) diff --git a/lib/plausible_web/components/generic.ex b/lib/plausible_web/components/generic.ex index 34eac55db26d..5b3258fb7623 100644 --- a/lib/plausible_web/components/generic.ex +++ b/lib/plausible_web/components/generic.ex @@ -391,7 +391,7 @@ defmodule PlausibleWeb.Components.Generic do ~H""" <.link class={[ - "inline-flex items-center gap-x-0.5", + "inline-flex items-center gap-x-1", @class ]} href={@href} @@ -401,7 +401,7 @@ defmodule PlausibleWeb.Components.Generic do {@rest} > {render_slot(@inner_block)} - + """ else @@ -469,6 +469,51 @@ defmodule PlausibleWeb.Components.Generic do """ end + attr :id, :string, required: true + attr :js_active_var, :string, required: true + attr :id_suffix, :string, default: "" + attr :disabled, :boolean, default: false + attr :label, :string, required: true + attr :help_text, :string, default: nil + attr :help_text_conditional, :boolean, default: false + attr :mt?, :boolean, default: true + + attr(:rest, :global) + + def toggle_field(assigns) do + help_text_conditional = assigns[:help_text_conditional] || false + + assigns = assign(assigns, help_text_conditional: help_text_conditional) + + ~H""" +
+
+ + {@label} + +

+ {@help_text} +

+
+ +
+ """ + end + def settings_tiles(assigns) do ~H"""
@@ -676,9 +721,9 @@ defmodule PlausibleWeb.Components.Generic do if String.contains?(classes, "text-sm") or String.contains?(classes, "text-xs") do - ["w-3 h-3"] + ["size-3"] else - ["w-4 h-4"] + ["size-4"] end end @@ -786,7 +831,7 @@ defmodule PlausibleWeb.Components.Generic do - <.label for={@id} class={if @help_text, do: "mb-0.5", else: "mb-1.5"}>{@label} +
+ <.label + :if={@label != nil and @label != ""} + for={@id} + class={if @help_text, do: "mb-0.5", else: "mb-1.5"} + > + {@label} +

{@help_text} @@ -84,6 +91,9 @@ defmodule PlausibleWeb.Live.Components.Form do {Phoenix.HTML.Form.options_for_select(@options, @value)} +

+ {render_slot(@link)} +
<.error :for={msg <- @errors}>{msg}
""" @@ -138,7 +148,7 @@ defmodule PlausibleWeb.Live.Components.Form do {@help_text} {render_slot(@help_content)} @@ -150,7 +160,7 @@ defmodule PlausibleWeb.Live.Components.Form do def input(%{type: "textarea"} = assigns) do ~H""" -
+
<.label class="mb-1.5" for={@id}>{@label}