Skip to content

Commit

Permalink
Merge branch 'main' into pk/fix-elevator-row-heights
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulJKim committed Jan 30, 2025
2 parents 286c569 + 9f55240 commit b11abd7
Show file tree
Hide file tree
Showing 17 changed files with 93 additions and 111 deletions.
8 changes: 4 additions & 4 deletions assets/css/elevator_v2.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ body {
}
}

.elevator-closures-list,
.current-elevator-closed {
.elevator-alternate-path,
.elevator-closures {
position: relative;
display: flex;
flex-direction: column;
Expand All @@ -69,5 +69,5 @@ body {
}
}

@import "v2/elevator/current_elevator_closed";
@import "v2/elevator/elevator_closures_list";
@import "v2/elevator/alternate_path";
@import "v2/elevator/closures";
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.current-elevator-closed {
.elevator-alternate-path {
position: relative;
height: 100%;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.elevator-closures-list {
.elevator-closures {
display: flex;
flex: 1;
flex-direction: column;
Expand Down
8 changes: 4 additions & 4 deletions assets/src/apps/v2/elevator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import EvergreenContent from "Components/v2/evergreen_content";
import ScreenPage from "Components/v2/screen_page";
import { MappingContext } from "Components/v2/widget";
import MultiScreenPage from "Components/v2/multi_screen_page";
import ElevatorClosuresList from "Components/v2/elevator/elevator_closures_list";
import CurrentElevatorClosed from "Components/v2/elevator/current_elevator_closed";
import Closures from "Components/v2/elevator/closures";
import AlternatePath from "Components/v2/elevator/alternate_path";
import SimulationScreenPage from "Components/v2/simulation_screen_page";
import Footer from "Components/v2/elevator/footer";
import NormalHeader from "Components/v2/normal_header";
Expand All @@ -25,8 +25,8 @@ import NoData from "Components/v2/elevator/no_data";
const TYPE_TO_COMPONENT = {
normal: NormalScreen,
takeover: TakeoverScreen,
elevator_closures_list: ElevatorClosuresList,
current_elevator_closed: CurrentElevatorClosed,
elevator_closures: Closures,
elevator_alternate_path: AlternatePath,
evergreen_content: EvergreenContent,
footer: Footer,
normal_header: NormalHeader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import CurrentLocationBackground from "Images/svgr_bundled/current-location-back
import NoService from "Images/svgr_bundled/no-service-black.svg";
import ElevatorWayfinding from "Images/svgr_bundled/elevator-wayfinding.svg";
import IsaNegative from "Images/svgr_bundled/isa-negative.svg";
import { CURRENT_CLOSED_PAGING_INTERVAL_MS } from "./elevator_constants";
import { ALTERNATE_PATH_PAGING_INTERVAL_MS } from "./constants";

type Coordinates = {
x: number;
Expand All @@ -35,7 +35,7 @@ interface Props extends WrappedComponentProps {
accessible_path_image_here_coordinates: Coordinates;
}

const CurrentElevatorClosed = ({
const AlternatePath = ({
alternate_direction_text: alternateDirectionText,
accessible_path_direction_arrow: accessiblePathDirectionArrow,
accessible_path_image_url: accessiblePathImageUrl,
Expand All @@ -45,7 +45,7 @@ const CurrentElevatorClosed = ({
const numPages = accessiblePathImageUrl ? 2 : 1;
const pageIndex = useIntervalPaging({
numPages,
intervalMs: CURRENT_CLOSED_PAGING_INTERVAL_MS,
intervalMs: ALTERNATE_PATH_PAGING_INTERVAL_MS,
updateVisibleData,
});

Expand All @@ -56,7 +56,7 @@ const CurrentElevatorClosed = ({
});

return (
<div className="current-elevator-closed">
<div className="elevator-alternate-path">
<div className="notch"></div>
<div className="header">
<div className="icons">
Expand Down Expand Up @@ -103,5 +103,5 @@ const CurrentElevatorClosed = ({
};

export default makePersistent(
CurrentElevatorClosed as ComponentType<WrappedComponentProps>,
AlternatePath as ComponentType<WrappedComponentProps>,
);
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import useIntervalPaging from "Hooks/v2/use_interval_paging";
import NormalService from "Images/svgr_bundled/normal-service.svg";
import AccessibilityAlert from "Images/svgr_bundled/accessibility-alert.svg";
import { CLOSURE_LIST_PAGING_INTERVAL_MS } from "./elevator_constants";
import { CLOSURES_PAGING_INTERVAL_MS } from "./constants";

interface ClosureRowProps {
station: StationWithClosures;
Expand Down Expand Up @@ -105,16 +105,16 @@ const InStationSummary = ({ closures }: InStationSummaryProps) => {
);
};

interface OutsideClosureListProps extends WrappedComponentProps {
interface CurrentClosuresProps extends WrappedComponentProps {
stations: StationWithClosures[];
stationId: string;
}

const OutsideClosureList = ({
const CurrentClosures = ({
stations,
stationId,
updateVisibleData,
}: OutsideClosureListProps) => {
}: CurrentClosuresProps) => {
const ref = useRef<HTMLDivElement>(null);

const sortedStations = [...stations].sort((a, b) => {
Expand All @@ -140,7 +140,7 @@ const OutsideClosureList = ({

const pageIndex = useIntervalPaging({
numPages,
intervalMs: CLOSURE_LIST_PAGING_INTERVAL_MS,
intervalMs: CLOSURES_PAGING_INTERVAL_MS,
updateVisibleData,
});

Expand Down Expand Up @@ -226,19 +226,19 @@ interface Props extends WrappedComponentProps {
station_id: string;
}

const ElevatorClosuresList = ({
const Closures = ({
stations_with_closures: stations,
station_id: stationId,
updateVisibleData,
}: Props) => {
return (
<div className="elevator-closures-list">
<div className="elevator-closures">
<InStationSummary
closures={stations
.filter((s) => s.id === stationId)
.flatMap((s) => s.closures)}
/>
<OutsideClosureList
<CurrentClosures
stations={stations}
stationId={stationId}
updateVisibleData={updateVisibleData}
Expand All @@ -247,6 +247,4 @@ const ElevatorClosuresList = ({
);
};

export default makePersistent(
ElevatorClosuresList as ComponentType<WrappedComponentProps>,
);
export default makePersistent(Closures as ComponentType<WrappedComponentProps>);
2 changes: 2 additions & 0 deletions assets/src/components/v2/elevator/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const ALTERNATE_PATH_PAGING_INTERVAL_MS = 12000; // 12 seconds
export const CLOSURES_PAGING_INTERVAL_MS = 8000; // 8 seconds
2 changes: 0 additions & 2 deletions assets/src/components/v2/elevator/elevator_constants.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions lib/screens/v2/candidate_generator/elevator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ defmodule Screens.V2.CandidateGenerator.Elevator do
@moduledoc false

alias Screens.V2.CandidateGenerator
alias Screens.V2.CandidateGenerator.Elevator.Closures, as: ElevatorClosures
alias Screens.V2.CandidateGenerator.Elevator.Closures
alias Screens.V2.CandidateGenerator.Widgets.Evergreen
alias Screens.V2.Template.Builder

@behaviour CandidateGenerator

@instance_fns [
&ElevatorClosures.elevator_status_instances/2,
&Closures.elevator_status_instances/2,
&Evergreen.evergreen_content_instances/2
]

Expand Down
26 changes: 9 additions & 17 deletions lib/screens/v2/candidate_generator/elevator/closures.ex
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
defmodule Screens.V2.CandidateGenerator.Elevator.Closures do
@moduledoc """
Generates the standard widgets for elevator screens: `CurrentElevatorClosed` when the screen's
elevator is closed, otherwise `ElevatorClosuresList`. Includes the header and footer, as these
have different variants depending on the "main" widget.
Generates the standard widgets for elevator screens: `ElevatorAlternatePath` when the screen's
elevator is closed, otherwise `ElevatorClosures`. Includes the header and footer, as these have
different variants depending on the "main" widget.
"""

defmodule Closure do
Expand Down Expand Up @@ -31,16 +31,8 @@ defmodule Screens.V2.CandidateGenerator.Elevator.Closures do
alias Screens.Routes.Route
alias Screens.Stops.Stop
alias Screens.V2.WidgetInstance
alias Screens.V2.WidgetInstance.{Footer, NormalHeader}

alias Screens.V2.WidgetInstance.{
CurrentElevatorClosed,
ElevatorClosuresList,
Footer,
NormalHeader
}

alias Screens.V2.WidgetInstance.Elevator.Closure, as: WidgetClosure
alias Screens.V2.WidgetInstance.{ElevatorAlternatePath, ElevatorClosures, Footer, NormalHeader}
alias Screens.V2.WidgetInstance.Serializer.RoutePill
alias ScreensConfig.Screen
alias ScreensConfig.V2.Elevator, as: ElevatorConfig
Expand All @@ -67,11 +59,11 @@ defmodule Screens.V2.CandidateGenerator.Elevator.Closures do

case Enum.find(closures, fn %Closure{id: id} -> id == elevator_id end) do
nil ->
[elevator_closures_list(closures, app_params) | header_footer_instances(config, now)]
[elevator_closures(closures, app_params) | header_footer_instances(config, now)]

_closure ->
[
%CurrentElevatorClosed{app_params: app_params}
%ElevatorAlternatePath{app_params: app_params}
| header_footer_instances(config, now, :closed)
]
end
Expand Down Expand Up @@ -112,15 +104,15 @@ defmodule Screens.V2.CandidateGenerator.Elevator.Closures do

defp elevator_closure(_alert), do: []

defp elevator_closures_list(
defp elevator_closures(
closures,
%ElevatorConfig{elevator_id: elevator_id} = app_params
) do
{:ok, %Stop{id: stop_id}} = @facility.fetch_stop_for_facility(elevator_id)
{:ok, station_names} = @stop.fetch_parent_station_name_map()
station_route_pills = fetch_station_route_pills(closures, stop_id)

%ElevatorClosuresList{
%ElevatorClosures{
app_params: app_params,
station_id: stop_id,
stations_with_closures:
Expand Down Expand Up @@ -149,7 +141,7 @@ defmodule Screens.V2.CandidateGenerator.Elevator.Closures do
|> Enum.filter(&relevant_closure?(&1, home_station_id, closures))
|> Enum.group_by(& &1.station_id)
|> Enum.map(fn {station_id, station_closures} ->
%ElevatorClosuresList.Station{
%ElevatorClosures.Station{
id: station_id,
name: Map.fetch!(station_names, station_id),
route_icons:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
defmodule Screens.V2.WidgetInstance.CurrentElevatorClosed do
@moduledoc false
defmodule Screens.V2.WidgetInstance.ElevatorAlternatePath do
@moduledoc "The main content of an elevator screen when its associated elevator is closed."

alias Screens.Util.Assets
alias ScreensConfig.V2.Elevator
Expand Down Expand Up @@ -28,16 +28,16 @@ defmodule Screens.V2.WidgetInstance.CurrentElevatorClosed do
}

defimpl Screens.V2.WidgetInstance do
alias Screens.V2.WidgetInstance.CurrentElevatorClosed
alias Screens.V2.WidgetInstance.ElevatorAlternatePath

def priority(_instance), do: [1]
def serialize(instance), do: CurrentElevatorClosed.serialize(instance)
def serialize(instance), do: ElevatorAlternatePath.serialize(instance)
def slot_names(_instance), do: [:main_content]
def widget_type(_instance), do: :current_elevator_closed
def widget_type(_instance), do: :elevator_alternate_path
def valid_candidate?(_instance), do: true
def audio_serialize(_instance), do: %{}
def audio_sort_key(_instance), do: [0]
def audio_valid_candidate?(_instance), do: false
def audio_view(_instance), do: ScreensWeb.V2.Audio.CurrentElevatorClosedView
def audio_view(_instance), do: ScreensWeb.V2.Audio.ElevatorAlternatePathView
end
end
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
defmodule Screens.V2.WidgetInstance.ElevatorClosuresList do
@moduledoc false
defmodule Screens.V2.WidgetInstance.ElevatorClosures do
@moduledoc "The main content of an elevator screen when its associated elevator is working."

alias Screens.Stops.Stop
alias Screens.V2.WidgetInstance.Elevator.Closure
Expand Down Expand Up @@ -44,16 +44,16 @@ defmodule Screens.V2.WidgetInstance.ElevatorClosuresList do
}

defimpl Screens.V2.WidgetInstance do
alias Screens.V2.WidgetInstance.ElevatorClosuresList
alias Screens.V2.WidgetInstance.ElevatorClosures

def priority(_instance), do: [1]
def serialize(instance), do: ElevatorClosuresList.serialize(instance)
def serialize(instance), do: ElevatorClosures.serialize(instance)
def slot_names(_instance), do: [:main_content]
def widget_type(_instance), do: :elevator_closures_list
def widget_type(_instance), do: :elevator_closures
def valid_candidate?(_instance), do: true
def audio_serialize(_instance), do: %{}
def audio_sort_key(_instance), do: [0]
def audio_valid_candidate?(_instance), do: false
def audio_view(_instance), do: ScreensWeb.V2.Audio.ElevatorClosuresListView
def audio_view(_instance), do: ScreensWeb.V2.Audio.ElevatorClosuresView
end
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule ScreensWeb.V2.Audio.CurrentElevatorClosedView do
defmodule ScreensWeb.V2.Audio.ElevatorAlternatePathView do
use ScreensWeb, :view

def render("_widget.ssml", _) do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule ScreensWeb.V2.Audio.ElevatorClosuresListView do
defmodule ScreensWeb.V2.Audio.ElevatorClosuresView do
use ScreensWeb, :view

def render("_widget.ssml", _) do
Expand Down
Loading

0 comments on commit b11abd7

Please sign in to comment.