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

feat: Arrange map and plan results correctly on desktop and mobile #2240

Merged
merged 8 commits into from
Dec 2, 2024

Conversation

joshlarson
Copy link
Contributor

Mobile

Before

Screenshot 2024-11-29 at 12 51 00 PM Screenshot 2024-11-29 at 12 51 09 PM

After

Screenshot 2024-11-29 at 12 47 43 PM Screenshot 2024-11-29 at 12 48 03 PM

Desktop

Looks pretty much the same


Asana Ticket: Trip Planner Preview | Scaffold out the responsive mobile/desktop layout

@joshlarson joshlarson requested a review from a team as a code owner November 29, 2024 17:57
@@ -181,10 +181,6 @@ $mobile-control-height: 73px;
cursor: pointer;
}

.hidden {
display: none !important;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like it could be a big risky change, but also this utility was overriding the tailwind utility that does the same thing (except that the tailwind utility doesn't have !important anymore, since we removed that here).

Interested in your thoughts on getting rid of this, and whether there's another way to get tailwind to conditionally give us display: none in the right settings.

target={@myself}
/>
<div>
<section class={"flex flex-col md:grid #{@grid_column_layout} md:grid-rows-[min-content_1fr] w-full border border-solid border-slate-400"}>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could also see a world in which this was a grid on both desktop and mobile, just with a different template, and different row-start/row-span/etc for the grid entries, but this felt easier as I was building it. This way, lexically the pieces are arranged according to the mobile design, and then on desktop, they get placed onto the grid instead, and their lexical ordering is ignored.

Open to feedback/ideas on this.

/>
</section>
<.async_result :let={results} assign={@results}>
<div
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This added some extra spacing between View all options and the content below it.

I'm currently leaning towards leaving it as-is for this PR, and fixing it, as well as a bunch of other minor visual issues as a follow-up.

~H"""
<section class="flex w-full border border-solid border-slate-400">
<section class={"flex flex-col md:grid #{@grid_column_layout} md:grid-rows-[min-content_1fr] w-full border border-solid border-slate-400"}>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could also see a world in which this was a grid on both desktop and mobile, just with a different template, and different row-start/row-span/etc for the grid entries, but this felt easier as I was building it. This way, lexically the pieces are arranged according to the mobile design, and then on desktop, they get placed onto the grid instead, and their lexical ordering is ignored.

Open to feedback/ideas on this.

(This was originally this comment, but got outdated when I changed the spacing, and is still relevant)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably a cleaner way to optionally assign classes than using case statements: https://github.com/mbta/mbta_metro/blob/8c01cc9b8bbd6018daea506b19a24e7b10ae95ae/lib/mbta_metro/components/flash.ex#L46

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, that is cleaner.

class="row-span-2"
/>

<.async_result :let={results} assign={@results}>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something about how I re-arranged the DOM elements added some extra spacing between View all options and the content below it.

I'm currently leaning towards leaving it as-is for this PR, and fixing it, as well as a bunch of other minor visual issues as a follow-up.

Copy link
Contributor

@anthonyshull anthonyshull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something we could look out for in the future: if we're wrapping a component in another component just to set the value of an attribute, that attribute can be set in the component directly.

~H"""
<section class="flex w-full border border-solid border-slate-400">
<section class={"flex flex-col md:grid #{@grid_column_layout} md:grid-rows-[min-content_1fr] w-full border border-solid border-slate-400"}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably a cleaner way to optionally assign classes than using case statements: https://github.com/mbta/mbta_metro/blob/8c01cc9b8bbd6018daea506b19a24e7b10ae95ae/lib/mbta_metro/components/flash.ex#L46

map_config={@map_config}
from={@from}
to={@to}
hide_on_mobile={@expanded_itinerary_index == nil}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of wrapping the map in another component and passing in this attribute, you could use the same ternary trick from above:

~H"""
  <.live_component
    module={MbtaMetro.Live.Map}
    id="trip-planner-map"
    class={[
      "h-64 md:h-96 w-full relative overflow-none",
      @expanded_itinerary_index == nil && "hidden md:block"
    ]}
    config={@map_config}
    pins={[@from, @to]}
  />
  """

@joshlarson joshlarson merged commit c184f1a into main Dec 2, 2024
17 checks passed
@joshlarson joshlarson deleted the jdl/trip-planner-details-responsive-layout branch December 2, 2024 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants