Skip to content

Commit

Permalink
Accessibility fixes for #276
Browse files Browse the repository at this point in the history
* Remove role main from main elements

* Follow _s lead, change widget titles to h2

* Extend h3 class on widget titles by default, but use !optional, since the class is currently blank

* Remove the cancel reply link from the leave reply heading

* Add hidden h2 to mark the comment section, update child headings accordingly

* Compiled styles

* Add script to fix main nav submenus

* Add base styles for the caret-down icon

* Compiled files

* Fix contrast on comment meta text

* Darken $color-blue ever so slightly for contrast

* Compiled styles
  • Loading branch information
Cheffheid authored and gregrickaby committed Jun 20, 2017
1 parent 597747b commit c2b719a
Show file tree
Hide file tree
Showing 20 changed files with 163 additions and 24 deletions.
2 changes: 1 addition & 1 deletion 404.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<div class="wrap">
<div class="primary content-area">
<main id="main" class="site-main" role="main">
<main id="main" class="site-main">

<section class="error-404 not-found">
<header class="page-header">
Expand Down
2 changes: 1 addition & 1 deletion archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<div class="wrap">
<div class="primary content-area">
<main id="main" class="site-main" role="main">
<main id="main" class="site-main">

<?php
if ( have_posts() ) : ?>
Expand Down
2 changes: 1 addition & 1 deletion assets/sass/modules/_comments.scss
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
margin-top: rem(5);

a {
color: $color-silver-chalice;
color: $color-tundora;
text-decoration: none;
} // a

Expand Down
14 changes: 14 additions & 0 deletions assets/sass/modules/_icons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,17 @@
transform: rotate(-225deg);
}
} // .down-arrow


//-----------------------------------------
// Caret down
//-----------------------------------------
.caret-down {
@include size(rem(10) rem(20));

background: url('assets/images/svg-icons/caret-down.svg') no-repeat transparent;
background-size: 100%;
margin-left: rem(5);
display: inline-block;
vertical-align: middle;
} // .angle-down
3 changes: 2 additions & 1 deletion assets/sass/utilities/variables/_colors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// COLORS

// Primary palette
$color-blue: #21759b;
$color-blue: #20739A;
$color-light-yellow: #fff9c0;
$color-black: #000;
$color-white: #fff;
Expand All @@ -23,6 +23,7 @@ $color-white: #fff;
$color-gray: #808080;
$color-cod-gray: #111;
$color-mineshaft: #333;
$color-tundora: #454545;
$color-dove-gray: #666;
$color-gray-alt: #929292;
$color-silver-chalice: #aaa;
Expand Down
5 changes: 5 additions & 0 deletions assets/sass/widgets/_widgets.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
select {
max-width: 100%;
} // select

// Extend the h3 style for the widget titles.
.widget-title {
@extend .h3 !optional;
} // .widget-title
} // .widget

// Search widget.
Expand Down
51 changes: 51 additions & 0 deletions assets/scripts/concat/navigation-primary.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* File: navigation-primary.js
*
* Helpers for the primary navigation.
*/
window.wdsPrimaryNavigation = {};
( function( window, $, app ) {

// Constructor.
app.init = function() {
app.cache();

if ( app.meetsRequirements() ) {
app.bindEvents();
}
};

// Cache all the things.
app.cache = function() {
app.$c = {
window: $( window ),
subMenuContainer: $( '.main-navigation .sub-menu' ),
subMenuParentItem: $( '.main-navigation li.menu-item-has-children' )
};
};

// Combine all events.
app.bindEvents = function() {
app.$c.window.on( 'load', app.addDownArrow );
app.$c.subMenuParentItem.find( 'a' ).on( 'focusin focusout', app.toggleFocus );
};

// Do we meet the requirements?
app.meetsRequirements = function() {
return app.$c.subMenuContainer.length;
};

// Add the down arrow to submenu parents.
app.addDownArrow = function() {
app.$c.subMenuParentItem.find( '> a' ).append( '<span class="caret-down" aria-hidden="true"></span>' );
};

// Toggle the focus class on the link parent.
app.toggleFocus = function() {
$( this ).parents( 'li.menu-item-has-children' ).toggleClass( 'focus' );
};

// Engage!
$( app.init );

})( window, jQuery, window.wdsPrimaryNavigation );
54 changes: 53 additions & 1 deletion assets/scripts/project.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/scripts/project.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion buddypress.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<div class="wrap">
<div class="primary content-area">
<main id="main" class="site-main" role="main">
<main id="main" class="site-main">

<?php while ( have_posts() ) :
the_post(); ?>
Expand Down
7 changes: 4 additions & 3 deletions comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
?>

<div id="comments" class="comments-area">
<h2 class="screen-reader-text"><?php esc_html_e( 'Comment section', '_s' ); ?></h2>

<?php
// You can start editing here -- including this comment!
if ( have_comments() ) : ?>
<h2 class="comments-title">
<h3 class="comments-title">
<?php
printf( // WPCS: XSS OK.
/* translators: the number of comments */
Expand All @@ -34,11 +35,11 @@
'<span>' . get_the_title() . '</span>'
);
?>
</h2>
</h3>

<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>
<nav id="comment-nav-above" class="navigation comment-navigation" role="navigation">
<h2 class="screen-reader-text"><?php esc_html_e( 'Comment navigation', '_s' ); ?></h2>
<h3 class="screen-reader-text"><?php esc_html_e( 'Comment navigation', '_s' ); ?></h3>
<div class="nav-links">

<div class="nav-previous"><?php previous_comments_link( esc_html__( 'Older Comments', '_s' ) ); ?></div>
Expand Down
4 changes: 2 additions & 2 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ function _s_widgets_init() {
'description' => /* translators: the sidebar name */ sprintf( esc_html__( 'Widget area for %s', '_s' ), $sidebar_name ),
'before_widget' => '<aside class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
) );
}

Expand Down
5 changes: 5 additions & 0 deletions inc/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,8 @@ function _s_custom_mime_types( $mimes ) {
return $mimes;
}
add_filter( 'upload_mimes', '_s_custom_mime_types' );

/**
* Disable the "Cancel reply" link. It doesn't seem to work anyway, and it only makes the "Leave Reply" heading confusing.
*/
add_filter( 'cancel_comment_reply_link', '__return_false' );
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<div class="wrap">
<div class="primary content-area">
<main id="main" class="site-main" role="main">
<main id="main" class="site-main">

<?php
if ( have_posts() ) :
Expand Down
2 changes: 1 addition & 1 deletion page.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<div class="wrap">
<div class="primary content-area">
<main id="main" class="site-main" role="main">
<main id="main" class="site-main">

<?php
while ( have_posts() ) : the_post();
Expand Down
2 changes: 1 addition & 1 deletion search.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<div class="wrap">
<section class="primary content-area">
<main id="main" class="site-main" role="main">
<main id="main" class="site-main">

<?php
if ( have_posts() ) : ?>
Expand Down
2 changes: 1 addition & 1 deletion single.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<div class="wrap">
<div class="primary content-area">
<main id="main" class="site-main" role="main">
<main id="main" class="site-main">

<?php
while ( have_posts() ) : the_post();
Expand Down
Loading

0 comments on commit c2b719a

Please sign in to comment.