Accessibility: Simplify the Site Health score indicator.

The Site Health score indicator isn't exactly a "progress bar" and shouldn't use ARIA roles and properties related to progress bars. Also, some browser / screen reader combinations don't announce the score properly.
- removes any ARIA
- adds a screen-reader-text "Current health score:"
- adds `role="img" aria-hidden="true" focusable="false"` to the SVG
- reduces CSS specificity simplifying unnecessary overqualified selectors
- fixes the syntax for ::after and ::before (double colon)

Fixes #46621.

Built from https://develop.svn.wordpress.org/trunk@45041


git-svn-id: http://core.svn.wordpress.org/trunk@44850 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrea Fercia 2019-03-27 20:39:51 +00:00
parent f9de2f860d
commit 9b15549b1c
9 changed files with 58 additions and 48 deletions

View File

@ -39,7 +39,7 @@ body.site-health .health-check-header .title-section h1 {
margin: 1rem 0.8rem 1rem 0.8rem; margin: 1rem 0.8rem 1rem 0.8rem;
} }
body.site-health .health-check-header .title-section #progressbar { .site-health-progress {
display: inline-block; display: inline-block;
height: 40px; height: 40px;
width: 40px; width: 40px;
@ -50,14 +50,13 @@ body.site-health .health-check-header .title-section #progressbar {
font-size: 0.4rem; font-size: 0.4rem;
} }
body.site-health .health-check-header .title-section #progressbar:after { .site-health-progress .progress-count {
position: absolute; position: absolute;
display: block; display: block;
height: 80px; height: 80px;
width: 80px; width: 80px;
right: 50%; right: 50%;
top: 50%; top: 50%;
content: attr(data-pct) "%";
margin-top: -40px; margin-top: -40px;
margin-right: -40px; margin-right: -40px;
border-radius: 100%; border-radius: 100%;
@ -65,37 +64,41 @@ body.site-health .health-check-header .title-section #progressbar:after {
font-size: 2em; font-size: 2em;
} }
body.site-health .health-check-header .title-section #progressbar.hidden { .site-health-progress .progress-count::after {
content: "";
}
.site-health-progress.hidden {
display: none; display: none;
} }
body.site-health .health-check-header .title-section #progressbar.loading:after { .site-health-progress.loading .progress-count::after {
animation: loadingEllipsis 3s infinite ease-in-out; animation: loadingEllipsis 3s infinite ease-in-out;
} }
body.site-health .health-check-header .title-section #progressbar.loading svg #bar { .site-health-progress.loading svg #bar {
stroke-dashoffset: 0; stroke-dashoffset: 0;
stroke: #adc5d2; stroke: #adc5d2;
animation: loadingPulse 3s infinite ease-in-out; animation: loadingPulse 3s infinite ease-in-out;
} }
body.site-health .health-check-header .title-section #progressbar svg circle { .site-health-progress svg circle {
stroke-dashoffset: 0; stroke-dashoffset: 0;
transition: stroke-dashoffset 1s linear; transition: stroke-dashoffset 1s linear;
stroke: #ccc; stroke: #ccc;
stroke-width: 2em; stroke-width: 2em;
} }
body.site-health .health-check-header .title-section #progressbar svg #bar { .site-health-progress svg #bar {
stroke-dashoffset: 565; stroke-dashoffset: 565;
stroke: #dc3232; stroke: #dc3232;
} }
body.site-health .health-check-header .title-section #progressbar svg #bar.green { .site-health-progress svg #bar.green {
stroke: #46b450; stroke: #46b450;
} }
body.site-health .health-check-header .title-section #progressbar svg #bar.orange { .site-health-progress svg #bar.orange {
stroke: #ffb900; stroke: #ffb900;
} }
@ -171,8 +174,8 @@ body.site-health .health-check-table tbody td ol {
margin: 0; margin: 0;
} }
body.site-health .pass:before, .site-health .pass::before,
body.site-health .good:before { .site-health .good::before {
content: "\f147"; content: "\f147";
display: inline-block; display: inline-block;
color: #46b450; color: #46b450;
@ -180,22 +183,22 @@ body.site-health .good:before {
vertical-align: top; vertical-align: top;
} }
body.site-health .warning:before { .site-health .warning::before {
content: "\f460"; content: "\f460";
display: inline-block; display: inline-block;
color: #ffb900; color: #ffb900;
font-family: dashicons; font-family: dashicons;
} }
body.site-health .info:before { .site-health .info::before {
content: "\f348"; content: "\f348";
display: inline-block; display: inline-block;
color: #00a0d2; color: #00a0d2;
font-family: dashicons; font-family: dashicons;
} }
body.site-health .fail:before, .site-health .fail::before,
body.site-health .error:before { .site-health .error::before {
content: "\f335"; content: "\f335";
display: inline-block; display: inline-block;
color: #dc3232; color: #dc3232;

File diff suppressed because one or more lines are too long

View File

@ -39,7 +39,7 @@ body.site-health .health-check-header .title-section h1 {
margin: 1rem 0.8rem 1rem 0.8rem; margin: 1rem 0.8rem 1rem 0.8rem;
} }
body.site-health .health-check-header .title-section #progressbar { .site-health-progress {
display: inline-block; display: inline-block;
height: 40px; height: 40px;
width: 40px; width: 40px;
@ -50,14 +50,13 @@ body.site-health .health-check-header .title-section #progressbar {
font-size: 0.4rem; font-size: 0.4rem;
} }
body.site-health .health-check-header .title-section #progressbar:after { .site-health-progress .progress-count {
position: absolute; position: absolute;
display: block; display: block;
height: 80px; height: 80px;
width: 80px; width: 80px;
left: 50%; left: 50%;
top: 50%; top: 50%;
content: attr(data-pct) "%";
margin-top: -40px; margin-top: -40px;
margin-left: -40px; margin-left: -40px;
border-radius: 100%; border-radius: 100%;
@ -65,37 +64,41 @@ body.site-health .health-check-header .title-section #progressbar:after {
font-size: 2em; font-size: 2em;
} }
body.site-health .health-check-header .title-section #progressbar.hidden { .site-health-progress .progress-count::after {
content: "";
}
.site-health-progress.hidden {
display: none; display: none;
} }
body.site-health .health-check-header .title-section #progressbar.loading:after { .site-health-progress.loading .progress-count::after {
animation: loadingEllipsis 3s infinite ease-in-out; animation: loadingEllipsis 3s infinite ease-in-out;
} }
body.site-health .health-check-header .title-section #progressbar.loading svg #bar { .site-health-progress.loading svg #bar {
stroke-dashoffset: 0; stroke-dashoffset: 0;
stroke: #adc5d2; stroke: #adc5d2;
animation: loadingPulse 3s infinite ease-in-out; animation: loadingPulse 3s infinite ease-in-out;
} }
body.site-health .health-check-header .title-section #progressbar svg circle { .site-health-progress svg circle {
stroke-dashoffset: 0; stroke-dashoffset: 0;
transition: stroke-dashoffset 1s linear; transition: stroke-dashoffset 1s linear;
stroke: #ccc; stroke: #ccc;
stroke-width: 2em; stroke-width: 2em;
} }
body.site-health .health-check-header .title-section #progressbar svg #bar { .site-health-progress svg #bar {
stroke-dashoffset: 565; stroke-dashoffset: 565;
stroke: #dc3232; stroke: #dc3232;
} }
body.site-health .health-check-header .title-section #progressbar svg #bar.green { .site-health-progress svg #bar.green {
stroke: #46b450; stroke: #46b450;
} }
body.site-health .health-check-header .title-section #progressbar svg #bar.orange { .site-health-progress svg #bar.orange {
stroke: #ffb900; stroke: #ffb900;
} }
@ -171,8 +174,8 @@ body.site-health .health-check-table tbody td ol {
margin: 0; margin: 0;
} }
body.site-health .pass:before, .site-health .pass::before,
body.site-health .good:before { .site-health .good::before {
content: "\f147"; content: "\f147";
display: inline-block; display: inline-block;
color: #46b450; color: #46b450;
@ -180,22 +183,22 @@ body.site-health .good:before {
vertical-align: top; vertical-align: top;
} }
body.site-health .warning:before { .site-health .warning::before {
content: "\f460"; content: "\f460";
display: inline-block; display: inline-block;
color: #ffb900; color: #ffb900;
font-family: dashicons; font-family: dashicons;
} }
body.site-health .info:before { .site-health .info::before {
content: "\f348"; content: "\f348";
display: inline-block; display: inline-block;
color: #00a0d2; color: #00a0d2;
font-family: dashicons; font-family: dashicons;
} }
body.site-health .fail:before, .site-health .fail::before,
body.site-health .error:before { .site-health .error::before {
content: "\f335"; content: "\f335";
display: inline-block; display: inline-block;
color: #dc3232; color: #dc3232;

File diff suppressed because one or more lines are too long

View File

@ -82,18 +82,19 @@ jQuery( document ).ready( function( $ ) {
*/ */
function RecalculateProgression() { function RecalculateProgression() {
var r, c, pct; var r, c, pct;
var $progressBar = $( '#progressbar' ); var $progress = $( '.site-health-progress' );
var $circle = $( '#progressbar svg #bar' ); var $progressCount = $progress.find( '.progress-count' );
var $circle = $( '.site-health-progress svg #bar' );
var totalTests = parseInt( SiteHealth.site_status.issues.good, 0 ) + parseInt( SiteHealth.site_status.issues.recommended, 0 ) + ( parseInt( SiteHealth.site_status.issues.critical, 0 ) * 1.5 ); var totalTests = parseInt( SiteHealth.site_status.issues.good, 0 ) + parseInt( SiteHealth.site_status.issues.recommended, 0 ) + ( parseInt( SiteHealth.site_status.issues.critical, 0 ) * 1.5 );
var failedTests = parseInt( SiteHealth.site_status.issues.recommended, 0 ) + ( parseInt( SiteHealth.site_status.issues.critical, 0 ) * 1.5 ); var failedTests = parseInt( SiteHealth.site_status.issues.recommended, 0 ) + ( parseInt( SiteHealth.site_status.issues.critical, 0 ) * 1.5 );
var val = 100 - Math.ceil( ( failedTests / totalTests ) * 100 ); var val = 100 - Math.ceil( ( failedTests / totalTests ) * 100 );
if ( 0 === totalTests ) { if ( 0 === totalTests ) {
$progressBar.addClass( 'hidden' ); $progress.addClass( 'hidden' );
return; return;
} }
$progressBar.removeClass( 'loading' ); $progress.removeClass( 'loading' );
r = $circle.attr( 'r' ); r = $circle.attr( 'r' );
c = Math.PI * ( r * 2 ); c = Math.PI * ( r * 2 );
@ -130,8 +131,7 @@ jQuery( document ).ready( function( $ ) {
$( '.site-status-has-issues' ).addClass( 'hide' ); $( '.site-status-has-issues' ).addClass( 'hide' );
} }
$progressBar.attr( 'data-pct', val ); $progressCount.text( val + '%' );
$progressBar.attr( 'aria-valuenow', val );
$.post( $.post(
ajaxurl, ajaxurl,

View File

@ -1 +1 @@
jQuery(document).ready(function(a){function b(b){var c=wp.template("health-check-issue"),d=a("#health-check-issues-"+b.status),e=a(".issue-count",d);SiteHealth.site_status.issues[b.status]++,e.text(SiteHealth.site_status.issues[b.status]),a(".issues","#health-check-issues-"+b.status).append(c(b))}function c(){var b,c,d,e=a("#progressbar"),f=a("#progressbar svg #bar"),g=parseInt(SiteHealth.site_status.issues.good,0)+parseInt(SiteHealth.site_status.issues.recommended,0)+1.5*parseInt(SiteHealth.site_status.issues.critical,0),h=parseInt(SiteHealth.site_status.issues.recommended,0)+1.5*parseInt(SiteHealth.site_status.issues.critical,0),i=100-Math.ceil(h/g*100);return 0===g?void e.addClass("hidden"):(e.removeClass("loading"),b=f.attr("r"),c=Math.PI*(2*b),0>i&&(i=0),100<i&&(i=100),d=(100-i)/100*c,f.css({strokeDashoffset:d}),1>parseInt(SiteHealth.site_status.issues.critical,0)&&a("#health-check-issues-critical").addClass("hidden"),1>parseInt(SiteHealth.site_status.issues.recommended,0)&&a("#health-check-issues-recommended").addClass("hidden"),50<=i&&f.addClass("orange").removeClass("red"),90<=i&&f.addClass("green").removeClass("orange"),100===i&&(a(".site-status-all-clear").removeClass("hide"),a(".site-status-has-issues").addClass("hide")),e.attr("data-pct",i),e.attr("aria-valuenow",i),a.post(ajaxurl,{action:"health-check-site-status-result",_wpnonce:SiteHealth.nonce.site_status_result,counts:SiteHealth.site_status.issues}),void wp.a11y.speak(SiteHealth.string.site_health_complete_screen_reader.replace("%s",i+"%")))}function d(){var e=!0;1<=SiteHealth.site_status.async.length&&a.each(SiteHealth.site_status.async,function(){var c={action:"health-check-"+this.test.replace("_","-"),_wpnonce:SiteHealth.nonce.site_status};return!!this.completed||(e=!1,this.completed=!0,a.post(ajaxurl,c,function(a){b(a.data),d()}),!1)}),e&&c()}var e;a(".health-check-copy-field").click(function(b){var c=a("#system-information-"+a(this).data("copy-field")+"-copy-field"),d=a(this).closest("div");b.preventDefault(),c.select(),document.execCommand("copy")&&(a(".copy-field-success",d).addClass("visible"),a(this).focus(),wp.a11y.speak(SiteHealth.string.site_info_copied))}),a(".health-check-accordion").on("click",".health-check-accordion-trigger",function(){var b="true"===a(this).attr("aria-expanded");b?(a(this).attr("aria-expanded","false"),a("#"+a(this).attr("aria-controls")).attr("hidden",!0)):(a(this).attr("aria-expanded","true"),a("#"+a(this).attr("aria-controls")).attr("hidden",!1))}),a(".health-check-accordion").on("keyup",".health-check-accordion-trigger",function(b){"38"===b.keyCode.toString()?a(".health-check-accordion-trigger",a(this).closest("dt").prevAll("dt")).focus():"40"===b.keyCode.toString()&&a(".health-check-accordion-trigger",a(this).closest("dt").nextAll("dt")).focus()}),a(".site-health-view-passed").on("click",function(){var b=a("#health-check-issues-good");b.toggleClass("hidden"),a(this).attr("aria-expanded",!b.hasClass("hidden"))}),"undefined"!=typeof SiteHealth&&(0===SiteHealth.site_status.direct.length&&0===SiteHealth.site_status.async.length?c():SiteHealth.site_status.issues={good:0,recommended:0,critical:0},0<SiteHealth.site_status.direct.length&&a.each(SiteHealth.site_status.direct,function(){b(this)}),0<SiteHealth.site_status.async.length?(e={action:"health-check-"+SiteHealth.site_status.async[0].test.replace("_","-"),_wpnonce:SiteHealth.nonce.site_status},SiteHealth.site_status.async[0].completed=!0,a.post(ajaxurl,e,function(a){b(a.data),d()})):c())}); jQuery(document).ready(function(a){function b(b){var c=wp.template("health-check-issue"),d=a("#health-check-issues-"+b.status),e=a(".issue-count",d);SiteHealth.site_status.issues[b.status]++,e.text(SiteHealth.site_status.issues[b.status]),a(".issues","#health-check-issues-"+b.status).append(c(b))}function c(){var b,c,d,e=a(".site-health-progress"),f=e.find(".progress-count"),g=a(".site-health-progress svg #bar"),h=parseInt(SiteHealth.site_status.issues.good,0)+parseInt(SiteHealth.site_status.issues.recommended,0)+1.5*parseInt(SiteHealth.site_status.issues.critical,0),i=parseInt(SiteHealth.site_status.issues.recommended,0)+1.5*parseInt(SiteHealth.site_status.issues.critical,0),j=100-Math.ceil(i/h*100);return 0===h?void e.addClass("hidden"):(e.removeClass("loading"),b=g.attr("r"),c=Math.PI*(2*b),0>j&&(j=0),100<j&&(j=100),d=(100-j)/100*c,g.css({strokeDashoffset:d}),1>parseInt(SiteHealth.site_status.issues.critical,0)&&a("#health-check-issues-critical").addClass("hidden"),1>parseInt(SiteHealth.site_status.issues.recommended,0)&&a("#health-check-issues-recommended").addClass("hidden"),50<=j&&g.addClass("orange").removeClass("red"),90<=j&&g.addClass("green").removeClass("orange"),100===j&&(a(".site-status-all-clear").removeClass("hide"),a(".site-status-has-issues").addClass("hide")),f.text(j+"%"),a.post(ajaxurl,{action:"health-check-site-status-result",_wpnonce:SiteHealth.nonce.site_status_result,counts:SiteHealth.site_status.issues}),void wp.a11y.speak(SiteHealth.string.site_health_complete_screen_reader.replace("%s",j+"%")))}function d(){var e=!0;1<=SiteHealth.site_status.async.length&&a.each(SiteHealth.site_status.async,function(){var c={action:"health-check-"+this.test.replace("_","-"),_wpnonce:SiteHealth.nonce.site_status};return!!this.completed||(e=!1,this.completed=!0,a.post(ajaxurl,c,function(a){b(a.data),d()}),!1)}),e&&c()}var e;a(".health-check-copy-field").click(function(b){var c=a("#system-information-"+a(this).data("copy-field")+"-copy-field"),d=a(this).closest("div");b.preventDefault(),c.select(),document.execCommand("copy")&&(a(".copy-field-success",d).addClass("visible"),a(this).focus(),wp.a11y.speak(SiteHealth.string.site_info_copied))}),a(".health-check-accordion").on("click",".health-check-accordion-trigger",function(){var b="true"===a(this).attr("aria-expanded");b?(a(this).attr("aria-expanded","false"),a("#"+a(this).attr("aria-controls")).attr("hidden",!0)):(a(this).attr("aria-expanded","true"),a("#"+a(this).attr("aria-controls")).attr("hidden",!1))}),a(".health-check-accordion").on("keyup",".health-check-accordion-trigger",function(b){"38"===b.keyCode.toString()?a(".health-check-accordion-trigger",a(this).closest("dt").prevAll("dt")).focus():"40"===b.keyCode.toString()&&a(".health-check-accordion-trigger",a(this).closest("dt").nextAll("dt")).focus()}),a(".site-health-view-passed").on("click",function(){var b=a("#health-check-issues-good");b.toggleClass("hidden"),a(this).attr("aria-expanded",!b.hasClass("hidden"))}),"undefined"!=typeof SiteHealth&&(0===SiteHealth.site_status.direct.length&&0===SiteHealth.site_status.async.length?c():SiteHealth.site_status.issues={good:0,recommended:0,critical:0},0<SiteHealth.site_status.direct.length&&a.each(SiteHealth.site_status.direct,function(){b(this)}),0<SiteHealth.site_status.async.length?(e={action:"health-check-"+SiteHealth.site_status.async[0].test.replace("_","-"),_wpnonce:SiteHealth.nonce.site_status},SiteHealth.site_status.async[0].completed=!0,a.post(ajaxurl,e,function(a){b(a.data),d()})):c())});

View File

@ -34,11 +34,13 @@ require_once( ABSPATH . 'wp-admin/admin-header.php' );
<?php _ex( 'Site Health', 'Menu, Section and Page Title' ); ?> <?php _ex( 'Site Health', 'Menu, Section and Page Title' ); ?>
</h1> </h1>
<div id="progressbar" class="loading" data-pct="0" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" aria-valuetext="<?php esc_attr_e( 'Site tests are running, please wait a moment.' ); ?>"> <div class="site-health-progress loading">
<svg width="100%" height="100%" viewBox="0 0 200 200" version="1.1" xmlns="http://www.w3.org/2000/svg"> <svg role="img" aria-hidden="true" focusable="false" width="100%" height="100%" viewBox="0 0 200 200" version="1.1" xmlns="http://www.w3.org/2000/svg">
<circle r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle> <circle r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle>
<circle id="bar" r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle> <circle id="bar" r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle>
</svg> </svg>
<span class="screen-reader-text"><?php _e( 'Current health score:' ); ?></span>
<span class="progress-count"></span>
</div> </div>
</div> </div>

View File

@ -36,11 +36,13 @@ require_once( ABSPATH . 'wp-admin/admin-header.php' );
<?php _ex( 'Site Health', 'Menu, Section and Page Title' ); ?> <?php _ex( 'Site Health', 'Menu, Section and Page Title' ); ?>
</h1> </h1>
<div id="progressbar" class="loading" data-pct="0" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" aria-valuetext="<?php esc_attr_e( 'Site tests are running, please wait a moment.' ); ?>"> <div class="site-health-progress loading">
<svg width="100%" height="100%" viewBox="0 0 200 200" version="1.1" xmlns="http://www.w3.org/2000/svg"> <svg role="img" aria-hidden="true" focusable="false" width="100%" height="100%" viewBox="0 0 200 200" version="1.1" xmlns="http://www.w3.org/2000/svg">
<circle r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle> <circle r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle>
<circle id="bar" r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle> <circle id="bar" r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle>
</svg> </svg>
<span class="screen-reader-text"><?php _e( 'Current health score:' ); ?></span>
<span class="progress-count"></span>
</div> </div>
</div> </div>

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.2-alpha-45040'; $wp_version = '5.2-alpha-45041';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.