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.
- Copy and paste the the stylesheet(s) below into the css lint tool at CSS LINT and test.
- Fix any warnings or errors the tool finds.
- Patch Drupal 8 locally and make sure the css changes have not broken anything visually.
- Create patch and upload for the testbot.
Files: modules/system/system.admin.css (and system.admin-rtl.css)
| Comment | File | Size | Author |
|---|---|---|---|
| #50 | cleanup-system-admin-css-1663166-50.patch | 9.53 KB | manuel garcia |
| #48 | admin-config.png | 29.01 KB | manuel garcia |
| #47 | admin-config-layout-container.png | 28.64 KB | manuel garcia |
| #47 | cleanup-system-admin-css-1663166-47.patch | 9.54 KB | manuel garcia |
| #41 | interdiff-37-41.patch | 686 bytes | BarisW |
Comments
Comment #1
robloachhttps://gist.github.com/3006391#L3676
Comment #2
manuel garcia commentedI'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.
Comment #3
lewisnymanComment #4
Anonymous (not verified) commentedThings have changed a bit since then, so here's a try at a new patch. Wraith test to follow.
Comment #5
Anonymous (not verified) commentedAttached the wrong patch...
Comment #7
sqndr commentedNeeds more work.
/admin/reports/statuslooks 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:
Should be:
background-color: rgba(0, 0, 0, 0.04);Comment #8
sqndr commentedThis should not be changed. See comment #7.
Attached is a new patch that changes that line.
Comment #9
lewisnymanComment #11
Anonymous (not verified) commentedThanks 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...
Comment #12
lewisnyman8: 1663166-8-cleanup-system-admin-css.patch queued for re-testing.
Comment #13
Anonymous (not verified) commentedBy 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
Comment #14
sqndr commentedAh, cool. I remember you talking about that tool. Thanks for sharing it. ;)
Comment #15
lewisnymanPatch is green, before/after pages have been tested. Let's go.
Comment #16
lewisnymanHey, 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.
Remove units from 0 values
Lets replace '0px' with '0'
Comment #17
Anonymous (not verified) commentedComment #18
Anonymous (not verified) commentedOkay, 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.
Comment #19
sunRecipe for false-positives.
.admin is too short and too common/ambiguous to stand on its own.
Same as my note about borders - these changes require before/after screenshots of Stark.
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).
Comment #20
lewisnymanGood point! Let's fix this here.
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?
Comment #23
lewisnymanSo, 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.
Comment #24
lewisnymanI'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.
Comment #25
tompagabor commentedThere is something wrong, the patch failed:
Comment #26
droplet commentedI'm strongly suggest that don't leave any single layer with .clearfix only. It's less semantic meaning & not so BEM way.
Comment #27
tompagabor commentedReroll.
Needs work(decision?) to do something with the #26 comment.
Comment #28
tompagabor commentedStatus change.
Comment #29
sqndr commented@droplet What would you suggest we do with this clearfix?
Comment #30
tim.plunkettFixing tags.
Comment #31
sqndr commented@droplet: Any ideas on this? Removing this might break everything?
Comment #32
BarisW commentedI 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 wrapperdiv, and also took out the unneeded clearfix classes in the columns.Before:
After:
Comment #33
droplet commentedLooks good.
Comment #34
ashish_nirmohi commentedComment #35
ashish_nirmohi commentedComment #36
lewisnymanThere is no new line on the end of this file. I can't see any other problems.
Comment #37
BarisW commentedGood catch!
Comment #38
lewisnymanI 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.
Comment #39
alexpottWe use this div to style...
from bartik.
from seven
Comment #40
alexpottComment #41
BarisW commentedGood 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:
EDIT: That interdiff should have been a .txt file :(
Comment #42
lewisnyman@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.
Comment #43
alexpottSo we've covered the admin part of this... but what about the clearfix?
Comment #44
lewisnymanBaris 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.
Comment #45
alexpottThe clearfix is important.
Steps to reproduce:
Comment #46
lewisnymanAh I see. Good point. In that case we can try replacing the clearfix class with the
.layout-containerclass. This includes a clearfix.Comment #47
manuel garcia commented@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;).Comment #48
manuel garcia commentedHere is how it looks without any patch applied atm for comparsion:
Comment #49
lewisnymanAh yep that doesn't work :-( I guess we should just go back to good old clearfix?
Comment #50
manuel garcia commentedOK, back to clearfix...
Comment #51
droplet commentedcan we add ".layout-container .clearfix".
Comment #52
BarisW commented@droplet: no, because that introduces left and right margin. See comment #47.
Patch in #50 is RTBC according to me.
Comment #53
lewisnymanRTBC 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.
Comment #54
droplet commentedCan 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.
Comment #55
manuel garcia commentedRight I can see what you mean droplet. I think that such change is out of the scope of this issue though.
Comment #56
droplet commentedIf 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 :).
Comment #57
lewisnyman@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 .clearfixComment #58
alexpottThis 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!