Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Use the shared checkbox classes in the Phoenix input component (#6767)
Sanne de Vriesd000be439fe6
diff --git a/assets/css/app.css b/assets/css/app.cssindex 1f58d4a46a..905a6be945 100644--- a/assets/css/app.css+++ b/assets/css/app.css@@ -193,7 +193,8 @@/** Checkbox component classes shared between the React `Checkbox` component- * and `checkboxClassName` (assets/js/dashboard/components/form-elements.tsx).+ * and `checkboxClassName` (assets/js/dashboard/components/form-elements.tsx)+ * and the Phoenix `input` component (lib/plausible_web/live/components/form.ex).* Update here only.*/.checkbox-base {diff --git a/assets/js/dashboard/components/form-elements.tsx b/assets/js/dashboard/components/form-elements.tsxindex 44c01a6aa1..42b5b19ca0 100644--- a/assets/js/dashboard/components/form-elements.tsx+++ b/assets/js/dashboard/components/form-elements.tsx@@ -250,8 +250,9 @@ export const getOptionDisabledMessage = ({}/**- * The actual Tailwind classes live in `assets/css/app.css` (.checkbox-base,- * .checkbox-{sm,md}).+ * Sizes are kept in sync with the Phoenix `input` component in+ * `lib/plausible_web/live/components/form.ex`. The actual Tailwind classes live+ * in `assets/css/app.css` (.checkbox-base, .checkbox-{sm,md}).*/export type CheckboxSize = 'sm' | 'md'diff --git a/lib/plausible_web/live/components/form.ex b/lib/plausible_web/live/components/form.exindex 017720116f..9d0463f153 100644--- a/lib/plausible_web/live/components/form.ex+++ b/lib/plausible_web/live/components/form.ex@@ -23,6 +23,16 @@ defmodule PlausibleWeb.Live.Components.Form do@input_class "input-base input-md"@multiline_input_class "input-base input-md input-multiline"+ # Base and sizes are defined as component classes in assets/css/app.css and+ # mirrored by the React `Checkbox` component in+ # assets/js/dashboard/components/form-elements.tsx. Update there only.+ @checkbox_base_class "checkbox-base"++ @checkbox_sizes %{+ "sm" => "checkbox-sm",+ "md" => "checkbox-md"+ }+attr(:id, :any, default: nil)attr(:name, :any)attr(:label, :string, default: nil)@@ -45,11 +55,12 @@ defmodule PlausibleWeb.Live.Components.Form doattr(: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(:multiple, :boolean, default: false, doc: "the multiple flag for select inputs")+ attr(:size, :string, default: "md", values: ~w(sm md), doc: "the size of checkbox inputs")attr(:rest, :global,include:~w(accept autocomplete autofocus capture cols disabled form list max maxlength min minlength- multiple pattern placeholder readonly required rows size step x-bind:type x-model)+ multiple pattern placeholder readonly required rows step x-bind:type x-model))attr(:class, :any, default: "")@@ -103,9 +114,14 @@ defmodule PlausibleWeb.Live.Components.Form dodef input(%{type: "checkbox"} = assigns) doassigns =- assign_new(assigns, :checked, fn ->+ assigns+ |> assign_new(:checked, fn ->Phoenix.HTML.Form.normalize_value("checkbox", assigns[:value])end)+ |> assign(+ checkbox_base_class: @checkbox_base_class,+ checkbox_size_class: @checkbox_sizes[assigns.size]+ )~H"""<div class={@wrapper_class}>@@ -120,7 +136,7 @@ defmodule PlausibleWeb.Live.Components.Form dochecked={@checked}id={@id}name={@name}- class="block size-5 rounded-sm dark:bg-gray-600 border-gray-300 dark:border-gray-600 text-indigo-600"+ class={[@checkbox_base_class, @checkbox_size_class]}{@rest}/>{@label}diff --git a/lib/plausible_web/templates/auth/verify_2fa.html.heex b/lib/plausible_web/templates/auth/verify_2fa.html.heexindex 009898818b..6cfed66951 100644--- a/lib/plausible_web/templates/auth/verify_2fa.html.heex+++ b/lib/plausible_web/templates/auth/verify_2fa.html.heex@@ -24,7 +24,6 @@field={f[:remember_2fa]}value="true"label={"Remember this device for #{PlausibleWeb.TwoFactor.Session.remember_2fa_days()} days"}- class="block size-5 rounded-sm dark:bg-gray-700 border-gray-300 text-indigo-600 focus:ring-indigo-600"/></div>