CSSLint has identified selectors within the Block module as candidates for using less-specific selectors. These are some classes with the tabledrag implementation on the Block region assignment interface. In theory the similar markup and classes could be used to provide the same behaviour for other purposes, ie. places other than just the Block admin screen.
Reworking this CSS benefits us by 1) making the CSS lighter, and 2) using selectors that can be reused for other purposes.
Original Issue
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.
- Copy and paste the the stylesheet(s) below into the css lint tool at http://csslint.net 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/block/block.css
| Comment | File | Size | Author |
|---|---|---|---|
| #60 | interdiff-clean-up-css-1662954-60.txt | 591 bytes | kalpaitch |
| #60 | clean-up-css-1662954-60.patch | 1.67 KB | kalpaitch |
| #57 | clean-up-css-1662954-57.patch | 1008 bytes | balis_m |
| #52 | clean-up-css-1662954-52.patch | 1.01 KB | balis_m |
| #52 | interdiff-1662954-44-52.txt | 432 bytes | balis_m |
Comments
Comment #1
mjonesdinero commentedupdate and check locally to see if patch affects other..confirm no effects on other css
Comment #2
mjonesdinero commentedComment #4
mjonesdinero commented#1: block-css-clean-up-1662954.patch queued for re-testing.
Comment #5
mjonesdinero commentedre test the patch if failed again i will re-roll the patch because the error is related to search
Comment #6
mjonesdinero commentedComment #7
droplet commentedsee #1290506: Remove webkit-specific border radius from CSS
EDIT (sorry, can you assign to yourself again)
Comment #8
mjonesdinero commentedThanks droplet
updated patch attach...ignoring the one waning out of 7 warning..
the -webkit-border-radius
Comment #9
droplet commented#blocks is point to TABLE
.block-admin-display-form is point to FORM
This is different but normally that's fine. lets keep it for one more reviewer
Comment #10
barrapontoI guess it's fine. You know, the whole point of disallowing IDs in selectors is actually making styles reusable. What we've got here are headers for sorting widgets (something we use quite often in Drupal). So I guess the right thing would be to change it to something like .draggable-region. And hope contrib starts using it.
Comment #11
barrapontooh i didn't mean to RTBC yet.
Comment #12
BarisW commentedThis can be even shorter:
No need to target the inner td.
Comment #13
BarisW commentedPlus, this exact same styling is used on the Field Display table, but then targeted with 'table.field-ui-overview tr.region-title td'.
Wouldn't it be better to have single draggable form styling (agree with #10), with a generic
.tabledrag .region-title {
font-weight: bold;
}
Then we only have to make sure drupal_add_tabledrag() adds a generic class 'tabledrag' to all forms calling it.
Comment #14
barrapontoYeah, that's what Object Oriented CSS is all about :D Let's do it.
Comment #15
BarisW commentedMenu module? Shouldn't this be theme system?
@mjonesdinero: still working on it? If not, can I assign it to myself?
Comment #16
barraponto@BarisW problem is we can't just add a class to the form or table from within drupal_add_tabledrag, unless we hack the function.
Comment #17
BarisW commentedWell, we can do that in tabledrag.js right? The class only has to be there when JS in enabled anyway, so I think that's the only place where we have to do it.
Let me look into it ;)
Comment #18
BarisW commentedI made it a bit less specific by using selectors like 'table tr.region-message' instead of 'table.field-ui-overview tr.region-message td' and '#blocks tr.region-message'.
What do you think?
Comment #19
BarisW commentedBy the way; I've added the classes to an aexisting bunch of tabledrag class in system.base.css, but shouldn't all those tabledrag classes be in system.admin.css?
Comment #20
barraponto@BarisW I think the class should be there even if there's no JS.
Comment #21
BarisW commented@barraponto: they do. I've made the classes to that they should also work without javascript enabled.
Comment #22
barrapontoAnd yes, they should probably move to base.admin.css
Comment #23
barrapontoOk, so let's push this. The actual CSS has come a long way, thanks a lot @BarisW.
As for moving it to admin.css, I've opened another issue for it: #1750134: Move tabledrag CSS into system.admin.css. Let's keep them separate to get this commited ASAP.
Comment #24
webchickHm. Are you sure this is right? My understanding is system.base.css was only for CSS styles related to functionality which would break if they weren't there. I'm confused why font bolding and italicizing would go there and not in system.admin.css.
I am probably missing a cluebat and if so, just mark back to RTBC with explanation.
Comment #25
BarisW commentedWell, all the other tabledrag styles were already in system.base.css, so I just added the three extra lines there. In system.admin.css I couldn't find any tabledrag selectors, so I thought it wouldn't make sense to add those 3 lines just there.
The question is whether tabledrag is used in the frontend as well? If so, then we can leave it like this. If not, we need to move all tabledrag selectors to the system.admin.css, including the untouched existing ones.
Comment #26
pakmanlhComment #27
pakmanlhComment #28
barraponto@barisw tabledrag is used to sort multiple field values. Will system.admin.css be loaded then?
Anyway, shouldn't drupal_add_library sort that out for us?
Comment #29
barrapontoReroll to apply cleanly, RTBCing again.
Tabledrag stuff is irrevelant to the scope of this patch, particularly in light of #1524414: Rewrite tabledrag.js to use jQuery UI.
Comment #30
xjmCSS changes need manual testing in all browsers and all affected core themes:
Post before-and-after screenshots for one browser/theme.
Comment #31
timwoodLooks like the Patch from #18 needs to be rerolled. It will not apply to the current D8-dev.
Comment #32
ckrinaTry it: the changes were in line numbers.
Comment #33
shyamala commentedThis patch not only affects the Block admin page, but also fixes styles on the manage fields page. There are overlapping styles that are also in issue at #1662986: Clean up css in Field UI. Though the 2 might independently work, we will need a combined patch to actually test the same.
Comment #34
kerasai commentedPatch no longer applies to 8.x-dev. Rerolling.
Comment #35
kerasai commentedRerolled, ready for review.
Comment #36
kerasai commentedComment #37
saltednutReroll is successful and works against 8.x.
Issue still needs screenshots and manual testing per #30
Comment #38
kerasai commentedScreenshots attached, using "Seven" theme. One quick note, the asterisk is not affected by this CSS change. It gets added when dragging the block from region to region or changing weight, not when moving from "disabled" into a region.
Before:

