Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add aria labels for itinerary group summaries #2328

Merged
merged 12 commits into from
Jan 17, 2025
Prev Previous commit
Next Next commit
combine
  • Loading branch information
anthonyshull committed Jan 14, 2025
commit f1c4d43e7e619e04a6d8f44dc0e2be9cc153d739
26 changes: 19 additions & 7 deletions lib/dotcom_web/components/route_symbols.ex
Original file line number Diff line number Diff line change
@@ -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
@@ -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"
/>
"""
@@ -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"
thecristen marked this conversation as resolved.
Show resolved Hide resolved
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