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 CSS LINT 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 CSS LINT 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.admin.css (and system.admin-rtl.css)

Comments

robloach’s picture

manuel garcia’s picture

Status: Active » Needs review
StatusFileSize
new3.14 KB

I've ignored ID selector warnings since these are admin screens and we should be safe there.
I've also ignored heading warnings since I don think they apply to our situation as a CMS.

lewisnyman’s picture

Issue summary: View changes
Issue tags: +CSS, +frontend
Anonymous’s picture

StatusFileSize
new3.14 KB

Things have changed a bit since then, so here's a try at a new patch. Wraith test to follow.

Anonymous’s picture

StatusFileSize
new3.4 KB

Attached the wrong patch...

The last submitted patch, 4: 1663166-2-cleanup-system-admin-css.patch, failed testing.

sqndr’s picture

Status: Needs review » Needs work

Needs more work.

/admin/reports/status looks bad after applying the patch.
Before: http://cl.ly/image/46163L2q3I2Z
After: http://cl.ly/image/2M070b1P2e1v

This is due to the fact that the transparency got removed:

.system-status-report td:nth-child(-n+2) {   
  background-color: rgb(0, 0, 0);
}

Should be: background-color: rgba(0, 0, 0, 0.04);

sqndr’s picture

StatusFileSize
new3.37 KB
+++ b/core/modules/system/css/system.admin.css
@@ -187,39 +187,40 @@ a.module-link-configure {
-  background-color: rgba(0, 0, 0, 0.04);
...
+  background-color: rgb(0, 0, 0);

This should not be changed. See comment #7.

Attached is a new patch that changes that line.

lewisnyman’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 8: 1663166-8-cleanup-system-admin-css.patch, failed testing.

Anonymous’s picture

Status: Needs work » Needs review

Thanks sqndr. I've run this through wraith (all admin pages) against head and there's no visual difference – good.

I've no idea why the language test failed, since this is just CSS. Let's see what happens this time...

lewisnyman’s picture

Anonymous’s picture

StatusFileSize
new3.98 KB

By the way, if anyone's interested, the wraith setup I used is attached. I'll make a post about how to use it in another d.o post I think.

https://github.com/BBC-News/wraith

sqndr’s picture

Ah, cool. I remember you talking about that tool. Thanks for sharing it. ;)

lewisnyman’s picture

Status: Needs review » Reviewed & tested by the community

Patch is green, before/after pages have been tested. Let's go.

lewisnyman’s picture

Status: Reviewed & tested by the community » Needs work

Hey, sorry. I found a few more areas that we could clean up:

Removed all colours declared in system.admin.css

The system module should not have an opinion about color. Lets leave that to the themes.

#system-modules label {
  color: #1d1d1d;
  font-size: 1.15em;
}

Remove units from 0 values
Lets replace '0px' with '0'

#system-modules td details {
  border: 0px;
  margin: 0px;
  height: 20px;
}
Anonymous’s picture

Assigned: Unassigned »
Anonymous’s picture

Assigned: » Unassigned
Status: Needs work » Needs review
StatusFileSize
new5.23 KB

Okay, I've removed all colours and removed the unnecessary 'px'. Wraith testing shows no difference, so I suppose those properties are all overridden by themes.

