Sub-issue of #1190252: [573] Use csslint as a weapon to beat the crappy CSS out of Drupal core

Inline with the CSS cleanup efforts of the HTML5 initiative, using CSSLint at http://csslint.net provides a quick way to code-sniff our css and tweak styles.

  1. Copy and paste the the stylesheet(s) below into the css lint tool at http://csslint.net and test.
  2. Fix any warnings or errors the tool finds.
  3. Patch Drupal 8 locally and make sure the css changes have not broken anything visually.
  4. Create patch and upload for the testbot.

Files: modules/system/system.module.css (and system.module-rtl.css)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Lebby’s picture

I've removed some input related useless class
I've switched from id autoremove to class autoremove and modified related files ( autocomplete.js ).
This file needs more work!

Manuel Garcia’s picture

I'm not sure we should just blindly throw away the id in favour of a class because of csslint, at least in this case. Selecting an ID with jQuery is way faster than a class.

droplet’s picture

+1 #2.
also all of these will be removed. #675446: Use jQuery UI Autocomplete

Lebby’s picture

You're right, it's more fast than using class.
BUT
I think that if you are develop a tool you could use class instead of Id ... why?
- Id must be unique, it's difficult to use an id that doesn't create conflicts.
- class is more flexible than id
- avoiding id is more easy to use from a site developer: add an id on a tag and customize it by css, that use a more classes because he can't modify a previous id
- class is correct abstraction to underline a feature or a behavior
- Using id doesn't allow to use it on more than one element.

All my previous observations are acceptable only considering frameworks/tools ...

Of course, this is my opinion ...

ZenDoodles’s picture

Status: Active » Needs review

Looks like there is more to do, but lets see what the bot has to say so far...

@Manuel Garcia please see #1190252: [573] Use csslint as a weapon to beat the crappy CSS out of Drupal core to discuss the relative merits of csslint.

oresh’s picture

I've also replaced the id with class in the css, but i added the class to the js and did not delete the id.
Also cleaned some styles, the html5 elements discription moved to top page (it shouldn't be at the bottom)
All the css is sorted with CSS Comb, and i went through the Lint and fixed thous issues, which didn't cause any styling break.

oresh’s picture

A little bit more clean up. Didn't add them in previous comment.

droplet’s picture

+++ b/core/modules/system/system.base.cssundefined
@@ -4,33 +4,55 @@
+  list-style: none;
+  list-style-image: none;

either one seems like redundant rule.

+++ b/core/modules/system/system.base.cssundefined
@@ -84,41 +106,42 @@ body.drag {
+.tree-child-horizontal {
+  background: url('../../misc/tree.png') no-repeat 11px center; /* LTR */
...
+.tree-child-horizontal {
+  background-position: -11px center;

2 same selector, but ONE has LTR, another hasn't.

droplet’s picture

+++ b/core/misc/autocomplete.jsundefined
@@ -196,7 +196,7 @@ Drupal.jsAC.prototype.populatePopup = function () {
-  this.popup = $('<div id="autocomplete"></div>')[0];
+  this.popup = $('<div class="autocomplete" id="autocomplete"></div>')[0];

Also,

about the autocomplete, it always has ONE div and should be only ONE. theoretically and ideally it should be #id

oresh’s picture

@droplet,
- list-style-image:none was there before, and as I know it's a fix for IE8 which doesn't like just list-style: none;
- autocomplete changed back to ID;
- LTR added

Thank you for testing!

oresh’s picture

Liam Morland’s picture

This has probably been superseded by #1921610: [Meta] Architect our CSS.

LewisNyman’s picture

Title: Clean up system base css » Clean up system.module.css
Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +frontend, +CSS
rteijeiro’s picture

Assigned: Unassigned » rteijeiro

Working on this :)

rteijeiro’s picture

Issue summary: View changes
rteijeiro’s picture

Assigned: rteijeiro » Unassigned
Status: Needs work » Needs review
FileSize
4.06 KB

Fixed a few CSSLint errors. Still some background errors remaining but not sure how to fix them. Any ideas?

Status: Needs review » Needs work

The last submitted patch, 16: 1663170-clean-system-module-16.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 16: 1663170-clean-system-module-16.patch, failed testing.

LewisNyman’s picture

The documentation for the multiple background image rule is here: https://github.com/CSSLint/csslint/wiki/Disallow-duplicate-background-im...

I manage to remove all the errors apart from the throbber image being used multiple times. I don't think we want to follow the rule in this situation as it's not possible to add custom classes to jQuery UI elements I think. Let's leave it as is and maybe we can revisit if we want to follow this rule later on.

We need some screenshots of the affected elements, especially the full screen throbber (Views UI)

Status: Needs review » Needs work

The last submitted patch, 20: 1663170-clean-system-module-20.patch, failed testing.

LewisNyman’s picture

Status: Needs work » Needs review
FileSize
4.76 KB

I messed up the patch

idebr’s picture

Status: Needs review » Needs work

I haven't checked the autocomplete and table hierarchy yet, but here are some pointers:

  1. +++ b/core/modules/system/css/system.module.css
    @@ -107,10 +107,8 @@ a.tabledrag-handle:hover {
     a.tabledrag-handle .handle {
       background: url(../../../misc/icons/787878/move.svg) no-repeat 6px 7px;
    -  height: 14px;
       margin: -0.4em 0.5em 0;
    -  padding: 0.42em 0.5em;
    -  width: 14px;
    +  padding: 0.42em 1em;
    

    This changes the size of the drag handle.

  2. +++ b/core/modules/system/css/system.module.css
    @@ -131,34 +129,31 @@ a.tabledrag-handle:focus .handle {
    -.touch .draggable.drag a.tabledrag-handle .handle {
    +.touch .draggable .drag a.tabledrag-handle .handle {
    

    This selector no longer applies to the intended element, since the markup is <tr class="draggable tabledrag-leaf drag">

  3. +++ b/core/modules/system/css/system.module.css
    @@ -131,34 +129,31 @@ a.tabledrag-handle:focus .handle {
    +.tree-child-horizontal {
    
    @@ -353,7 +346,7 @@ tr .ajax-progress-throbber .throbber {
      * "!important" is used to prevent unintentional overrides.
    

    Comment no longer applies when !important is removed

  4. +++ b/core/modules/system/css/system.module.css
    @@ -365,9 +358,9 @@ tr .ajax-progress-throbber .throbber {
    -.visually-hidden.focusable:active,
    -.visually-hidden.focusable:focus {
    -  position: static !important;
    +.visually-hidden .focusable:active,
    +.visually-hidden .focusable:focus {
    +  position: static;
    

    This breaks the contextual link selector, as its markup is

    <a href="#main-content" class="visually-hidden focusable skip-link">
      Skip to main content
    </a>
  5. Not in patch:
    /*
     * Remove browser styles, especially for <buttons> and so on.
     */
    .reset-appearance {

    should be

    /**
     * Remove browser styles, especially for <buttons> and so on.
     */
    .reset-appearance {
    
  6. Not in patch:
    /*
     * Contain positioned elements.
     */
    .position-container {

    Should be

    /**
     * Contain positioned elements.
     */
    .position-container {
    
LewisNyman’s picture

mgifford’s picture

Status: Postponed » Needs work

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 22: 1663170-clean-system-module-21.patch, failed testing.

LewisNyman’s picture

Can we replace these issues with individual issues for each file? It would make it easier to work on. Does anyone want to create the issues? :)

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.