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

Refactor: agency selection frontend #1206

Merged
merged 30 commits into from
Jan 26, 2023
Merged

Conversation

angela-tran
Copy link
Member

@angela-tran angela-tran commented Jan 19, 2023

Closes #1197
Closes #1214

This PR implements the designs from #1090.

The overall approach here was to use Bootstrap's Modal component in a Django template that can be extended. A template called agency-selector.html then extends modal.html and handles defining the cards. It is used specifically by the core/index.html template.

@angela-tran angela-tran self-assigned this Jan 19, 2023
@github-actions github-actions bot added front-end HTML/CSS/JavaScript and Django templates back-end Django views, sessions, middleware, models, migrations etc. i18n Copy: Language files or Django i18n framework deployment-dev [auto] Changes that will trigger a deploy if merged to dev labels Jan 19, 2023
@angela-tran
Copy link
Member Author

angela-tran commented Jan 19, 2023

This is still a work-in-progress due to some minor questions / fixes needed, but here are some screenshots of it so far:

Screenshots

Screen size Indirect Entry (Index) / Modal is open Hovering over a card
Desktop 01_index 02_modal_open 03_modal_hoverd
Mobile localhost_11369_(iPhone SE) (0) localhost_11369_(iPhone SE) (1) localhost_11369_(iPhone SE) (2)

GIFs

Desktop Mobile
modal-desktop modal-mobile

Questions for @srhhnry:

  • Does the faded background and animation look ok to you? It's just the default from Bootstrap. It doesn't match what's currently in Figma exactly, but you were saying you wanted to see what Bootstrap does.
  • I exported the logos from Figma and noticed the MST logo in the mobile designs is truncated (some of the text in "Monterey-Salinas Transit" is cut off). Is that easy for you to fix? Once it's updated, I'll re-export it.

image

@angela-tran angela-tran force-pushed the refactor/agency-selection-frontend branch from 4894ec0 to d0b5892 Compare January 19, 2023 18:28
@srhhnry
Copy link

srhhnry commented Jan 19, 2023

Thoughts:

  1. The bootstrap default animation looks just fine to me. We're just visually indicating to the user that the rest of the screen is inactive. Also, the rest of the screen should be inactive (I'm assuming that's standard bootstrap modal/lightbox behavior).

  2. Ideally we should get logo assets from the agencies. As we haven't done this before, there's a bit of a workflow issue there (e.g. does product handle that? Customer relations? Design? Unclear). But I pulled those logos from the internet, and I'm not 100% sure they are robust enough for an actual site (they work for Figma screens, but may not have the fidelity for say, a 49 inch monitor). I'll ask around for how we get those assets.

  3. Choose Your Provider CTA on desktop should be justified left to align with the copy--this is an update from the previous iteration of the home page.

  4. The mobile CTA and header (within the white box) looks a little low--the hero image feels like it's taking up a lot of real estate, causing the user to have to scroll to see the full context for the page. In the Figma boards the white box starts about midway up the Visa CC (instead of at the bottom)

image

Possible to move the box/header/CTA up? Expected behavior would be the user can see the CTA button without having to scroll.

@srhhnry
Copy link

srhhnry commented Jan 19, 2023

Oh, and I fixed the MST logo on the Mobile board (it was filling the image instead of fitting to the box!) so at the very least it's not cut off anymore. Standing by on logo assets though.

@angela-tran
Copy link
Member Author

  1. ... Also, the rest of the screen should be inactive (I'm assuming that's standard bootstrap modal/lightbox behavior).

Currently I have it configured so that if the user clicks outside the modal dialog, it closes. Bootstrap also gives us the option to not do anything in that case (the user would have to click the "X" to close the modal dialog).

  1. Choose Your Provider CTA on desktop should be justified left to align with the copy--this is an update from the previous iteration of the home page.
  2. The mobile CTA and header (within the white box) looks a little low--the hero image feels like it's taking up a lot of real estate, causing the user to have to scroll to see the full context for the page. In the Figma boards the white box starts about midway up the Visa CC (instead of at the bottom)

