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/color/color.css and color-rtl.css

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

RobLoach’s picture

barraponto’s picture

The problem is it doesn't have any other usable selector besides the IDs. So we might have to dig into the JS.

barraponto’s picture

This is FUBAR. I mean, it needs to be addressed in color.module, color.js and the themes implementing it (including the js in the themes) :|

barraponto’s picture

Status: Active » Needs review
FileSize
4.41 KB

So, what I actually did was add classes, leave the ids the way they were. Trying to remove the ids would force me to go through the js files and it's enough of a patch for this file.

barraponto’s picture

This still applies cleanly. Color widget seems unaffected by this patch (as supposed).

markhalliwell’s picture

Status: Needs review » Needs work
Issue tags: +Novice
+++ w/core/modules/color/color.js
@@ -21,7 +21,7 @@ Drupal.behaviors.color = {
-    $('<div id="placeholder"></div>').once('color').prependTo(form);
+    $('<div id="placeholder" class="placeholder"></div>').once('color').prependTo(form);

If we're going to replace IDs with classes (which we should btw +1), you might as well remove the IDs entirely from the JS and HTML.

barraponto’s picture

@Mark Carver, agreed, but it's quite some effort to remove the id from js. I suggest it as a follow up patch.

markhalliwell’s picture

Status: Needs work » Needs review
Issue tags: -Novice

#4: csslint-color-1662958.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +Novice

The last submitted patch, csslint-color-1662958.patch, failed testing.

markhalliwell’s picture

Issue tags: +Needs reroll

Patch needs to be rerolled against the latest HEAD.

On a side note, we may want to also refactor this patch against our CSS coding standards while we're at it.

iflista’s picture

Assigned: Unassigned » iflista

Working with this.

plopesc’s picture

Assigned: iflista » Unassigned

@iflista, marking as unassing given that there are no work for more than three weeks.

If you're interested on work on it, please reassign it.

Regards.

StryKaizer’s picture

Assigned: Unassigned » StryKaizer

Working on this

StryKaizer’s picture

Css classes renamed as suggested in css code styling.
This patch also fixes Bartik, which overrides the color template.

Some js selectors had to be rewritten for this patch to allow the new code styling.

StryKaizer’s picture

Status: Needs work » Needs review
Issue tags: -Novice

Needs review

Status: Needs review » Needs work

The last submitted patch, csslint-color-codingstandards-1662958.patch, failed testing.

jason.bell’s picture

Issue tags: -Needs reroll
  • Ran color.admin.css through CSS Lint and resolved all warnings except "Disallow too many floats" (address later)
  • Updated Color module templates with class names instead of ID
  • Updated javascript to call class instead of ID
  • Does not use new CSS coding standards

Is the intention with CSS Lint to remove all errors, warnings, or both?

ZenDoodles asked me to upload this patch.

jason.bell’s picture

those files you requested.

Noticed in the previous patch that the id "placeholder" was removed. It looks to me like the placeholder div is generated via the color.js and that farbtastic depends on the id "placeholder". I ended up adding a class on that element to apply style and layout css instead of calling #placeholder.

barraponto’s picture

Status: Needs work » Needs review

run, bot!

markhalliwell’s picture

Title: Clean up css in Color » Clean up CSS/JS in color module
Assigned: StryKaizer » Unassigned
Status: Needs review » Needs work
+++ b/core/modules/color/color.js
@@ -39,8 +39,8 @@ Drupal.behaviors.color = {
+        $('.preview').once('color').append('<div class="gradient-' + i + '"></div>');
+        var gradient = $('.preview .gradient-' + i);

We should be following jQuery Coding Standards. I know this issue just said CSS, but when that changes, so does the markup/JS:

  • Use context and proper event delegations.
  • Use correct variable names for jQuery objects (ie: form => $form).
petermallett’s picture

Status: Needs work » Needs review
FileSize
10.15 KB
26.32 KB

Did some cleanup for JS/jQuery coding standards for variable names & using the context passed to attach. (https://drupal.org/node/172169 as well as https://drupal.org/node/1720586).

I wasn't sure what was meant by "proper event delegations" at this time, so this will probably need another pass.

This work was started during the Drupalcamp ATL code sprint for http://drupalmentoring.org/task/4416

areke’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Needs reroll

This patch needs to be rebased against the current HEAD; it no longer applies.

lokapujya’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
26.2 KB
nod_’s picture

Status: Needs review » Needs work
Issue tags: +JavaScript
Related issues: +#1751334: Selectors clean-up: color module

I'd rather not mess with JS here. Just make the bare minimum changes please. Anything else should be dealt with in #1751334: Selectors clean-up: color module (and there is already a patch fixing things to review).

Also don't forget the JavaScript tag on JS issues. Otherwise JS maintainers can't have a look at it and will reopen the issue and probably complain, thanks :D

lokapujya’s picture

Assigned: Unassigned » lokapujya
Status: Needs work » Needs review
FileSize
19.89 KB

Removed .js changes since they will be handled in another issue. Kept changes needed for using a class instead of the ID.

lokapujya’s picture

25: 1662958-25.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 25: 1662958-25.patch, failed testing.

lokapujya’s picture

Status: Needs work » Needs review
FileSize
19.86 KB

Re-roll.

markhalliwell’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/color/color.js
    @@ -21,7 +21,7 @@
    -      $('<div id="placeholder"></div>').once('color').prependTo(form);
    +      $('<div id="placeholder class="color-picker""></div>').once('color').prependTo(form);
    
    +++ b/core/modules/color/css/color.admin.css
    @@ -27,56 +27,56 @@
    -  [dir="rtl"] #placeholder {
    +  [dir="rtl"] .color-picker {
    

    I think you forgot to remove the #id. Also, let's not change the name, just the specificity here.

  2. +++ b/core/modules/color/preview.html
    @@ -1,7 +1,7 @@
    \ No newline at end of file
    

    There should be a single empty line at the end of the file (for git).

lokapujya’s picture

Assigned: lokapujya » Unassigned
Status: Needs work » Needs review
FileSize
19.86 KB
520 bytes

I kept the placeholder ID, per comment #18. (Something about Farbtastic.) The missing newline was in the existing code. Unassigning because I might not get to work on this for a while.

lokapujya’s picture

30: 1662958-30.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 30: 1662958-30.patch, failed testing.

lokapujya’s picture

I noticed #2268955: Deprecate farbtastic library and remembered this issue, so that placeholder ID can probably be removed with a reroll.

lokapujya’s picture

Issue tags: +Needs reroll
markhalliwell’s picture

Agreed. Let's postpone this until Farbtastic is removed. No sense in trying to clean up something that will end up just being removed anyway.

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.

Manuel Garcia’s picture

Issue tags: -Needs reroll

Just removing the needs reroll tag, since this is going to be postponed for quite some time... farbtastic isnt going to be removed until #1651344: Use color input type in the color.module gets in, and that's postponed until Color input type gets support on all major browsers....

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.

quietone’s picture

Project: Drupal core » Color backport
Version: 9.4.x-dev » 2.x-dev
Component: color.module » Code
Issue tags: -JavaScript +JavaScript

Color has been removed from core, #3270899: Remove Color module from core.