Skip to content

Commit

Permalink
Merge pull request #8675 from cfpb/tccp-itap
Browse files Browse the repository at this point in the history
TCCP: ITAP Changes
  • Loading branch information
mistergone authored Dec 17, 2024
2 parents 0819480 + 0d94336 commit 1df6966
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 16 deletions.
11 changes: 7 additions & 4 deletions cfgov/tccp/jinja2/tccp/includes/card_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
data-js-hook="behavior_ignore-link-targets"
data-ignore-link-targets="[data-tooltip]"
aria-label="{{ card.product_name }} from {{ card.institution_name }} with {{ card_purchase_apr }} purchase APR, {{ card_account_fee }} account fee, {{ card_rewards(card) }} card rewards{%- if card.requirements_for_opening or card.issued_by_credit_union -%}, eligibility requirements{%- endif -%}"
{% if loop.index == 11 %}data-js-hook="behavior_faded-card" tabindex="-1"{% endif %}
>
<div class="m-card__heading-group">
<h2 class="h3 m-card__heading">{{ card.institution_name }}</h2>
Expand Down Expand Up @@ -102,8 +103,9 @@ <h2 class="h3 m-card__heading">{{ card.institution_name }}</h2>
body=(
'APRs change over time and are '
~ 'specific to the applicant. '
~ 'Check rates before applying.'
)
~ 'Check rates before applying.',
),
tabindex=( loop.index == 11 )
) }}
</span>
</div>
Expand Down Expand Up @@ -171,15 +173,16 @@ <h2 class="h3 m-card__heading">{{ card.institution_name }}</h2>
~ oxfordize(requirement_types)
~ ('. ' if card.geographic_restrictions or card.professional_affiliation)
~ 'See card details for more information.'
)
),
tabindex=( loop.index == 11 )
) }}
</span>
</dd>
</div>
{%- endif -%}
</dl>
<div class="m-card__footer">
<p class="m-card__subtitle">See card details</p>
<p class="m-card__link" data-js-hook="behavior_card-link-proxy" tabindex="{% if loop.index == 11 %}-1{% else %}0{% endif %}">See card details</p>
</div>
</a>
</article>
Expand Down
4 changes: 2 additions & 2 deletions cfgov/tccp/jinja2/tccp/includes/tooltip.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% macro tooltip(name, heading=none, body=none, icon="help-round") -%}
{% macro tooltip(name, heading=none, body=none, icon="help-round", tabindex="0") -%}

<span tabindex="0" data-tooltip>
<span tabindex="{% if tabindex == False %}0{% else %}-1{% endif %}" data-tooltip>
{{ svg_icon(icon) }}
</span>
<template>
Expand Down
17 changes: 8 additions & 9 deletions cfgov/unprocessed/apps/tccp/css/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@
// Disable iOS link highlighting for our large cards
-webkit-tap-highlight-color: transparent;

&:visited .m-card__subtitle {
border-color: $link-underline-visited;
color: $link-text-visited;
&:visited .m-card__link {
border-bottom: 1px dotted $link-underline;
color: $link-text;
}

@include respond-to-min($bp-sm-min) {
Expand All @@ -182,11 +182,6 @@
-2px 0 0 0 inset var(--gray-20);
}

.m-card__subtitle {
border-bottom: 1px solid $link-underline-hover;
color: $link-text-hover;
}

&::after {
content: '';
position: absolute;
Expand All @@ -204,14 +199,18 @@

.m-card__heading {
margin-bottom: 0;
color: var(--gray);
color: var(--black);
font-size: math.div(16px, $base-font-size-px) + rem;
font-weight: 400;
text-transform: uppercase;
}

.m-card__subtitle {
display: inline;
}

.m-card__link {
display: inline;
border-bottom: 1px dotted $link-underline;
color: $link-text;
}
Expand Down
22 changes: 21 additions & 1 deletion cfgov/unprocessed/apps/tccp/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ function init() {
behaviorAttach('submit-situations', 'click', handleFormValidation);
// Attach handler for conditional link targets
behaviorAttach('ignore-link-targets', 'click', handleIgnoreLinkTargets);
// Attach handler for "Enter" on card details link proxy
behaviorAttach('card-link-proxy', 'keydown', handleCardLinkProxies);
// Make the breadcrumb on the details page go back to a filtered list
updateBreadcrumb();
// Move the card ordering dropdown below the expandable
Expand All @@ -38,6 +40,8 @@ function init() {
function initializeAndReport(event) {
initializeTooltips();
reportFilter(event);
// Attach handler for "Enter" on card details link proxy
behaviorAttach('card-link-proxy', 'keydown', handleCardLinkProxies);
}

/**
Expand Down Expand Up @@ -134,7 +138,11 @@ function handleShowMore(event) {
}
const results = document.querySelector('.o-filterable-list-results');
const showMoreFade = document.querySelector('#u-show-more-fade');
const nextResult = document.querySelector('.u-show-more > a');
const nextResult = document.querySelector('[data-js-hook="behavior_faded-card"]');
nextResult.setAttribute('tabIndex', '0');
nextResult.querySelectorAll('[tabindex="-1"]').forEach( elem => {
elem.setAttribute('tabIndex', '0');
});
results.classList.remove('o-filterable-list-results--partial');
showMoreFade.classList.add('u-hidden');
nextResult.focus();
Expand Down Expand Up @@ -175,6 +183,18 @@ function handleFormValidation(event) {
}
}

/**
* Handles "Enter" key on focusable p elements ("card link proxies"). These
* proxies are p elements masquerading as anchor tags.
* @param {Event} event - Keydown event
*/
function handleCardLinkProxies(event) {
if (event.key && event.key === 'Enter') {
const parentAnchor = event.target.closest('a');
parentAnchor.click();
}
}

/**
* Update the breadcrumb on the card details page to point back to the filtered
* list of cards the user came from. We have to do this client-side to prevent
Expand Down

0 comments on commit 1df6966

Please sign in to comment.