From 8965ac40a73940cd71ba777a36d22780320bc636 Mon Sep 17 00:00:00 2001 From: hq1 Date: Mon, 22 Jan 2024 12:14:47 +0100 Subject: [PATCH] Decorate site settings sidebar with heroicons (#3711) * Decorate site settings sidebar with heroicons * Capitalize "Danger Zone" * Capitalize "Danger Zone" --- lib/plausible_web/components/generic.ex | 10 ++++++++++ .../templates/layout/_settings_tab.html.eex | 5 ----- .../templates/layout/_settings_tab.html.heex | 13 +++++++++++++ .../templates/layout/site_settings.html.eex | 4 ++-- .../site/settings_danger_zone.html.eex | 2 +- lib/plausible_web/views/layout_view.ex | 18 +++++++++--------- 6 files changed, 35 insertions(+), 17 deletions(-) delete mode 100644 lib/plausible_web/templates/layout/_settings_tab.html.eex create mode 100644 lib/plausible_web/templates/layout/_settings_tab.html.heex diff --git a/lib/plausible_web/components/generic.ex b/lib/plausible_web/components/generic.ex index 8a72d0f28..3a6fb07a7 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) do if 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.eex deleted file mode 100644 index 1fe10c793..000000000 --- a/lib/plausible_web/templates/layout/_settings_tab.html.eex +++ /dev/null @@ -1,5 +0,0 @@ -<%= if is_current_tab(@conn, @this_tab) do %> - "><%= @text %> -<% else %> - "><%= @text %> -<% end %> diff --git a/lib/plausible_web/templates/layout/_settings_tab.html.heex b/lib/plausible_web/templates/layout/_settings_tab.html.heex new file mode 100644 index 000000000..560e6240d --- /dev/null +++ b/lib/plausible_web/templates/layout/_settings_tab.html.heex @@ -0,0 +1,13 @@ + 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" + ]} +> + + <%= @text %> + diff --git a/lib/plausible_web/templates/layout/site_settings.html.eex b/lib/plausible_web/templates/layout/site_settings.html.eex index 2759a0321..3913f3b3c 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 %> diff --git a/lib/plausible_web/templates/site/settings_danger_zone.html.eex b/lib/plausible_web/templates/site/settings_danger_zone.html.eex index b8c9415cc..892a7c4ed 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 @@
-

Danger zone

+

Danger Zone

Destructive actions below can result in irrecoverable data loss. Be careful.

<%= 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.ex index 6cbcacda2..6787cf9cc 100644 --- a/lib/plausible_web/views/layout_view.ex +++ b/lib/plausible_web/views/layout_view.ex @@ -42,18 +42,18 @@ defmodule PlausibleWeb.LayoutView do def 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