diff --git a/lib/dotcom_web/components/components.ex b/lib/dotcom_web/components/components.ex index f582b5066d..c061dde9c8 100644 --- a/lib/dotcom_web/components/components.ex +++ b/lib/dotcom_web/components/components.ex @@ -11,6 +11,7 @@ defmodule DotcomWeb.Components do endpoint: DotcomWeb.Endpoint, router: DotcomWeb.Router + import DotcomWeb.ViewHelpers, only: [mode_name: 1] import MbtaMetro.Components.Badge, only: [badge: 1] import MbtaMetro.Components.Button, only: [button: 1] import MbtaMetro.Components.Icon, only: [icon: 1] @@ -402,4 +403,35 @@ defmodule DotcomWeb.Components do """ end + + attr :route_type_atom, :atom, required: true + @doc "Renders a banner with a call-to-action to download the MBTA Go app" + def mbta_go_cta(%{route_type_atom: route_type_atom} = assigns) do + assigns = + assigns + |> assign( + :route_type_text, + route_type_atom + |> mode_name() + |> String.downcase() + ) + + ~H""" + + <.icon type="icon-svg" name="icon-mbta-go" class="size-11 shrink-0" aria-hidden /> + + {gettext("Track your %{route_type_text} trip live with the MBTA Go app", + route_type_text: @route_type_text + ) + |> Phoenix.HTML.raw()} + + + + """ + end end diff --git a/lib/dotcom_web/components/departures.ex b/lib/dotcom_web/components/departures.ex new file mode 100644 index 0000000000..533c019f19 --- /dev/null +++ b/lib/dotcom_web/components/departures.ex @@ -0,0 +1,79 @@ +defmodule DotcomWeb.Components.Departures do + @moduledoc """ + Components for showing information about departures in various contexts + """ + use DotcomWeb, :component + + alias DotcomWeb.RouteComponents + + attr :route, Routes.Route, + required: true, + doc: "The route for the departure trip, used to render an icon" + + slot :headsign, + required: true, + doc: "The headsign of the departure, describing the trip destination" + + slot :additional_info, + doc: + "Additional information to display below the headsign, such as a platform name, vehicle name, or train number" + + slot :time, required: true, doc: "The formatted time of the departure." + + @doc """ + Wrapper for a single row of departure information + """ + def departure_heading(assigns) do + ~H""" +