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.

  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/block/block.css

Comments

mjonesdinero’s picture

StatusFileSize
new842 bytes

update and check locally to see if patch affects other..confirm no effects on other css

mjonesdinero’s picture

Status: Active » Needs review

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

The last submitted patch, block-css-clean-up-1662954.patch, failed testing.

mjonesdinero’s picture

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

#1: block-css-clean-up-1662954.patch queued for re-testing.

mjonesdinero’s picture

re test the patch if failed again i will re-roll the patch because the error is related to search

mjonesdinero’s picture

Assigned: Unassigned » mjonesdinero
droplet’s picture

Assigned: mjonesdinero » Unassigned
Status: Needs review » Needs work
+++ b/core/modules/block/block.admin.cssundefined
@@ -20,6 +20,7 @@ a.block-demo-backlink:link,
+  -webkit-border-radius: 0 0 10px 10px;

see #1290506: Remove webkit-specific border radius from CSS

EDIT (sorry, can you assign to yourself again)

mjonesdinero’s picture

Assigned: Unassigned » mjonesdinero
Status: Needs work » Needs review
StatusFileSize
new551 bytes

Thanks droplet

updated patch attach...ignoring the one waning out of 7 warning..
the -webkit-border-radius

droplet’s picture

#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

barraponto’s picture

Status: Needs review » Reviewed & tested by the community

I 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.

barraponto’s picture

Status: Reviewed & tested by the community » Needs review

oh i didn't mean to RTBC yet.

BarisW’s picture

Status: Needs review » Needs work
+++ b/core/modules/block/block.admin.cssundefined
@@ -1,12 +1,12 @@
+.block-admin-display-form .region-title td {

This can be even shorter:

.block-admin-display-form .region-title { 
  font-weight: bold;
}

No need to target the inner td.

BarisW’s picture

Plus, 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.

barraponto’s picture

Component: block.module » menu.module
Status: Needs work » Needs review

Yeah, that's what Object Oriented CSS is all about :D Let's do it.

BarisW’s picture

Component: menu.module » theme system

Menu module? Shouldn't this be theme system?

@mjonesdinero: still working on it? If not, can I assign it to myself?

barraponto’s picture

@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.

BarisW’s picture

Assigned: mjonesdinero » BarisW

Well, 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 ;)

BarisW’s picture

StatusFileSize
new1.92 KB

I 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?

BarisW’s picture

By 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?

barraponto’s picture

Assigned: BarisW » Unassigned

@BarisW I think the class should be there even if there's no JS.

BarisW’s picture

@barraponto: they do. I've made the classes to that they should also work without javascript enabled.

barraponto’s picture

And yes, they should probably move to base.admin.css

barraponto’s picture

Status: Needs review » Reviewed & tested by the community

Ok, 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.

webchick’s picture

Status: Reviewed & tested by the community » Needs review

Hm. 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.

BarisW’s picture

Well, 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.

pakmanlh’s picture

Assigned: Unassigned » pakmanlh
pakmanlh’s picture

Assigned: pakmanlh » Unassigned
barraponto’s picture

@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?

barraponto’s picture

Status: Needs review » Reviewed & tested by the community

Reroll 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.

xjm’s picture

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

CSS changes need manual testing in all browsers and all affected core themes:

  1. Test pages where the relevant classes are used without the patch applied.
  2. Apply the patch, clear the site and browser caches, and test again. Confirm that there are no changes or regressions.

Post before-and-after screenshots for one browser/theme.

timwood’s picture

Issue tags: +Needs reroll

Looks like the Patch from #18 needs to be rerolled. It will not apply to the current D8-dev.

ckrina’s picture

Status: Needs work » Needs review
StatusFileSize
new1.51 KB

Try it: the changes were in line numbers.

shyamala’s picture

This 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.

kerasai’s picture

Assigned: Unassigned » kerasai

Patch no longer applies to 8.x-dev. Rerolling.

kerasai’s picture

Assigned: kerasai » Unassigned
StatusFileSize
new1023 bytes

Rerolled, ready for review.

kerasai’s picture

Issue tags: +SprintWeekend2013
saltednut’s picture

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

Reroll is successful and works against 8.x.

