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

TCCP: Consolidate card detail headings into macro #8416

Merged
merged 1 commit into from
May 22, 2024

Conversation

chosak
Copy link
Member

@chosak chosak commented May 14, 2024

This commit creates a new data_section macro in the TCCP card details page template, removing some boilerplate used repeatedly to render this page.

See internal https://github.local/Design-Development/Design-Thinking-and-User-Research/issues/306 for context.

How to test this PR

To test, run a local server with the latest data and visit pages like: http://localhost:8000/consumer-tools/credit-cards/explore-cards/cards/vinton-county-national-bank-consumer-credit-card/

Checklist

  • PR has an informative and human-readable title
  • Changes are limited to a single goal (no scope creep)
  • Code follows the standards laid out in the CFPB development guidelines

Comment on lines +47 to +53
<span class="u-visually-hidden">{{ heading }}</span>
</div>
<div
{%- if subheading_classes %} class="{{ subheading_classes }}"{% endif %}
aria-hidden="true"
>
{{- heading -}}
Copy link
Member

Choose a reason for hiding this comment

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

How come there's a visually hidden heading directly above an aria-hidden heading of the same heading value?

Copy link
Member Author

Choose a reason for hiding this comment

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

@niqjohnson? This came from your code. Is this for screenreader support?

Copy link
Member

Choose a reason for hiding this comment

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

I think that came from @contolini's improvements after an accessibility audit. And looking back at older chats, we'd also talked about changing the markup from divs to spans to help a screenreader read the text more naturally. @contolini, when you're back, do you want to take a look at this one?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, it's for assistive technologies. TCCP has a novel visual hierarchy that isn't great for screen readers. Each card's data point has its value appear larger and on a new line above its descriptor, e.g. annual fee:

image

A screenreader reads "$99" and then stops because it's a block level element with no relationship to the next line, "Annual fee". I first tried term and definition roles to improve things but the template ended up rather messy and screenreaders don't have great support for those roles. @niqjohnson had the smart suggestion to use spans but because there's CSS that makes the spans block level, it didn't change the situation. So ultimately the cleanest solution was to add invisible text next to the value so that screenreaders read "$99 Annual fee" when they reach the section.

This commit creates a new `data_section` macro in the TCCP card details
page template, removing some boilerplate used repeatedly to render this
page.

See internal
https://github.local/Design-Development/Design-Thinking-and-User-Research/issues/306
for context.

To test, run a local server with the latest data and visit pages like:
http://localhost:8000/consumer-tools/credit-cards/explore-cards/cards/vinton-county-national-bank-consumer-credit-card/
@chosak chosak force-pushed the tccp/details-heading-macro branch from 5445542 to 8f8379b Compare May 22, 2024 16:09
@chosak chosak added this pull request to the merge queue May 22, 2024
Merged via the queue into main with commit 5d8f881 May 22, 2024
12 checks passed
@chosak chosak deleted the tccp/details-heading-macro branch May 22, 2024 16:57
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.

None yet

4 participants