+ <.transit_place
+ show_leg_line
place={@leg.from}
time={@leg.start}
route={if(match?(%TransitDetail{}, @leg.mode), do: @leg.mode.route)}
alerts={@alerts.from}
/>
-
+
+
+
<%= if Enum.count(@leg.mode.intermediate_stops) < 2 do %>
- <.leg_summary leg={@leg} alerts={@alerts.route} />
- <.leg_details leg={@leg} />
+
+ <.leg_summary leg={@leg} alerts={@alerts.route} />
+ <.leg_details leg={@leg} />
+
<% else %>
-
-
+
+
<.leg_summary leg={@leg} alerts={@alerts.route} />
+
<.icon
- name="chevron-up"
- class="group-open/stops:rotate-180 w-4 h-4 absolute top-3 right-3 fill-brand-primary"
+ name="chevron-down"
+ class="ml-auto shrink-0 w-4 h-4 fill-brand-primary group-open/stops:rotate-180"
/>
<.leg_details leg={@leg} />
<% end %>
- <.place
+
+ <.transit_place
place={@leg.to}
time={@leg.stop}
route={if(match?(%TransitDetail{}, @leg.mode), do: @leg.mode.route)}
@@ -63,12 +75,52 @@ defmodule DotcomWeb.Components.TripPlanner.TransitLeg do
"""
end
+ attr :place, :any, required: true
+ attr :time, :any, required: true
+ attr :route, :any, required: true
+ attr :alerts, :list, required: true
+ attr :show_leg_line, :boolean, default: false
+
+ defp transit_place(assigns) do
+ ~H"""
+
+ <.place
+ time={@time}
+ name={@place.stop.name}
+ accessible={!is_nil(@place.stop) and Stop.accessible?(@place.stop)}
+ url={stop_url(@route, @place.stop)}
+ >
+ <:icon>
+ <.transit_leg_icon route={@route} />
+
+
+
+
+
+
+
+ <.alert :for={alert <- @alerts} alert={alert} />
+
+
+
+ """
+ end
+
+ defp stop_url(%Route{external_agency_name: nil}, %Stop{} = stop) do
+ ~p"/stops/#{stop}"
+ end
+
+ defp stop_url(_, _), do: nil
+
defp leg_line_class(%Route{external_agency_name: "Massport"}) do
- "border-massport"
+ "bg-massport"
end
defp leg_line_class(%Route{external_agency_name: "Logan Express", name: name}) do
- "border-logan-express-#{name}"
+ "bg-logan-express-#{name}"
end
defp leg_line_class(%Route{} = route) do
@@ -76,10 +128,42 @@ defmodule DotcomWeb.Components.TripPlanner.TransitLeg do
|> Route.to_naive()
|> Route.icon_atom()
|> CSSHelpers.atom_to_class()
- |> then(&"border-#{&1}")
+ |> then(&"bg-#{&1}")
+ end
+
+ defp transit_leg_icon(assigns) do
+ name =
+ case Route.vehicle_name(assigns.route) do
+ "Bus" -> "icon-stop-default"
+ _ -> "icon-circle-t-default"
+ end
+
+ assigns = assigns |> assign(:name, name)
+
+ ~H"""
+ <.icon type="icon-svg" class="shrink-0 h-5 w-5" name={@name} />
+ """
end
- defp leg_line_class(_), do: ""
+ defp alert(assigns) do
+ ~H"""
+
+
+ <.icon name="triangle-exclamation" class="h-3 w-3" />
+
+ {Phoenix.Naming.humanize(@alert.effect)}
+
+ Show Details
+
+ Hide Details
+
+
+
+ {@alert.header}
+
+
+ """
+ end
defp leg_summary(assigns) do
assigns =
@@ -88,14 +172,19 @@ defmodule DotcomWeb.Components.TripPlanner.TransitLeg do
|> assign(:headsign, headsign(assigns.leg.mode))
~H"""
-
- <.route_symbol route={@leg.mode.route} />
-
{@headsign}
-
- <.ride_message mode={@leg.mode} />
-
{@stops_count} {Inflex.inflect("stop", @stops_count)}
+
+ <.route_symbol class="shrink-0" route={@leg.mode.route} />
+
+
+ {@headsign}
+
+ <.ride_message mode={@leg.mode} />
+
+ {@stops_count} {Inflex.inflect("stop", @stops_count)}
+
+
+ <.alert :for={alert <- @alerts} alert={alert} />
- <.alert_group class="col-start-2 mb-2 mr-4" alerts={@alerts} />
"""
end
@@ -169,12 +258,12 @@ defmodule DotcomWeb.Components.TripPlanner.TransitLeg do
defp leg_details(assigns) do
~H"""
-