Issue still needs screenshots and manual testing per #30

CSS changes need manual testing in all browsers and all affected core themes:

Test pages where the relevant classes are used without the patch applied.
Apply the patch, clear the site and browser caches, and test again. Confirm that there are no changes or regressions.
Post before-and-after screenshots for one browser/theme.

kerasai’s picture

Issue tags: -Needs screenshots
StatusFileSize
new43.75 KB
new42.42 KB

Screenshots 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:
before.jpg

After:
after.jpg

kerasai’s picture

Title: Clean up css in Block » Use Less-Sepecific tabledrag Selectors
Status: Needs work » Needs review

I'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.

kerasai’s picture

Title: Use Less-Sepecific tabledrag Selectors » Use Less-Specific tabledrag Selectors
no_angel’s picture

Assigned: Unassigned » no_angel
no_angel’s picture

Assigned: no_angel » Unassigned
star-szr’s picture

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

No longer applies, probably due to #1987066: Rename files to match CSS file naming convention. Should be a quick reroll.

ishadakota’s picture

Status: Needs work » Needs review
StatusFileSize
new1.04 KB

rerolled.

aedwards88’s picture

Assigned: Unassigned » aedwards88
aedwards88’s picture

Assigned: aedwards88 » Unassigned
CaptainWonky’s picture

Assigned: Unassigned » CaptainWonky
CaptainWonky’s picture

Title: Use less-specific tabledrag selectors » Use Less-Specific tabledrag Selectors
Assigned: Unassigned » CaptainWonky
StatusFileSize
new12.3 KB
new12.43 KB

The patch applies ok.

Manual testing turned up a couple of things though:

1 - The color: #999 property of the 'tr.region-message' row is not set after the patch. (Check screenshots)

2 - Why has the font-style: italic of 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

beforeafter

CaptainWonky’s picture

Assigned: CaptainWonky » Unassigned
Status: Needs review » Needs work
star-szr’s picture

Title: Use Less-Specific tabledrag Selectors » Use less-specific tabledrag selectors

Thanks @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/ :)

star-szr’s picture

Title: Use Less-Specific tabledrag Selectors » Use less-specific tabledrag selectors
Assigned: CaptainWonky » Unassigned
Issue tags: -Needs reroll

And as @CaptainWonky pointed out, this no longer needs a reroll.

balis_m’s picture

Status: Needs work » Needs review
StatusFileSize
new432 bytes
new1.01 KB

I agree with #48, and i rerolled the patch to include his suggestions.

balis_m’s picture

Issue summary: View changes

Updated issue summary.

parthipanramesh’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

It looks better now! Thank you!

xjm’s picture

52: clean-up-css-1662954-52.patch queued for re-testing.

BarisW’s picture

By the way. we could make this even cleaner, as we probably don't need table tr. A tr is always part of a table, so why not just make it:

tr.region-title {
  font-weight: bold;
}
tr.region-message {
  color: #999;
}
tr.region-populated {
  display: none;
}
tr.add-new .tabledrag-changed {
  display: none;
}
catch’s picture

Status: Reviewed & tested by the community » Needs work

Seems reasonable to do here.

balis_m’s picture

StatusFileSize
new1008 bytes

I agree with #55. So i rerolled the patch again to include his suggestions.

star-szr’s picture

Status: Needs work » Needs review

Thanks @balis_m! Setting the status to 'Needs review' so the patch gets tested.

droplet’s picture

Status: Needs review » Needs work

Please also remove the code in field UI css

kalpaitch’s picture

I could find two classes in field ui css that appear to be obsolete given the changes to the system.module.css

rootwork’s picture

Status: Needs work » Needs review

Setting to review to trigger testbot.

aboros’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new144.54 KB
new144.34 KB
new144.83 KB
new146.16 KB
new145.77 KB
new149.02 KB

The 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.

aboros’s picture

hide my screenshots to allow more important files to show up in summary.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed cdcbb9d and pushed to 8.x. Thanks!

  • Commit cdcbb9d on 8.x by alexpott:
    Issue #1662954 by balis_m, mjonesdinero, kalpaitch, IshaDakota, kerasai...

Status: Fixed » Closed (fixed)

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