Decorate site settings sidebar with heroicons (#3711)

* Decorate site settings sidebar with heroicons

* Capitalize "Danger Zone"

* Capitalize "Danger Zone"
pull/3704/head r2024.01.22-321
hq1 3 years ago committed by GitHub
parent 1b95433d6e
commit 8965ac40a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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"]

@ -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 %>

@ -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>

@ -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>

@ -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 %>

@ -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

Loading…
Cancel
Save