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
Decorate site settings sidebar with heroicons (#3711)
hq18965ac40a739
diff --git a/lib/plausible_web/components/generic.ex b/lib/plausible_web/components/generic.exindex 8a72d0f28e..3a6fb07a70 100644--- a/lib/plausible_web/components/generic.ex+++ b/lib/plausible_web/components/generic.ex@@ -273,6 +273,16 @@ defmodule PlausibleWeb.Components.Generic do"""end+ attr :rest, :global, include: ~w(fill stroke stroke-width)+ attr :name, :atom, required: true+ attr :outline, :boolean, default: true+ attr :solid, :boolean, default: false+ attr :mini, :boolean, default: false++ def dynamic_icon(assigns) do+ apply(Heroicons, assigns.name, [assigns])+ end+defp icon_class(link_assigns) doif String.contains?(link_assigns[:class], "text-sm") do["w-3 h-3"]diff --git a/lib/plausible_web/templates/layout/_settings_tab.html.eex b/lib/plausible_web/templates/layout/_settings_tab.html.eexdeleted file mode 100644index 1fe10c793a..0000000000--- a/lib/plausible_web/templates/layout/_settings_tab.html.eex+++ /dev/null@@ -1,5 +0,0 @@-<%= if is_current_tab(@conn, @this_tab) do %>- <a href="/<%= URI.encode_www_form(@site.domain) %>/settings/<%= @this_tab %>" class="flex items-center px-3 py-2 text-sm leading-5 font-medium text-gray-900 dark:text-gray-100 rounded-md bg-gray-100 dark:bg-gray-900 hover:text-gray-900 hover:bg-gray-100 outline-none focus:outline-none focus:bg-gray-200 dark:focus:bg-gray-800 transition ease-in-out duration-150 cursor-default <%= if @this_tab != "general", do: "mt-1" %>"><%= @text %></a>-<% else %>- <a href="/<%= URI.encode_www_form(@site.domain) %>/settings/<%= @this_tab %>" class="flex items-center px-3 py-2 text-sm leading-5 font-medium text-gray-600 dark:text-gray-400 rounded-md hover:text-gray-900 dark:hover:text-gray-100 hover:bg-gray-50 dark:hover:bg-gray-800 outline-none focus:outline-none focus:text-gray-900 focus:bg-gray-50 dark:focus:text-gray-100 dark:focus:bg-gray-800 transition ease-in-out duration-150 <%= if @this_tab != "general", do: "mt-1" %>"><%= @text %></a>-<% end %>diff --git a/lib/plausible_web/templates/layout/_settings_tab.html.heex b/lib/plausible_web/templates/layout/_settings_tab.html.heexnew file mode 100644index 0000000000..560e6240df--- /dev/null+++ b/lib/plausible_web/templates/layout/_settings_tab.html.heex@@ -0,0 +1,13 @@+<a+ href={"/" <> URI.encode_www_form(@site.domain) <> "/settings/" <> @this_tab}+ class={[+ "flex items-center px-3 py-2 text-sm leading-5 font-medium rounded-md outline-none focus:outline-none transition ease-in-out duration-150 cursor-default",+ is_current_tab(@conn, @this_tab) &&+ "cursor-default text-gray-900 dark:text-gray-100 bg-gray-100 dark:bg-gray-900 hover:text-gray-900 hover:bg-gray-100 focus:bg-gray-200 dark:focus:bg-gray-800",+ not is_current_tab(@conn, @this_tab) &&+ "cursor-pointer text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-100 hover:bg-gray-50 dark:hover:bg-gray-800 focus:text-gray-900 focus:bg-gray-50 dark:focus:text-gray-100 dark:focus:bg-gray-800"+ ]}+>+ <PlausibleWeb.Components.Generic.dynamic_icon name={@icon} class="h-4 w-4 mr-2" />+ <%= @text %>+</a>diff --git a/lib/plausible_web/templates/layout/site_settings.html.eex b/lib/plausible_web/templates/layout/site_settings.html.eexindex 2759a03214..3913f3b3cd 100644--- a/lib/plausible_web/templates/layout/site_settings.html.eex+++ b/lib/plausible_web/templates/layout/site_settings.html.eex@@ -12,8 +12,8 @@<%= select f, :tab, settings_tabs(@conn), class: "dark:bg-gray-800 mt-1 block w-full pl-3 pr-10 py-2 text-base border-gray-300 dark:border-gray-500 outline-none focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md dark:text-gray-100", onchange: "location.href = location.href.replace(/[^\/\/]*$/, event.target.value)", selected: List.last(@conn.path_info) %><% end %><div class="hidden lg:block">- <%= for [key: key, value: val] <- settings_tabs(@conn) do %>- <%= render("_settings_tab.html", this_tab: val, text: key, site: @site, conn: @conn) %>+ <%= for [key: key, value: val, icon: icon] <- settings_tabs(@conn) do %>+ <%= render("_settings_tab.html", icon: icon, this_tab: val, text: key, site: @site, conn: @conn) %><% end %></div></div>diff --git a/lib/plausible_web/templates/site/settings_danger_zone.html.eex b/lib/plausible_web/templates/site/settings_danger_zone.html.eexindex b8c9415cc8..892a7c4edd 100644--- a/lib/plausible_web/templates/site/settings_danger_zone.html.eex+++ b/lib/plausible_web/templates/site/settings_danger_zone.html.eex@@ -1,7 +1,7 @@<div class="sm:rounded-md sm:overflow-hidden shadow"><div class="bg-white dark:bg-gray-800 py-6 px-4 space-y-6 sm:p-6"><div>- <h2 class="text-lg leading-6 font-medium text-gray-900 dark:text-gray-100">Danger zone</h2>+ <h2 class="text-lg leading-6 font-medium text-gray-900 dark:text-gray-100">Danger Zone</h2><p class="mt-1 text-sm leading-5 text-gray-500 dark:text-gray-200">Destructive actions below can result in irrecoverable data loss. Be careful.</p></div><%= if @conn.assigns[:current_user_role] == :owner do %>diff --git a/lib/plausible_web/views/layout_view.ex b/lib/plausible_web/views/layout_view.exindex 6cbcacda2d..6787cf9cc8 100644--- a/lib/plausible_web/views/layout_view.ex+++ b/lib/plausible_web/views/layout_view.ex@@ -42,18 +42,18 @@ defmodule PlausibleWeb.LayoutView dodef settings_tabs(conn) do[- [key: "General", value: "general"],- [key: "People", value: "people"],- [key: "Visibility", value: "visibility"],- [key: "Goals", value: "goals"],+ [key: "General", value: "general", icon: :rocket_launch],+ [key: "People", value: "people", icon: :users],+ [key: "Visibility", value: "visibility", icon: :eye],+ [key: "Goals", value: "goals", icon: :check_circle],on_full_build do- [key: "Funnels", value: "funnels"]+ [key: "Funnels", value: "funnels", icon: :funnel]end,- [key: "Custom Properties", value: "properties"],- [key: "Integrations", value: "integrations"],- [key: "Email Reports", value: "email-reports"],+ [key: "Custom Properties", value: "properties", icon: :document_text],+ [key: "Integrations", value: "integrations", icon: :arrow_path_rounded_square],+ [key: "Email Reports", value: "email-reports", icon: :envelope],if conn.assigns[:current_user_role] == :owner do- [key: "Danger zone", value: "danger-zone"]+ [key: "Danger Zone", value: "danger-zone", icon: :exclamation_triangle]end]end