Thanks for pointing these out @srhhnry! I'll look into making these changes.

@srhhnry
Copy link

srhhnry commented Jan 19, 2023

Currently I have it configured so that if the user clicks outside the modal dialog, it closes. Bootstrap also gives us the option to not do anything in that case (the user would have to click the "X" to close the modal dialog).

Yup! That's perfect. Usually more savvy users will click outside the modal whereas less savvy will look for the X. Having both is great.

@angela-tran angela-tran force-pushed the refactor/agency-selection-frontend branch from 10c0be7 to 45e86f9 Compare January 19, 2023 21:48
Copy link
Member

@machikoyasuda machikoyasuda left a comment

Choose a reason for hiding this comment

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

I'm going through the modal user experience with an eye on accessibility (keyboard only, keyboard shortcuts) and matching the mocks.

These flows all work:

  • Use tab to get focus ring on CTA. Then, use enter or space to open the modal. ✅
  • Once modal is open, and nothing is in focus, use escape to exit modal. ✅
  • Once modal is open, press tab. The first icon in focus is the X. Use either space or enter on the focused X to exit modal. ✅
  • Once modal is open, press tab twice. The MST button is selected. Use either space or enter get to MST (or SacRT). ✅

The one thing missing: There needs to be a focus ring around the whole button very clearly. We don't have designs for it necessary @srhhnry but we can use default (from our styles)

image

or @srhhnry can design something custom.

Looking more deeply into the way the card link is constructed, it might be tricky (but not impossible) to style the "invisble" linke to not look like below on focus, but rather a ring that goes around the entire card.
image

Resources:
https://www.sarasoueidan.com/blog/focus-indicators/#new-focus-indicator-accessibility-requirements-in-wcag-2.2
https://www.smashingmagazine.com/2021/03/complete-guide-accessible-front-end-components/#accessible-focus-styles

@machikoyasuda
Copy link
Member

@angela-tran Thinking about the HTML structure of the MST and SacRT components more, I think it should/could all be a <button> with an image inside, rather than a card. How I'd approach it: https://www.sarasoueidan.com/blog/accessible-icon-buttons/#icon-sitting-next-to-text

height="74"
alt="{% blocktranslate with agency_short_name=agency.short_name %}core.pages.index.agency_selector{{ agency_short_name }}{% endblocktranslate %}">
<h4 class="card-title mt-lg-3 mb-0 mb-lg-3">{{ agency.long_name }}</h4>
<a href="{{ agency.eligibility_index_url }}" class="stretched-link"></a>
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if there's a way to move this link or add styles to it so this link does not affect the height/flow of the parent div. Also, I wonder if there's a way to add styles so that the focus ring of this link borders the entire div cleanly.

Copy link
Member

Choose a reason for hiding this comment

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

Similarly, this link needs to at least wrap the h4 text, we shouldn't have a link with no text content.

Copy link
Member

Choose a reason for hiding this comment

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

FWIW @machikoyasuda I think this stretched-link utility is the right way to do this for cards in Bootstrap: https://getbootstrap.com/docs/4.6/utilities/stretched-link/

But we do need text content in the link

Copy link
Member

@thekaveman thekaveman left a comment

Choose a reason for hiding this comment

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

+1 to also needing a solution for the focus state on each card when navigating by keyboard.

@angela-tran angela-tran force-pushed the refactor/agency-selection-frontend branch from c1347be to 4719906 Compare January 26, 2023 02:34
@angela-tran
Copy link
Member Author

@angela-tran Thinking about the HTML structure of the MST and SacRT components more, I think it should/could all be a <button> with an image inside, rather than a card. How I'd approach it: https://www.sarasoueidan.com/blog/accessible-icon-buttons/#icon-sitting-next-to-text

I read through that article, and I can see some benefit to switching it to a <button> (mostly that screenreaders would read it as an actual button?). I'm not sure how much time we have to make the switch, so maybe this is a refactor we could take on after the initial release?

I will definitely work on fixing the focus style with the suggestion you sent me in Slack @machikoyasuda.

