diff --git a/lib/lightning_web/components/icons.ex b/lib/lightning_web/components/icons.ex index 63a7df1b3b..dfd606cffa 100644 --- a/lib/lightning_web/components/icons.ex +++ b/lib/lightning_web/components/icons.ex @@ -22,21 +22,16 @@ defmodule LightningWeb.Components.Icons do <.icon name="hero-play-circle" class="ml-1 w-3 h-3 animate-spin" /> """ attr :name, :string, required: true - attr :class, :string, default: nil - attr :naked, :boolean, default: false attr :rest, :global def icon(%{name: "hero-" <> _} = assigns) do + assigns = + assigns + |> assign(:class, get_in(assigns, [:rest, :class]) |> List.wrap()) + |> update(:rest, fn rest -> Map.delete(rest, :class) end) + ~H""" - + """ end end diff --git a/lib/lightning_web/components/layout_components.ex b/lib/lightning_web/components/layout_components.ex index fcfdf3e338..937795fc1a 100644 --- a/lib/lightning_web/components/layout_components.ex +++ b/lib/lightning_web/components/layout_components.ex @@ -167,26 +167,29 @@ defmodule LightningWeb.LayoutComponents do else: String.at(@current_user.last_name, 0) } /> - <.dropdown_menu_item link_type="live_redirect" to={~p"/profile"}> - + <.icon name="hero-user-circle" class="w-5 h-5 text-secondary-500" /> User Profile <.dropdown_menu_item link_type="live_redirect" to={~p"/credentials"}> - Credentials + <.icon name="hero-key" class="w-5 h-5 text-secondary-500" /> + Credentials <.dropdown_menu_item link_type="live_redirect" to={~p"/profile/tokens"}> - + <.icon name="hero-command-line" class="w-5 h-5 text-secondary-500" /> API Tokens <.dropdown_menu_item link_type="live_redirect" to={~p"/users/log_out"}> - - Log out + <.icon + name="hero-arrow-right-on-rectangle" + class="w-5 h-5 text-secondary-500" + /> Log out <% end %> diff --git a/lib/lightning_web/components/layouts/live.html.heex b/lib/lightning_web/components/layouts/live.html.heex index 9d6de84b44..a5055fae45 100644 --- a/lib/lightning_web/components/layouts/live.html.heex +++ b/lib/lightning_web/components/layouts/live.html.heex @@ -7,7 +7,7 @@ >
- <.link navigate={Routes.dashboard_index_path(@socket, :index)}> + <.link navigate={~p"/projects"}>
<%= if @current_user.role == :superuser do %> - + <.icon name="hero-cog" class="h-5 w-5 inline-block mr-2" /> Admin Menu <%= if function_exported?(Routes, :live_dashboard_path, 2) do %> - + <.icon + name="hero-exclamation-triangle" + class="h-5 w-5 inline-block mr-2" + /> Sys Info <% end %> <% else %> - + <.icon name="hero-book-open" class="h-5 w-5 inline-block mr-2" /> Documentation - + <.icon name="hero-user-group" class="h-5 w-5 inline-block mr-2" /> Community Lightning.Config.instance_admin_email()}> - + <.icon name="hero-lifebuoy" class="h-5 w-5 inline-block mr-2" /> Support <% end %> diff --git a/lib/lightning_web/components/layouts/settings.html.heex b/lib/lightning_web/components/layouts/settings.html.heex index eb22faf8f0..108e4ac98d 100644 --- a/lib/lightning_web/components/layouts/settings.html.heex +++ b/lib/lightning_web/components/layouts/settings.html.heex @@ -22,33 +22,33 @@ to={Routes.project_index_path(@socket, :index)} active={@active_menu_item == :projects} > - + <.icon name="hero-building-library" class="h-5 w-5 inline-block mr-2" /> Projects - + <.icon name="hero-user-group" class="h-5 w-5 inline-block mr-2" /> Users - + <.icon name="hero-key" class="h-5 w-5 inline-block mr-2" /> Authentication - + <.icon name="hero-archive-box" class="h-5 w-5 inline-block mr-2" /> Audit
- + <.icon name="hero-arrow-left-mini" class="h-5 w-5 inline-block mr-2" /> Back diff --git a/lib/lightning_web/components/viewers.ex b/lib/lightning_web/components/viewers.ex index dafb4af029..f073506c02 100644 --- a/lib/lightning_web/components/viewers.ex +++ b/lib/lightning_web/components/viewers.ex @@ -189,7 +189,7 @@ defmodule LightningWeb.Components.Viewers do >
- + <.icon name="hero-code-bracket" class="w-4 h-4" />
diff --git a/lib/lightning_web/controllers/user_session_html/new.html.heex b/lib/lightning_web/controllers/user_session_html/new.html.heex index f901bb6eeb..bad2238228 100644 --- a/lib/lightning_web/controllers/user_session_html/new.html.heex +++ b/lib/lightning_web/controllers/user_session_html/new.html.heex @@ -54,10 +54,8 @@
- - - via external provider - + <.icon name="hero-identification" class="h-4 w-4" /> + via external provider
diff --git a/lib/lightning_web/live/audit_live/index.ex b/lib/lightning_web/live/audit_live/index.ex index 5fe382c6ef..0f11339488 100644 --- a/lib/lightning_web/live/audit_live/index.ex +++ b/lib/lightning_web/live/audit_live/index.ex @@ -62,7 +62,7 @@ defmodule LightningWeb.AuditLive.Index do ~H""" <%= for {field, old, new} <- @changes do %>
  • <%= field %>  <%= old %> - + <.icon name="hero-arrow-right-mini" class="h-4 w-4 inline-block mr-2" /> <%= new %>
  • <% end %> """ diff --git a/lib/lightning_web/live/auth_providers/form_component.ex b/lib/lightning_web/live/auth_providers/form_component.ex index 5f5eb97d1f..7a864bb14e 100644 --- a/lib/lightning_web/live/auth_providers/form_component.ex +++ b/lib/lightning_web/live/auth_providers/form_component.ex @@ -270,7 +270,7 @@ defmodule LightningWeb.AuthProvidersLive.FormComponent do
    - + <.icon name="hero-trash" class="h-4 w-4 inline-block" /> Remove
    diff --git a/lib/lightning_web/live/live_helpers.ex b/lib/lightning_web/live/live_helpers.ex index 55263bebdd..6efe7d4751 100644 --- a/lib/lightning_web/live/live_helpers.ex +++ b/lib/lightning_web/live/live_helpers.ex @@ -3,6 +3,7 @@ defmodule LightningWeb.LiveHelpers do General purpose LiveView helper functions """ import Phoenix.Component + import LightningWeb.Components.Icons alias Lightning.Extensions.UsageLimiting.Context alias Lightning.Services.UsageLimiter @@ -102,7 +103,7 @@ defmodule LightningWeb.LiveHelpers do
    - + <.icon name="hero-exclamation-triangle" class="h-6 w-6 text-red-600" />

    Close
    - + <.icon name="hero-x-mark" class="w-4 h-4" />

    diff --git a/lib/lightning_web/live/run_live/components.ex b/lib/lightning_web/live/run_live/components.ex index 643d2de043..7c8675f9a0 100644 --- a/lib/lightning_web/live/run_live/components.ex +++ b/lib/lightning_web/live/run_live/components.ex @@ -179,8 +179,8 @@ defmodule LightningWeb.RunLive.Components do phx-hook="Tooltip" data-placement="bottom" > - @@ -196,10 +196,9 @@ defmodule LightningWeb.RunLive.Components do } > <.icon - naked title="Inspect Step" name="hero-document-magnifying-glass-mini" - class="h-5 w-5" + class="h-5 w-5 text-gray-500 hover:text-primary-400" /> <% end %> @@ -363,8 +362,8 @@ defmodule LightningWeb.RunLive.Components do phx-hook="Tooltip" data-placement="right" > - @@ -385,9 +384,8 @@ defmodule LightningWeb.RunLive.Components do } > <.icon - naked name="hero-document-magnifying-glass-mini" - class="h-5 w-5" + class="h-5 w-5 text-gray-500 hover:text-primary-400" />
    @@ -436,12 +434,14 @@ defmodule LightningWeb.RunLive.Components do end} > <.icon - {if not @deleted, do: [naked: true], else: []} name="hero-play-circle-mini" - class={"h-5 w-5 #{if not @deleted, - do: "hover:text-primary-400 cursor-pointer", - else: "text-gray-400 hover:text-gray-400" - }"} + class={[ + "h-5 w-5", + if(not @deleted, + do: "hover:text-primary-400 cursor-pointer", + else: "text-gray-400 hover:text-gray-400" + ) + ]} /> <% else %> @@ -458,7 +458,7 @@ defmodule LightningWeb.RunLive.Components do ) } > - + <.icon name="hero-arrow-path" class="h-5 w-5" /> <% end %> """ @@ -543,46 +543,44 @@ defmodule LightningWeb.RunLive.Components do def step_icon(%{reason: reason, error_type: error_type} = assigns) do [icon, classes] = case {reason, error_type} do - {nil, _any} -> [:pending, "text-gray-400"] - {"success", _any} -> [:success, "text-green-500"] - {"fail", _any} -> [:fail, "text-red-500"] - {"crash", _any} -> [:crash, "text-orange-800"] - {"cancel", _any} -> [:cancel, "text-grey-600"] - {"kill", "SecurityError"} -> [:shield, "text-yellow-800"] - {"kill", "ImportError"} -> [:shield, "text-yellow-800"] - {"kill", "TimeoutError"} -> [:clock, "text-yellow-800"] - {"kill", "OOMError"} -> [:circle_ex, "text-yellow-800"] - {"exception", ""} -> [:triangle_ex, "text-black-800"] - {"lost", _nil} -> [:triangle_ex, "text-black-800"] + {nil, _any} -> + ["hero-ellipsis-horizontal-circle-solid", "text-gray-400"] + + {"success", _any} -> + ["hero-check-circle-solid", "text-green-500"] + + {"fail", _any} -> + ["hero-x-circle-solid", "text-red-500"] + + {"crash", _any} -> + ["hero-x-circle-solid", "text-orange-800"] + + {"cancel", _any} -> + ["hero-no-symbol-mini", "text-grey-600"] + + {"kill", "SecurityError"} -> + ["hero-shield-exclamation-solid", "text-yellow-800"] + + {"kill", "ImportError"} -> + ["hero-shield-exclamation-solid", "text-yellow-800"] + + {"kill", "TimeoutError"} -> + ["hero-clock-solid", "text-yellow-800"] + + {"kill", "OOMError"} -> + ["hero-exclamation-circle-solid", "text-yellow-800"] + + {"exception", ""} -> + ["hero-exclamation-triangle-solid", "text-black-800"] + + {"lost", _nil} -> + ["hero-exclamation-triangle-solid", "text-black-800"] end - assigns = - assign(assigns, - icon: icon, - classes: ["mr-1.5 h-5 w-5 flex-shrink-0 inline", classes] - ) + assigns = assign(assigns, icon: icon, classes: classes) ~H""" - <%= case @icon do %> - <% :pending -> %> - - <% :success -> %> - - <% :fail -> %> - - <% :crash -> %> - - <% :cancel -> %> - - <% :shield -> %> - - <% :clock -> %> - - <% :circle_ex -> %> - - <% :triangle_ex -> %> - - <% end %> + <.icon name={@icon} class={["mr-1.5 h-5 w-5 flex-shrink-0 inline", @classes]} /> """ end diff --git a/storybook/runs/status_icons.story.exs b/storybook/runs/status_icons.story.exs new file mode 100644 index 0000000000..bc663f6d1b --- /dev/null +++ b/storybook/runs/status_icons.story.exs @@ -0,0 +1,31 @@ +defmodule LightningWeb.Storybook.Runs.StatusIcons do + alias LightningWeb.RunLive.Components + use PhoenixStorybook.Story, :component + + # required + def function, do: &Components.step_icon/1 + + def variations do + [ + {:nothing, nil, nil}, + {:success, "success", nil}, + {:fail, "fail", nil}, + {:crash, "crash", nil}, + {:cancel, "cancel", nil}, + {:kill_security, "kill", "SecurityError"}, + {:kill_import, "kill", "ImportError"}, + {:kill_timeout, "kill", "TimeoutError"}, + {:kill_oom, "kill", "OOMError"}, + {:exception, "exception", ""}, + {:list, "lost", nil} + ] + |> Enum.map(fn {id, reason, error_type} -> + %Variation{ + id: id, + description: "Status Icon", + attributes: %{reason: reason, error_type: error_type}, + slots: [] + } + end) + end +end diff --git a/test/lightning_web/live/run_live/components_test.exs b/test/lightning_web/live/run_live/components_test.exs index ffe59d351a..66e3fa97d8 100644 --- a/test/lightning_web/live/run_live/components_test.exs +++ b/test/lightning_web/live/run_live/components_test.exs @@ -108,11 +108,11 @@ defmodule LightningWeb.RunLive.ComponentsTest do ) |> Floki.parse_fragment!() - assert html - |> Floki.find( - ~s{svg[class="mr-1.5 h-5 w-5 flex-shrink-0 inline text-gray-400"]} + assert has_elem_with_class?( + html, + "span", + "hero-ellipsis-horizontal-circle-solid text-gray-400" ) - |> Enum.any?() assert has_run_step_link?(html, workflow.project, run, first_step) @@ -127,11 +127,11 @@ defmodule LightningWeb.RunLive.ComponentsTest do ) |> Floki.parse_fragment!() - assert html - |> Floki.find( - ~s{svg[class="mr-1.5 h-5 w-5 flex-shrink-0 inline text-green-500"]} + assert has_elem_with_class?( + html, + "span", + "hero-check-circle-solid text-green-500" ) - |> Enum.any?() assert has_run_step_link?(html, workflow.project, run, second_step) @@ -146,11 +146,11 @@ defmodule LightningWeb.RunLive.ComponentsTest do ) |> Floki.parse_fragment!() - assert html - |> Floki.find( - ~s{svg[class="mr-1.5 h-5 w-5 flex-shrink-0 inline text-red-500"]} + assert has_elem_with_class?( + html, + "span", + "hero-x-circle-solid text-red-500" ) - |> Enum.any?() assert has_run_step_link?(html, workflow.project, run, third_step) @@ -493,4 +493,20 @@ defmodule LightningWeb.RunLive.ComponentsTest do ) |> Enum.any?() end + + defp has_elem_with_class?(html, tag, class_names) do + html + |> Floki.find(tag) + |> Enum.filter(fn {_tag, attrs, _inner} -> + Enum.filter(attrs, &match?({"class", _}, &1)) + |> Enum.find(attrs, fn {"class", value} -> + class_names + |> String.split() + |> Enum.all?(fn class_name -> + String.contains?(value, class_name) + end) + end) + end) + |> Enum.any?() + end end