Skip to content

Commit

Permalink
Adds banner type as ARIA label to banner article elements
Browse files Browse the repository at this point in the history
  • Loading branch information
danchamp committed Jul 5, 2024
1 parent f2b9f4e commit e84eddb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions localgov_alert_banner.page.inc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ function template_preprocess_localgov_alert_banner(array &$variables) {
// Type of alert is an optional field and may not exist.
if ($entity->hasField('type_of_alert')) {
$variables['type_of_alert'] = $entity->get('type_of_alert')->value;
$definitions = \Drupal::service('entity_field.manager')->getFieldDefinitions('localgov_alert_banner', 'localgov_alert_banner');
$options = $definitions['type_of_alert']->getSetting('allowed_values');
$variables['type_of_alert_label'] = $options[$variables['type_of_alert']];
}

}
2 changes: 1 addition & 1 deletion templates/localgov-alert-banner.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
]
%}

<article {{ attributes.addClass(classes) }}>
<article {{ attributes.addClass(classes) }} role="region" aria-label="{{ type_of_alert_label }}">
{# Begin Wrapper #}
<div class="localgov-alert-banner__wrapper">
{# Begin Inner #}
Expand Down

0 comments on commit e84eddb

Please sign in to comment.