@angela-tran
Copy link
Member Author

angela-tran commented Jan 26, 2023

So @thekaveman and @machikoyasuda , I tried each of your suggestions. The similarities between the two are that

  • the tab focus ring does not cause the text to shift ✅
  • I could not find a way to change the style of the focus ring (it seems browser-defined)

Here's what they each looked like:

Use stretched-link class on <a> element which wraps <h4>

Code snippet

<div class="card mt-lg-4 mx-lg-auto">
    <div class="card-body d-flex flex-row-reverse flex-lg-column justify-content-center align-items-center">
        <img class="sm d-lg-none ms-auto"
             src="{% get_static_prefix %}img/agencies/{{ agency.slug }}-sm.svg"
             width="46"
             height="29"
             alt="{% blocktranslate with agency_short_name=agency.short_name %}core.pages.index.agency_selector{{ agency_short_name }}{% endblocktranslate %}">
        <img class="lg d-none d-lg-block mt-lg-3 mx-lg-auto"
             src="{% get_static_prefix %}img/agencies/{{ agency.slug }}-lg.svg"
             width="117"
             height="74"
             alt="{% blocktranslate with agency_short_name=agency.short_name %}core.pages.index.agency_selector{{ agency_short_name }}{% endblocktranslate %}">
        <a href="{{ agency.eligibility_index_url }}" class="stretched-link"><h4 class="card-title mt-lg-3 mb-0 mb-lg-3">{{ agency.long_name }}</h4></a>
    </div>
</div>

Screenshots

Chrome Firefox
image image

Make the element with card class an <a> instead of <div>

Code

See 801b57c

Screenshots

Chrome Firefox
image image

I went with the latter suggestion because it puts the focus ring around the whole card.

Let me know if there's something I'm missing re: styling the focus ring.

@machikoyasuda machikoyasuda self-requested a review January 26, 2023 18:50
@machikoyasuda
Copy link
Member

@angela-tran this is looking good!

one small thing to add: remove the underline when hovered - by adding custom style for .card:hover
image

Copy link
Member

@thekaveman thekaveman left a comment

Choose a reason for hiding this comment

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

Thanks for the changes, this looks good to me.

Copy link
Member

@machikoyasuda machikoyasuda left a comment

Choose a reason for hiding this comment

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

LGTM! ✨ ✨ 🚀

@srhhnry
Copy link

srhhnry commented Jan 26, 2023

Catching up on this thread. It sounds like the focus ring can't be designed? And is set by the browser?

In case that's not the case, my suggestion would be to keep the behavior fairly close to default, with the exception being the use of our blue (#046b99) for the focus outline. To get real fancy, I'd suggest the hover color (#2f4c65) when selecting the agency button.

@angela-tran
Copy link
Member Author

Catching up on this thread. It sounds like the focus ring can't be designed? And is set by the browser?

In case that's not the case, my suggestion would be to keep the behavior fairly close to default, with the exception being the use of our blue (#046b99) for the focus outline. To get real fancy, I'd suggest the hover color (#2f4c65) when selecting the agency button.

Yeah, so the cards are <a> elements (links), which are styled by the browser when given focus. For example, try tabbing around the links on http://info.cern.ch/.

@angela-tran
Copy link
Member Author

If we'd like to revisit the focus ring styling and using <a> vs. <button> for the cards, I recommend we create new issues for those topics. I'll go ahead and merge in this PR's changes.

@angela-tran angela-tran merged commit dfaaafc into dev Jan 26, 2023
@angela-tran angela-tran deleted the refactor/agency-selection-frontend branch January 26, 2023 20:15
@srhhnry
Copy link

srhhnry commented Jan 26, 2023

Sounds good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
back-end Django views, sessions, middleware, models, migrations etc. deployment-dev [auto] Changes that will trigger a deploy if merged to dev front-end HTML/CSS/JavaScript and Django templates i18n Copy: Language files or Django i18n framework
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use approved logos for transit agencies Implement Agency Selection page
4 participants