From 0eb9d168d9f845df759a24d1c256482a36a7ca60 Mon Sep 17 00:00:00 2001 From: Josh Larson Date: Mon, 23 Dec 2024 17:17:21 -0500 Subject: [PATCH] WIP - Make map and results summary sticky --- .../components/trip_planner/input_form.ex | 6 ++- .../trip_planner/results_summary.ex | 6 ++- lib/dotcom_web/live/trip_planner.ex | 50 +++++++++++-------- 3 files changed, 38 insertions(+), 24 deletions(-) diff --git a/lib/dotcom_web/components/trip_planner/input_form.ex b/lib/dotcom_web/components/trip_planner/input_form.ex index 1633ae2859..1556b72985 100644 --- a/lib/dotcom_web/components/trip_planner/input_form.ex +++ b/lib/dotcom_web/components/trip_planner/input_form.ex @@ -16,9 +16,13 @@ defmodule DotcomWeb.Components.TripPlanner.InputForm do Otherwise, we just render the form. """ + + attr :class, :string, default: "" + attr :changeset, :any, required: true + def input_form(assigns) do ~H""" -
+
<.form :let={f} class="md:grid md:grid-cols-2 gap-x-8 gap-y-2" diff --git a/lib/dotcom_web/components/trip_planner/results_summary.ex b/lib/dotcom_web/components/trip_planner/results_summary.ex index f8bb45513e..c6334f1e60 100644 --- a/lib/dotcom_web/components/trip_planner/results_summary.ex +++ b/lib/dotcom_web/components/trip_planner/results_summary.ex @@ -5,6 +5,10 @@ defmodule DotcomWeb.Components.TripPlanner.ResultsSummary do alias Dotcom.TripPlan.InputForm + attr :changeset, :any, required: true + attr :class, :string, default: "" + attr :results, :any, required: true + def results_summary(assigns) do ~H"""
0 || (@changeset.action && @changeset.valid?) } - class="mt-2 mb-6" + class={@class} >

{submission_summary(@changeset.changes)}

{time_summary(@changeset.changes)}

diff --git a/lib/dotcom_web/live/trip_planner.ex b/lib/dotcom_web/live/trip_planner.ex index c9fa1cd0ab..bf62ffbbb7 100644 --- a/lib/dotcom_web/live/trip_planner.ex +++ b/lib/dotcom_web/live/trip_planner.ex @@ -64,30 +64,36 @@ defmodule DotcomWeb.Live.TripPlanner do ~H"""

Trip Planner Preview

- <.input_form changeset={@input_form.changeset} /> - <.results_summary changeset={@input_form.changeset} results={@results} /> -
- <.live_component - module={MbtaMetro.Live.Map} - id="trip-planner-map" - class={[ - "md:order-last", - "h-64 md:h-[32rem] w-full", - @results.itinerary_group_selection == nil && "hidden md:block", - @results.itinerary_group_selection != nil && "block" - ]} - config={@map.config} - lines={@map.lines} - pins={@map.pins} - points={@map.points} - /> - <.results - :if={Enum.count(@results.itinerary_groups) > 0} - class="md:max-w-[25rem]" + <.input_form class="mb-4" changeset={@input_form.changeset} /> +
+ <.results_summary + class="mt-2 mb-6 md:sticky md:top-0 bg-white z-[1000]" + changeset={@input_form.changeset} results={@results} /> +
+ <.live_component + module={MbtaMetro.Live.Map} + id="trip-planner-map" + class={[ + "md:order-last md:sticky md:top-28", + "h-64 md:h-[32rem] w-full", + @results.itinerary_group_selection == nil && "hidden md:block", + @results.itinerary_group_selection != nil && "block" + ]} + config={@map.config} + lines={@map.lines} + pins={@map.pins} + points={@map.points} + /> + <.results + :if={Enum.count(@results.itinerary_groups) > 0} + class="md:max-w-[25rem]" + results={@results} + /> +
"""