Skip to content
This repository has been archived by the owner on Jun 26, 2018. It is now read-only.

DP-5343 Callout Grid #578

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from
Open

DP-5343 Callout Grid #578

wants to merge 9 commits into from

Conversation

legostud
Copy link
Contributor

Description

  • Refactoring the Key Actions pattern to work within the Action Finder.
  • Updated the Action Finder to use a Comp Heading and Key Actions

Related Issue / Ticket

https://jira.state.ma.us/browse/DP-5343

Steps to Test

  1. Compare http://localhost:3000/?p=organisms-action-finder to http://mayflower.digital.mass.gov/?p=organisms-action-finder
  2. Compare http://localhost:3000/?p=organisms-action-finder-without-background to http://mayflower.digital.mass.gov/?p=organisms-action-finder-without-background
  3. Note that nothing appears different.

Impacted Areas in Application

  • Key Actions - hiding the heading with a new 'hiddenHeading` variable
  • Key Actions - Has a new id variable
  • Action Finder - swapped out the heading for a Comp Heading (twig and json)
  • Action Finder - changed the links to render using Key Actions
  • Action Finder - added a labelledby attribute to the h3 headings.

@todo

  • Should eventually replace the hard coded h3 with a restyled Comp Heading contained in the Key Actions pattern

… throughout page (#518)

* Added an aria-labelledby for the key actions using compHeading.id

* Added id to the key-actions.json

* Added compHeading.id to the sidebar-heading "Key Agencies"

* Removed the aria label from the sidebar-heading

* Updated the comp-heading with modifier class --sidebar

* Moved the 'after' under the --sidebar & .sidebar

* Add modifiers --centered and --sidebar to the comp-header.twig

* Moved the sidebar modifier in the comp-heading.twig

* Removed the compHeading.id from the key-actions.twig

* Removed the center modifiere to h3 header in comp-heading.twig

* DP-3232 - Comp Heading - updates

* DP-3232 - Comp Heading - reverting level headings

* DP-3232 - Key Actions - populating aria-labelled by and removing sidebarheading
Copy link
Contributor

@jesconstantine jesconstantine left a comment

Choose a reason for hiding this comment

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

Great work @legostud -- I looooove using the key actions as a callout grid. I know you did a lot of work with a lot of care to make this backwards compatible and I appreciate it!

I just want to confirm my understanding with the questions below. Maybe you can walk me through it during scrum on Monday?

Thanks :)

<h2 class="ma__action-finder__title">
{{ actionFinder.title }}
</h2>
{# Backward compatible with 5.7 - replaced h2 with compHeading #}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

@@ -3,13 +3,26 @@
{% set keyActions = keyActions|merge({"compHeading": { "title": keyActions.sidebarHeading.title, "sidebar" : true }}) %}
{% endif %}

<section class="ma__key-actions">
{# fallback to compHeading Id value #}
{% set keyActionId = keyActions.compHeading.id %}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we check for keyActions.compHeading.id here first since it's optional?

<div
class="ma__key-actions__items"
{% if keyActionId %}
aria-labelledby="{{ keyActionId }}"
Copy link
Contributor

Choose a reason for hiding this comment

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

I remember talking about the heading / labelledby id stuff, just want to make sure I understand what's happening here:

When key actions is used as a standalone component, it will generally have a compHeading (visual or semantic) with an id, so that is the default / fallback value of keyActionId -- a variable which refers to the id of the thing that describes it.

When key actions is included as a child component (i.e. actionFinder), it does not need to use its compHeading because the parent component could have its own heading and can therefor pass in an id for that heading as keyActions.id (i.e. keyActions|merge({"id": "all-" ~ actionFinder.id, }). This variable assignment happens after the fallback so it will always take precedent if it exists.

Am I understanding this correctly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

correct.

<div class="ma__key-actions__container">
{% if keyActions.compHeading %}
{% set compHeading = keyActions.compHeading %}
{% set compHeading = keyActions.compHeading|merge({"id": keyActionId}) %}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain why this is necessary? (I know we talked about it!) If there is a compHeading.id don't we always want to use that? And if there isn't a compHeading.id isn't it likely that the id was passed in because there is a heading in the parent component that is including this whose id is used in aria-labelledby?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What we want to always use is the keyActions.id value. If that hasn't been passed then we fallback to the compHeading.id. If that hasn't been passed then we fall back to a blank id, because unlabeled is better than mis-labeled.

{% if actionFinder.featuredHeading %}
<h3 class="ma__action-finder__category">{{ actionFinder.featuredHeading }}</h3>
{% endif %}
<div class="ma__action-finder__items">
Copy link
Contributor

Choose a reason for hiding this comment

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

I saw the backwards-compatible scss to support this selector - thank you!

{% endif %}
{% endfor %}
<div class="ma__action-finder__all-items">
{% set keyActions = { "links": actionFinder.links } %}
Copy link
Contributor

Choose a reason for hiding this comment

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

This ensures that the data structure can stay the same - nice!

<h3 class="ma__action-finder__category" id="featured-{{ actionFinder.id }}">{{ actionFinder.featuredHeading }}</h3>
{% set keyActions = keyActions|merge({"id": "featured-" ~ actionFinder.id, }) %}
{% endif %}
{% include "@organisms/by-author/key-actions.twig" %}
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the id for keyActions if we don't have a featuredHeading here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, now I get the other comment. I'll pass the main title's id if we don't have a featured Heading.

{% endfor %}
<div class="ma__action-finder__all-items">
{% set keyActions = { "links": actionFinder.links } %}
{% if actionFinder.generalHeading and actionFinder.featuredLinks %}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why wouldn't we display the generalHeading regardless of whether or not there were featuredLinks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was a design decision. Did really make sense to say "All ..." when there aren't "featured" links above it. The heading just adds confusion.

{{ actionFinder.title }}
</h2>
{# Backward compatible with 5.7 - replaced h2 with compHeading #}
{% set compHeading = actionFinder.compHeading ? : {"title": actionFinder.title, "color":"yellow","id": ""} %}
Copy link
Contributor

@jesconstantine jesconstantine Sep 23, 2017

Choose a reason for hiding this comment

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

Don't we want the title heading to have an id since that could potentially be passed down to the keyActions aria-labelledby (i.e. in the else clause for the general items)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The aria-labelledby id would be the sub heading not the this title.

<h3 class="ma__action-finder__category" id="all-{{ actionFinder.id }}">{{ actionFinder.generalHeading }}</h3>
{% set keyActions = keyActions|merge({"id": "all-" ~ actionFinder.id, }) %}
{% else %}
{% set keyActions = keyActions|merge({"id": actionFinder.id, }) %}
Copy link
Contributor

Choose a reason for hiding this comment

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

This actionFinder.id doesn't currently correspond to a heading, does it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch

@legostud
Copy link
Contributor Author

I think I've address all of the issues here. please feel free to review again

@jesconstantine jesconstantine added this to the 6.0.0 milestone Oct 12, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants