Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply new error taxonomy page design #1394

Merged
merged 32 commits into from
Sep 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
1cb9eee
Reorganize error taxonomy page columns based on design
kienstra Sep 3, 2018
3bc656b
Merge in develop, resolve trivial conflict.
kienstra Sep 5, 2018
8c26606
Merge branch 'develop' into add/1361-taxonomy-page
johnwatkins0 Sep 7, 2018
aab32d6
Improved error listing view - details column
johnwatkins0 Sep 9, 2018
e5a4b68
Improved error listing view - add error type column (without sorting)
johnwatkins0 Sep 9, 2018
f93c2fe
Error inventory column - link items to post type listing for term
johnwatkins0 Sep 10, 2018
ecc8f6e
Error listing view - update action text
johnwatkins0 Sep 10, 2018
4f913dc
Error listing view - update statuses filter text
johnwatkins0 Sep 10, 2018
96a5eeb
Error taxonomy list - move CSS to file and add down SVG
johnwatkins0 Sep 10, 2018
6d5862c
Error listing view - add button to toggle all details
johnwatkins0 Sep 10, 2018
34fbb7b
Error list view - resolve jshint by renaming webpack output file
johnwatkins0 Sep 10, 2018
8751842
Error listing view - resolve faling PHPUnit test
johnwatkins0 Sep 10, 2018
457add1
Error listing view - resolve failing PHPUnit tests
johnwatkins0 Sep 10, 2018
aafaf79
Error listing view - update language based on new AC
johnwatkins0 Sep 11, 2018
1c94539
Error listing view - update language based on new AC
johnwatkins0 Sep 11, 2018
c7af581
Error listing view - enable sorting list alphabetically by error type
johnwatkins0 Sep 11, 2018
21413ba
Error listing view - make details column sortable by element/node/att…
johnwatkins0 Sep 11, 2018
d1fd252
Error listing view - make error inventory column sortable
johnwatkins0 Sep 12, 2018
768f6eb
Error listing view - phpcs
johnwatkins0 Sep 12, 2018
85e2415
Error listing view - resolve failing PHPUnit test
johnwatkins0 Sep 12, 2018
db3a8b4
Error listing view - add status icon styles
johnwatkins0 Sep 12, 2018
cd11b82
Error listing view - change 'Javascript' to 'JavaScript'
johnwatkins0 Sep 12, 2018
3cfb7e3
Error listing view - omit details if the invalid element has no attri…
johnwatkins0 Sep 12, 2018
13e09be
Error listing view - phpcs
johnwatkins0 Sep 12, 2018
d94482d
Error listing view - PHPCS on test file
johnwatkins0 Sep 12, 2018
22e90ce
Error listing view - fix 'Rejected Errors' text
johnwatkins0 Sep 12, 2018
581e5d6
Error listing view - remove unused script dependency and escape an at…
johnwatkins0 Sep 12, 2018
3ae7184
Improve validation error details in list view
westonruter Sep 13, 2018
300c812
Improve display of invalid element/attribute and at-rule
westonruter Sep 13, 2018
01327f1
Add details link to validation error row actions; update column headings
westonruter Sep 13, 2018
8cd1480
Use 'Error Index' instead of 'Errors by Type'
westonruter Sep 13, 2018
59380a5
Fix translation function use; remove unused param
westonruter Sep 13, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 138 additions & 0 deletions assets/css/amp-validation-error-taxonomy.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
#col-left {
display: none;
}
#col-right {
float: none;
width: auto;
}

/* Improve column widths */
td.column-details pre,
td.column-sources pre {
overflow: auto;
}

th.column-created_date_gmt,
th.column-error_type {
width: 15%;
}

th.column-status {
width: 10%;
}

.fixed th.column-posts {
width: 10%;
}

/* Details column */
.details-attributes__summary {
display: flex;
justify-content: space-between;
align-items: center;
}

details[open] .details-attributes__summary {
font-weight: 600;
margin-bottom: 15px;
}

.details-attributes__summary::-webkit-details-marker {
display: none;
}

.details-attributes__summary::after {
order: 99;
width: 12px;
height: 12px;
background-image: url("../images/down-triangle.svg");
background-size: cover;
background-position: center;
content: "";
}

details[open] .details-attributes__summary::after {
transform: rotate(180deg);
}

.details-attributes__title,
.details-attributes__attr {
color: #dc3232;
}

.details-attributes__list {
margin-top: 0;
padding-left: 45px;
list-style-type: disc;
}

.details-attributes__list li {
word-break: break-all;
}

.details-attributes__value {
color: #00a0d2;
}

/* Error details toggle button */
.manage-column.column-details {
display: flex;
justify-content: space-between;
align-items: center;
}

.error-details-toggle {
display: flex;
flex-direction: column;
height: 12px;
margin-right: 10px;
padding: 0;
background: none;
border: none;
cursor: pointer;
}

.error-details-toggle.is-open {
transform: rotate(180deg);
}

.error-details-toggle::before,
.error-details-toggle::after {
width: 12px;
height: 12px;
background-image: url("../images/down-triangle.svg");
background-size: cover;
background-position: center;
content: "";
}

/* Status text icons */
.status-text {
display: flex;
align-items: center;
}

.status-text::before {
margin-right: 10px;
background-size: 20px 20px;
height: 20px;
width: 20px;
content: "";
}

.status-text.sanitized::before {
background-image: url( '../images/amp-logo-icon.svg' );
}

.status-text.new::before {
background-image: url( '../images/baseline-error.svg' );
}

.status-text.accepted::before {
background-image: url( '../images/baseline-check-circle-green.svg' );
}

.status-text.rejected::before {
background-image: url( '../images/baseline-error-blue.svg' );
}

4 changes: 4 additions & 0 deletions assets/images/baseline-check-circle-green.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/images/down-triangle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 60 additions & 0 deletions assets/src/amp-validation-error-detail-toggle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* WordPress dependencies
*/
import domReady from '@wordpress/dom-ready';

/**
* Localized data
*/
import { btnAriaLabel } from 'amp-validation-i18n';

const OPEN_CLASS = 'is-open';

/**
* Adds detail toggle buttons to the header and footer rows of the validation error "details" column.
* The buttons are added via JS because there's no easy way to append them to the heading of a sortable
* table column via backend code.
*/
function addToggleButtons() {
[ ...document.querySelectorAll( 'th.column-details.manage-column' ) ].forEach( th => {
const button = document.createElement( 'button' );
button.setAttribute( 'aria-label', btnAriaLabel );
button.setAttribute( 'type', 'button' );
button.setAttribute( 'class', 'error-details-toggle' );
th.appendChild( button );
} );
}

/**
* Adds a listener toggling all details in the error type taxonomy details column.
*/
function addToggleListener() {
let open = false;

const details = [ ...document.querySelectorAll( '.column-details details' ) ];
const toggleButtons = [ ...document.querySelectorAll( 'button.error-details-toggle' ) ];
const onButtonClick = () => {
open = ! open;
toggleButtons.forEach( btn => {
btn.classList.toggle( OPEN_CLASS );
} );
details.forEach( detail => {
if ( open ) {
detail.setAttribute( 'open', true );
} else {
detail.removeAttribute( 'open' );
}
} );
};

window.addEventListener( 'click', event => {
if ( toggleButtons.includes( event.target ) ) {
onButtonClick();
}
} );
}

domReady( () => {
addToggleButtons();
addToggleListener();
} );
2 changes: 1 addition & 1 deletion dev-lib
Submodule dev-lib updated 1 files
+0 −5 check-diff.sh
17 changes: 12 additions & 5 deletions includes/sanitizers/class-amp-style-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ class AMP_Style_Sanitizer extends AMP_Base_Sanitizer {
*/
const TREE_SHAKING_ERROR_CODE = 'removed_unused_css_rules';

/**
* Error code for illegal at-rule.
*
* @var string
*/
const ILLEGAL_AT_RULE_ERROR_CODE = 'illegal_css_at_rule';

/**
* Inline style selector's specificity multiplier, i.e. used to generate the number of ':not(#_)' placeholders.
*
Expand Down Expand Up @@ -233,7 +240,7 @@ public static function get_css_parser_validation_error_codes() {
return array(
'css_parse_error',
'excessive_css',
'illegal_css_at_rule',
self::ILLEGAL_AT_RULE_ERROR_CODE,
'illegal_css_important',
'illegal_css_property',
self::TREE_SHAKING_ERROR_CODE,
Expand Down Expand Up @@ -1243,7 +1250,7 @@ private function process_css_list( CSSList $css_list, $options ) {
} elseif ( $css_item instanceof AtRuleBlockList ) {
if ( ! in_array( $css_item->atRuleName(), $options['allowed_at_rules'], true ) ) {
$error = array(
'code' => 'illegal_css_at_rule',
'code' => self::ILLEGAL_AT_RULE_ERROR_CODE,
'at_rule' => $css_item->atRuleName(),
'type' => AMP_Validation_Error_Taxonomy::CSS_ERROR_TYPE,
);
Expand All @@ -1264,7 +1271,7 @@ private function process_css_list( CSSList $css_list, $options ) {
} elseif ( $css_item instanceof AtRuleSet ) {
if ( ! in_array( $css_item->atRuleName(), $options['allowed_at_rules'], true ) ) {
$error = array(
'code' => 'illegal_css_at_rule',
'code' => self::ILLEGAL_AT_RULE_ERROR_CODE,
'at_rule' => $css_item->atRuleName(),
'type' => AMP_Validation_Error_Taxonomy::CSS_ERROR_TYPE,
);
Expand All @@ -1281,7 +1288,7 @@ private function process_css_list( CSSList $css_list, $options ) {
} elseif ( $css_item instanceof KeyFrame ) {
if ( ! in_array( 'keyframes', $options['allowed_at_rules'], true ) ) {
$error = array(
'code' => 'illegal_css_at_rule',
'code' => self::ILLEGAL_AT_RULE_ERROR_CODE,
'at_rule' => $css_item->atRuleName(),
'type' => AMP_Validation_Error_Taxonomy::CSS_ERROR_TYPE,
);
Expand All @@ -1297,7 +1304,7 @@ private function process_css_list( CSSList $css_list, $options ) {
}
} elseif ( $css_item instanceof AtRule ) {
$error = array(
'code' => 'illegal_css_at_rule',
'code' => self::ILLEGAL_AT_RULE_ERROR_CODE,
'at_rule' => $css_item->atRuleName(),
'type' => AMP_Validation_Error_Taxonomy::CSS_ERROR_TYPE,
);
Expand Down
Loading