Together We’re More Site

5–7 minutes

We launched the new Together We’re More site in early November, 2024! I’m really proud of the way the code was authored, and this site also had a unique challenge to handle accessible design well.

This site, like all sites built by the Choctaw Nation dev team, is built on top of Bootstrap 5 and Advanced Custom Fields.

Accessibility Wins and Learnings

Accessible Animation

On the homepage of the site is a big section with the phrase “We are [word]”, where word falls on the second line and fades in and out with some Javascript. I was curious how macOS VoiceOver read the text aloud, and the short answer was, it didn’t

My next thought was to use aria-live properties to announce the new phrase every time it updated.

const statementContainer = document.getElementById(
	'statement-word'
) as HTMLElement;
const statements = statementContainer
	.getAttribute( 'data-statements' )!
	.split( ',' );
let index = 0;
setInterval( () => {
	// Start Fade-Out transition
	statementContainer.style.transition = 'opacity .5s';
	statementContainer.style.opacity = '0';
    statementContainer.removeAttribute('aria-live');
	// Wait for transition to complete
	setTimeout( () => {
		// Change statement
		statementContainer.textContent = statements[ index ] + '.';
        // Set the aria-live attribute
        statementContainer.setAttribute('aria-live', 'polite');
		// Update index for next iteration
		index = index === statements.length - 1 ? 0 : index + 1;
		// Start Fade-In transition
		statementContainer.style.opacity = '1';
	}, 250 );
}, 2000 );

That didn’t work out either, as the words fade in/out infinitely—while a user was on the home page, every time the word changed a new polite aria announcement would be queued up, regardless of where they were on the page.

The Solve

What I chose to do was to hide the div and paragraph with arai-hidden and place an aria-label on the containing div, so screen readers would simply read the full statement as “We are Artists, Inspiring, Choctaw Proud, etc.”

<?php
$section; // get acf field settings
$statements = array_map( fn( $word ) => esc_textarea( $word['statement'] ), $section['statements'] );
?>
<section class='position-relative py-5 overflow-hidden' id='who-we-are'>
	<div class="container position-relative z-1">
		<div class="row row-cols-1 justify-content-center">
			<div class="col-xl-6 text-center statements" aria-label="We are <?php echo implode( ',', $statements ); ?>">
				<div class="statement text-white text-uppercase fw-bold display-1 ls-2" aria-hidden="true">
					We are
				</div>
				<p class="display-2 text-white text-uppercase" id="statement-word" data-statements="<?php echo implode( ',', $statements ); ?>" aria-hidden="true">
					Choctaw Proud.
				</p>
			</div>
		</div>

Accessible Horizontal Rules

Across the site is a repeated design: two <hr /> elements separated by a triple-diamond svg

a screenshot of the "together we're more" home page where five instances of the horizontal rule and diamond design are visible.

From a code perspective, this design is a single “component” file. (It’s technically a “template-part” in WordPress nomenclature, but it operates more like a JSX component with its use of the “args” parameter). From a screen-reader perspective, it’s kind of a nightmare.

Semantic HTML

To me, it makes sense to define component as 3 parts: a figure with two horizontal rule (<hr /> elements). Since it visually acts as a singe horizontal rule split by three diamonds (and the three diamonds are an inline svg element) I chose to wrap the whole thing in a figure.

<?php
/**
* The basic structure of the component
* without aria attributes
*/
?>
<figure class="<?php echo join( ' ', $classes ); ?>">
	<hr class="<?php echo join( ' ', $hr_classes ); ?>" />
	<div class="diamonds" style="<?php echo "--color:var(--bs-{$color});"; ?>">
		<?php get_template_part( 'template-parts/ui/content', 'diamonds' ); ?>
	</div>
	<hr class="<?php echo join( ' ', $hr_classes ); ?>" />
</figure>

An <hr /> element is read out as “a horizontal splitter,” so since there are two of them wrapped in a figure, VoiceOver + keyboard navigation essentially reads out 4 things:

  1. “Figure. You are curently on a figure”
  2. “Horizontal splitter. You are currently on a horizontal splitter insde of figure.”
  3. “Three diamonds” (this would be definied with aria-label="three diamonds") on the div.diamonds elements
  4. “Horizontal splitter. You are currently on a horizontal splitter insde of figure.”

While that is technically correct in terms of the semantic markup I chose to use, that doesn’t really get to the heart of what’s going on with the design, and it’s super annoying to have to tab through three things to skip past what is essentially a single component.

Semantic HTML + Aria Attributes

I’ve heard you should typically reach for semantic html over aria-label, but this is one of those cases where it made more sense to override the defaults in favor of something that makes more sense. With that in mind, I chose to hide everything inside of the figure with aria-hidden='true' and role my own description with aria-label

<?php
/**
* The final component markup
* with aria attributes
*/
?>
<figure class="<?php echo join( ' ', $classes ); ?>" aria-label="a stylized horizontal splitter with diamonds in the center">
	<hr class="<?php echo join( ' ', $hr_classes ); ?>" aria-hidden="true" />
	<div class="diamonds" style="<?php echo "--color:var(--bs-{$color});"; ?>" aria-hidden="true">
		<?php get_template_part( 'template-parts/ui/content', 'diamonds' ); ?>
	</div>
	<hr class="<?php echo join( ' ', $hr_classes ); ?>" aria-hidden="true" />
</figure>

By choosing this route, I was able to succintly and accurately describe the component as “a stylized horizontal splitter with diamonds in the center,” and I used the same language I heard in VoiceOver to describe the <hr /> element, so that users who use screen readers hopefully hear something that is familiar to them.

Accessible Colors

This site uses 4 main colors associated with the 4 categories a feature could fall under. Of these 4 colors, only 1 (“gold”) has enough contrast on a black background—how they appear on the menu bar on desktop sizes—to meet WCAG contrast guidelines. Using the CSS filter property, I was able to alter the colors just enough to hit the WCAG guidelines without breaking the overall style of menu items (it was important to our creative director that the links be font-weight:400).

filter: brightness(130%) saturate(120%);

This fix is applied on interaction (hover, focus, and active states) as well as when the user is on a category archive page or on a story single (with the .active class). If the .active class is applied, then interaction removes the filter.

Code Authorship Wins

These wins feel big because they get us to contemporary practices of code authorship, but I won’t get into as much detail because they are more common practices. The unique (ish) situation is that it’s with WordPress/php and not a JSX-based front-end framework like React or Vue.

Conclusion

Because of this site, we’ll also be able to federate the current featured person back to the nation site on the homepage which is something I’m particularly excited about.

Although I can take no credit for the design, I’m really proud to be part of building a site that highlights and preserves the Choctaw culture, and doing so in a way that helps my team build quickly and efficiently.