diff --git a/lib/components_elixir_web/live/components_live.ex b/lib/components_elixir_web/live/components_live.ex index b230e1f..533bae6 100644 --- a/lib/components_elixir_web/live/components_live.ex +++ b/lib/components_elixir_web/live/components_live.ex @@ -35,6 +35,7 @@ defmodule ComponentsElixirWeb.ComponentsLive do |> assign(:form, nil) |> assign(:show_image_modal, false) |> assign(:modal_image_url, nil) + |> assign(:focused_component_id, nil) |> allow_upload(:image, accept: ~w(.jpg .jpeg .png .gif), max_entries: 1, @@ -207,6 +208,19 @@ defmodule ComponentsElixirWeb.ComponentsLive do |> assign(:modal_image_url, nil)} end + def handle_event("toggle_focus", %{"id" => id}, socket) do + component_id = String.to_integer(id) + + new_focused_id = + if socket.assigns.focused_component_id == component_id do + nil # Unfocus if clicking on the same component + else + component_id # Focus on the new component + end + + {:noreply, assign(socket, :focused_component_id, new_focused_id)} + end + def handle_event("prevent_close", _params, socket) do {:noreply, socket} end @@ -675,26 +689,14 @@ defmodule ComponentsElixirWeb.ComponentsLive do
+
- {component.description} -
+ ++ {component.description} +
++ <%= if component.datasheet_url do %> + + {component.name} + + <% else %> + {component.name} + <% end %> +
+ <%= if component.datasheet_url do %> + 📄 + <% end %> ++ {component.description} +
++ Keywords: {component.keywords} +
- Keywords: {component.keywords} -
-