sun’s picture

  1. +++ b/core/modules/system/css/system.admin.css
    @@ -6,40 +6,40 @@
    -div.admin {
    +.admin {
    

    Recipe for false-positives.

    .admin is too short and too common/ambiguous to stand on its own.

  2. +++ b/core/modules/system/css/system.admin.css
    @@ -83,11 +83,9 @@ small .admin-link:after {
     #system-modules label {
    -  color: #1d1d1d;
    
    @@ -105,22 +103,21 @@ small .admin-link:after {
     #system-modules td details a {
    -  color: #5C5C5B;
    
    @@ -144,16 +141,9 @@ small .admin-link:after {
    -span.admin-enabled {
    -  color: #080;
    

    Same as my note about borders - these changes require before/after screenshots of Stark.

  3. +++ b/core/modules/system/css/system.admin.css
    @@ -251,7 +239,7 @@ table.system-status-report .status-title {
     .system-themes-list-disabled {
    -  border-top: 1px solid #cdcdcd;
    +  border-top: 1px solid;
    
    @@ -270,7 +258,7 @@ table.system-status-report .status-title {
     .theme-default .screenshot {
    -  border: 1px solid #aaa;
    +  border: 1px solid;
    

    Why are we removing / defaulting the border color to black everywhere?

    Shouldn't we default to some basic/minimalistic colors instead? (potentially using built-in color shortnames; black/grey/silver/etc)

    Alternatively, we could consider to drop the borders altogether. (Doing so would require a fair amount of testing + screenshots though.)

    I'd personally prefer to use simplistic color shortnames (so as to produce a minimalistic but yet working output).

lewisnyman’s picture

Status: Needs review » Needs work

Recipe for false-positives.

.admin is too short and too common/ambiguous to stand on its own.

Good point! Let's fix this here.

Why are we removing / defaulting the border color to black everywhere?

Shouldn't we default to some basic/minimalistic colors instead? (potentially using built-in color shortnames; black/grey/silver/etc)

In my mind, the less CSS we write on top of browser defaults the better because then we have less that other themes have to overwrite. I don't think Stark has to "look good" but I don't know if you agree with that?

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 18: 1663166-18-cleanup-system-admin-css.patch, failed testing.

lewisnyman’s picture

So, after #2017257: Create generic layout classes it looks like the admin class is no longer used in system.admin.css, let's just remove the class from the mark up and bid good riddance.

lewisnyman’s picture

Status: Needs work » Needs review
Issue tags: +needs screenshots
StatusFileSize
new8.5 KB

I've reimplemented the patch, completely removing the admin class and not touching the colours.

The admin class isn't being used anymore.
Removing colours without adding them back in Seven is going to cause visual regressions so we should do that elsewhere.

We could do with some before/after screenshots just to make sure we haven't broken anything.

tompagabor’s picture

Status: Needs review » Needs work

There is something wrong, the patch failed:

Checking patch core/modules/system/css/system.admin.css...
error: while searching for:
/**
 * Modules page.
 */
#system-modules thead > tr {
  border: 0;
}
...
error: patch failed: core/modules/system/css/system.admin.css:47
droplet’s picture

+++ b/core/modules/system/templates/admin-page.html.twig
@@ -14,7 +14,7 @@
-<div class="admin clearfix">
+<div class="clearfix">

I'm strongly suggest that don't leave any single layer with .clearfix only. It's less semantic meaning & not so BEM way.

tompagabor’s picture

StatusFileSize
new8.57 KB

Reroll.
Needs work(decision?) to do something with the #26 comment.

tompagabor’s picture

Status: Needs work » Needs review

Status change.

sqndr’s picture

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

@droplet What would you suggest we do with this clearfix?

tim.plunkett’s picture

Issue tags: - +Needs screenshots

Fixing tags.

sqndr’s picture

@droplet: Any ideas on this? Removing this might break everything?

BarisW’s picture

Status: Needs work » Needs review
StatusFileSize
new8.87 KB

I discussed it with Lewis and we couldn't think of a reason why we would need the wrapper anyway. So I removed the whole .admin wrapper div, and also took out the unneeded clearfix classes in the columns.

Before:

<?php
<div class="admin clearfix">
  {{ system_compact_link }}
  {% for container in containers %}
    <div class="layout-column half clearfix">
      {% for block in container.blocks %}
        {{ block }}
      {% endfor %}
    </div>
  {% endfor %}
</div>
?>

After:

<?php
{{ system_compact_link }}
{% for container in containers %}
  <div class="layout-column half">
    {% for block in container.blocks %}
      {{ block }}
    {% endfor %}
  </div>
{% endfor %}
?>
droplet’s picture

Looks good.

ashish_nirmohi’s picture

Issue summary: View changes
ashish_nirmohi’s picture

Issue summary: View changes
lewisnyman’s picture

Status: Needs review » Needs work
+++ b/core/modules/system/templates/admin-page.html.twig
@@ -14,13 +14,11 @@
+{{ system_compact_link }}
+{% for container in containers %}
+  <div class="layout-column half">
+    {% for block in container.blocks %}
+      {{ block }}
+    {% endfor %}
+  </div>
+{% endfor %}
\ No newline at end of file

There is no new line on the end of this file. I can't see any other problems.

BarisW’s picture

Status: Needs work » Needs review
StatusFileSize
new8.84 KB

Good catch!

lewisnyman’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs screenshots
StatusFileSize
new541.85 KB
new614.56 KB
new467.54 KB
new511.61 KB
new517.09 KB
new592 KB
new558.79 KB

I manually tested all the affected pages and they look great. Here are screenshots in Seven and Stark. The extend page looks bad on Stark in HEAD so it is not introduced in this patch.

alexpott’s picture

+++ b/core/modules/system/templates/admin-page.html.twig
@@ -14,13 +14,11 @@
-<div class="admin clearfix">

We use this div to style...

/* Configuration. */
div.admin .right,
div.admin .left {
  width: 49%;
  margin: 0;
}

from bartik.

@media screen and (min-width: 40em) {
  div.admin .right,
  div.admin .left {
    width: 49%;
    margin: 0;
  }
}

from seven

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
BarisW’s picture

Status: Needs work » Needs review
StatusFileSize
new9.7 KB
new686 bytes

Good catch. This piece of CSS doesn't seem to be used anymore. I tested both Seven and Bartik and they work fine without the wrapper div and these CSS rules. They are divided into columns by this piece of CSS:

.layout-column.half {
  width: 50%;
}

EDIT: That interdiff should have been a .txt file :(

lewisnyman’s picture

Status: Needs review » Reviewed & tested by the community

@alexpott Good catch! @BarisW Thanks for the patch.

We look good to go now. Annoying that we missed this duplicate code when we implemented the layout classes.

alexpott’s picture

Status: Reviewed & tested by the community » Needs review
+++ b/core/modules/system/templates/admin-page.html.twig
@@ -14,13 +14,11 @@
-<div class="admin clearfix">

So we've covered the admin part of this... but what about the clearfix?

lewisnyman’s picture

Status: Needs review » Reviewed & tested by the community

Baris and I discussed this in Ghent but I guess we forgot to mention it in the issue. The clearfix class has no effect on the page, as there is no content below the floated content.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs screenshots

The clearfix is important.
Steps to reproduce:

  1. Add any old block to seven's content region beneath the main content block.
  2. Go to admin/config
  3. See visual regression
lewisnyman’s picture

Ah I see. Good point. In that case we can try replacing the clearfix class with the .layout-container class. This includes a clearfix.

manuel garcia’s picture

@LewisNyman here's how that looks like. Layout is fixed, but a new margin on both sides in introduced with the class (margin: 0 2.5em;).

admin-config-layout-container

manuel garcia’s picture

StatusFileSize
new29.01 KB

Here is how it looks without any patch applied atm for comparsion:

lewisnyman’s picture

Ah yep that doesn't work :-( I guess we should just go back to good old clearfix?

manuel garcia’s picture

Status: Needs work » Needs review
StatusFileSize
new9.53 KB

OK, back to clearfix...

droplet’s picture

+++ b/core/modules/system/templates/admin-page.html.twig
@@ -14,10 +14,10 @@
+<div class="clearfix">

can we add ".layout-container .clearfix".

BarisW’s picture

@droplet: no, because that introduces left and right margin. See comment #47.
Patch in #50 is RTBC according to me.

lewisnyman’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs screenshots

RTBC from me as well. Using a clearfix in this way in inline with our CSS standards. We don't need to add 'semantic' classes for styling hooks, just classes that have design meaning.

droplet’s picture

Can I say No ? hehe.

OK. still thinking of when you really want the system looks like #47 or whatever crazy idea. Applying margin to ".layout-whatever-drupal-code-standard-name" always better than ".block .clearfix".

#47 is a simple problem.

Change .layout-container to .layout-col-container or whatever fits Drupal Code Standard.
Or apply .block .layout-container { margin: 0 }

It's a great idea male. Because you soon can apply this pattern to everywhere:

.layout-column-container
--.layout-column
--.layout-column

Thanks.

manuel garcia’s picture

Right I can see what you mean droplet. I think that such change is out of the scope of this issue though.

droplet’s picture

If it's out of the scope, I can't understand why it's also changing / removing other classes name.

OK @Manuel Garcia. I'll keep silence :).

lewisnyman’s picture

@droplet I understand your suggestion, but the idea here is to minimise the default HTML/CSS as much as possible. We don't need to provide classes that aren't used because if someone wants to add some styling to this page then they can override the template file. No one should ever have to write .block .clearfix

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

This issue is an unfrozen change (CSS and templates) as per https://www.drupal.org/core/beta-changes and it's benefits outweigh any disruption. Committed 21765ac and pushed to 8.0.x. Thanks!

  • alexpott committed 21765ac on 8.0.x
    Issue #1663166 by LewisNyman, Manuel Garcia, JamesLefrère, BarisW, sqndr...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.