diff --git a/lib/dotcom_web/components/trip_planner/place.ex b/lib/dotcom_web/components/trip_planner/place.ex index aa6f210ce8..34944880c6 100644 --- a/lib/dotcom_web/components/trip_planner/place.ex +++ b/lib/dotcom_web/components/trip_planner/place.ex @@ -5,9 +5,10 @@ defmodule DotcomWeb.Components.TripPlanner.Place do use DotcomWeb, :component + attr :accessible, :boolean, default: false attr :name, :string, required: true attr :time, :any, required: true - attr :accessible, :boolean, default: false + attr :url, :string, default: nil slot :icon def place(assigns) do @@ -17,27 +18,41 @@ defmodule DotcomWeb.Components.TripPlanner.Place do {render_slot(@icon)} - - {@name} - <.icon - :if={@accessible} - type="icon-svg" - name="icon-accessible-default" - class="h-3 w-3 shrink-0 ml-1.5" - aria-hidden="true" - /> - + <.wrap_with_url url={@url}> + + {@name} + <.icon + :if={@accessible} + type="icon-svg" + name="icon-accessible-default" + class="h-3 w-3 shrink-0 ml-1.5" + aria-hidden="true" + /> + + """ end - # defp stop_url(%Route{external_agency_name: nil}, %Stop{} = stop) do - # ~p"/stops/#{stop}" - # end + attr :url, :string, required: true + slot :inner_block + defp wrap_with_url(assigns) - # defp stop_url(_, _), do: nil + defp wrap_with_url(%{url: nil} = assigns) do + ~H""" + {render_slot(@inner_block)} + """ + end + + defp wrap_with_url(assigns) do + ~H""" + + {render_slot(@inner_block)} + + """ + end defp format_time(datetime), do: Timex.format!(datetime, "%-I:%M %p", :strftime) end diff --git a/lib/dotcom_web/components/trip_planner/start_or_end_place.ex b/lib/dotcom_web/components/trip_planner/start_or_end_place.ex index ccba901d0d..e94babe80c 100644 --- a/lib/dotcom_web/components/trip_planner/start_or_end_place.ex +++ b/lib/dotcom_web/components/trip_planner/start_or_end_place.ex @@ -16,16 +16,6 @@ defmodule DotcomWeb.Components.TripPlanner.StartOrEndPlace do attr :alerts, :list, default: [] def start_or_end_place(assigns) do - # TODO come back to this - - stop_url = stop_url(assigns.route, assigns.place.stop) - - assigns = - assign(assigns, %{ - stop_url: stop_url, - tag_name: if(stop_url, do: "a", else: "div") - }) - ~H"""