After:

Comment #39
kerasai commentedI'm going along with #25's response to @webchick's question as why to put the code into system.base.css. The "we should put it where other the stuff like it is" reason makes sense to me. IMO this is still very much open to discussion.
Another discussion to have would be to adjust the class names used to be more general and tweak the Block module accordingly. Table that for now, in the spirit of getting this acute fix in place.
Feedback is very much welcomed.
Comment #40
kerasai commentedComment #41
no_angel commentedComment #42
no_angel commentedComment #43
star-szrNo longer applies, probably due to #1987066: Rename files to match CSS file naming convention. Should be a quick reroll.
Comment #44
ishadakota commentedrerolled.
Comment #45
aedwards88 commentedComment #46
aedwards88 commentedComment #47
CaptainWonky commentedComment #48
CaptainWonky commentedThe patch applies ok.
Manual testing turned up a couple of things though:
1 - The
color: #999property of the 'tr.region-message' row is not set after the patch. (Check screenshots)2 - Why has the
font-style: italicof the 'tr.region-message' been added? In the admin/structure/blocks, it seems that the only text styled by this class is already wrapped in<em>tags.Actually, in my opinion, the font-style is a more suitable way of doing this as I don't think the text is trying to be emphasised, but trying to appear different for readability purposes.
*Edit to embed screenies
Comment #49
CaptainWonky commentedComment #50
star-szrThanks @CaptainWonky! It's helpful if you embed your screenshots in your comment, Dreditor makes that easy.
Tweaking title, I keep having to do a double take thinking this is referring to http://lesscss.org/ :)
Comment #51
star-szrAnd as @CaptainWonky pointed out, this no longer needs a reroll.
Comment #52
balis_m commentedI agree with #48, and i rerolled the patch to include his suggestions.
Comment #52.0
balis_m commentedUpdated issue summary.
Comment #53
parthipanramesh commentedIt looks better now! Thank you!
Comment #54
xjm52: clean-up-css-1662954-52.patch queued for re-testing.
Comment #55
BarisW commentedBy the way. we could make this even cleaner, as we probably don't need
table tr. Atris always part of atable, so why not just make it:Comment #56
catchSeems reasonable to do here.
Comment #57
balis_m commentedI agree with #55. So i rerolled the patch again to include his suggestions.
Comment #58
star-szrThanks @balis_m! Setting the status to 'Needs review' so the patch gets tested.
Comment #59
droplet commentedPlease also remove the code in field UI css
Comment #60
kalpaitch commentedI could find two classes in field ui css that appear to be obsolete given the changes to the system.module.css
Comment #61
rootworkSetting to review to trigger testbot.
Comment #62
aboros commentedThe patch in #60 applied cleanly.
Both the block admin page and the field UI works well and looks ok.
I am attaching couple after/before screenshots.
Block admin before:
Block admin after:
Block admin after, block dragged from one region to another:
Field UI before:
Field UI after:
Field UI after, dragging a field to another position:
Setting status to RTBC, i hope it is ok.
Comment #63
aboros commentedhide my screenshots to allow more important files to show up in summary.
Comment #64
alexpottCommitted cdcbb9d and pushed to 8.x. Thanks!