Skip to content

Commit

Permalink
combine
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyshull committed Jan 14, 2025
1 parent e20fb10 commit f1c4d43
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions lib/dotcom_web/components/route_symbols.ex
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,13 @@ defmodule DotcomWeb.Components.RouteSymbols do
end
end)

assigns = assign(assigns, :route_label, route_label(route))

~H"""
<.icon
aria-label={@route_label}
role="text"
type="icon-svg"
name={@icon_name}
class={"#{@class} #{@cva_class}"}
aria-label={route_label(@route)}
role="text"
/>
"""
end
Expand All @@ -162,7 +160,7 @@ defmodule DotcomWeb.Components.RouteSymbols do
type="icon-svg"
name={"icon-massport-#{@route_number}"}
class={"#{@class} #{@cva_class}"}
aria-label={"Massport Shuttle #{@route_number}"}
aria-label={route_label(@route)}
role="text"
/>
"""
Expand All @@ -175,20 +173,34 @@ defmodule DotcomWeb.Components.RouteSymbols do
type="icon-svg"
name={"icon-logan-express-#{@route.name}"}
class={"#{@class} #{@cva_class}"}
aria-label="Logan Express"
aria-label={route_label(@route)}
role="text"
/>
"""
end

def route_icon(assigns) do
~H"""
<.icon type="icon-svg" name="icon-mode-shuttle-default" class={"#{@class} #{@cva_class}"} />
<.icon
type="icon-svg"
name="icon-mode-shuttle-default"
class={"#{@class} #{@cva_class}"}
aria-label="Shuttle"
role="text"
/>
"""
end

# Given a route, return a machine-readable label.
defp route_label(%Route{description: :ferry}), do: "Ferry"
defp route_label(%Route{description: :regional_rail}), do: "Commuter Rail"
defp route_label(%Route{external_agency_name: "Logan Express"}), do: "Logan Express"
defp route_label(%Route{id: "Green-" <> branch}), do: "Green Line #{branch} Branch"
defp route_label(%Route{long_name: long_name}), do: long_name

defp route_label(%Route{
external_agency_name: "Massport",
name: <<route_number::binary-size(2), _::binary>>
}),
do: "Massport Shuttle #{route_number}"
end

0 comments on commit f1c4d43

Please sign in to comment.