Follow-up to #2409653: The color module lock/unlock link is not accessible
Problem/Motivation
The color module CSS files are not inline with our CSS standards, and contain quite a few CSSlint errors: http://lewisnyman.co.uk/drupalcore-frontend-toolkit/
Proposed resolution
Refactor the CSS so it fits our standards and produces no CSSlint errors
This issue also uncovered a regression in the UI that was fixed while rewriting the CSS selectors.
Before

After

Remaining tasks
User interface changes
A fix to a UI regression, see above.
API changes
None
Beta phase evaluation
| Issue category | Task because coding standards |
|---|---|
| Unfrozen changes | Unfrozen because it only changes CSS/markup |
| Comment | File | Size | Author |
|---|---|---|---|
| #58 | drupal_color-module-css_2470069_57_0.patch | 24.7 KB | manjit.singh |
| #46 | drupal_color-module-css_2470069_46_0.patch | 24.75 KB | manjit.singh |
| #43 | interdiff-patch29-patch42.txt | 3.25 KB | pjbaert |
| #42 | drupal_color-module-css_2470069_42.patch | 24.72 KB | pjbaert |
| #29 | drupal_color-module-css_2470069_29.patch | 24.79 KB | wadmiraal |
Comments
Comment #1
lewisnymanComment #2
wadmiraal commentedHaving a look it.
Comment #3
wadmiraal commentedRemoved all CSS ID selectors from the the Color module CSS files. This has an impact on JS logic as well as on Bartik, which implements the color logic.
Instead of simply re-using the ID as a class (e.g.: #placeholder to .placeholder), I prefixed them with color- (.color-placeholder). I'm afraid just using the class is too generic, and might apply styles in contexts they were not intended for.
Comment #4
lewisnymanNice! This is going well.
For all the classes that are required by Javascript, we should prefix the class with
.js-. See https://www.drupal.org/node/1887918#formatting.color-palette is a good idea, it is less generic. What we want to do here is to make all the selectors really short, so we could rename this class to
.color-palette__hook.color-palette__down.color-palette__up.color-palette__both.color-palette__lock.color-palette__unlockedComment #5
wadmiraal commentedBrilliant, love the BEM notation. On it.
Comment #6
zakxxi commentedHi,
I have also started to work on it, and on the Bartik side wich is linked,
maybe we need to create a Bartik issue for the "preview" part of color module on the theme settings because a lot of work to do here.
Comment #7
wadmiraal commentedRefactored, using is-* for state. There are no JS only classes; they all relate to presentation, so we shouldn't use js-* classes in this particular case.
Comment #8
wadmiraal commentedStatus change. Sorry, interdiff and patch in #7 did not take #6 into account.
Comment #9
wadmiraal commentedSorry, interdiff is incorrect I see. Re-rolling patch from #7, correcting interdiff.
Comment #10
lewisnymanGood stuff
I think the only class that is required by javascript is this only, so we would only need to add another class that we only use to init the JS:
js-color-paletteIn this situation I think that we would use the common class
.color-palette__hookto apply the background image.When we do this we should also include the component in the selector. So it would be:
etc
Comment #11
wadmiraal commentedOn it.
Comment #12
wadmiraal commentedUpdated.
Switching to .js-color-palette is a good idea, but just be aware Bertik adds a small CSS rule for the form, so now uses js-color-palette. It's small, and the standards say we "shouldn't" use js-* classes in CSS, but that doesn't mean there are no, very rare, cases where we can. Here, for example, the basic color component works fine without any additional styling. Only Bartik adds a slight margin and positioning to make it look a little better.
Or we add a double class, .color-palette.js-color-palette ...
Comment #13
wadmiraal commentedApplied the double CSS class approach (.js-color-palette and .color-palette).
Comment #14
lewisnymanI manually tested this patch and found the up/down behaviour is a bit different from before. It seems to be adding the lines to the wrong elements. See the screenshots:
Before:

After:


Comment #15
wadmiraal commentedYes, I noticed. I opened a separate issue here: #2470769: Color module lock hooks don't show up correctly. This bug is not related to the class changes. Checking out on 8.0.x reveals the same problem. There's already a patch in the linked issue.
In fact, your first screenshot already shows the bug; it's not correctly showing the lines at the third locked lock. Now that I look closer, the locks are actually too low. A lock should sit between 2 fields, not next to a field.
Comment #16
wadmiraal commentedHere's a screenshot of D7. The difference with your "before" screenshot is quite clear:
Comment #17
wadmiraal commentedOk, patch doesn't apply anymore; HEAD has moved. Plus, new HEAD introduces another bug (lock icons not showing up anymore).
Comment #18
wadmiraal commentedWe need to be careful. Color module and Bartik are being updated elsewhere as well. Latest HEAD broke the lock icons. I fixed it in this patch (check interdiff). Also, the locks were not correctly aligned. I fixed it here as well, instead of opening yet another issue.
Comment #19
wadmiraal commentedFor reference, here's the state after applying patch in #18:
The hooks are still incorrect, see #2470769: Color module lock hooks don't show up correctly.
Comment #20
wadmiraal commentedFixing small syntax issue.
Comment #21
lewisnymanI manually tested this patch and it seems like the lock UI is still buggy, it's still not drawing the lines between the right locks?
Also I ran the patched code through CSS lint and we only have one left in

color.admin.css:Comment #22
lewisnymanI think that all the Javascript is broken, I'm not sure why yet though.
Comment #23
wadmiraal commentedAs noted in #15 and #19, the JavaScript has an error, it is reported here #2470769: Color module lock hooks don't show up correctly and the issue already has a patch.
I'll fix the text-indent issue while we're at it.
Comment #24
wadmiraal commentedHere we go again :-)
Comment #25
lewisnymanGreat! Functionally this works as it did before, and you are right about the lock line issue already existing in here. We have no CSSlint errors now! Here are some screenshots to show that the color module integration is working correctly with Bartik.
Comment #26
lewisnymanI think I meant to RTBC this. Sorry.
Comment #28
wadmiraal commentedOk, HEAD moved. Re-rolling patch.
Comment #29
wadmiraal commentedOk, re-rolled.
Comment #30
lewisnymanNice, thanks.
Comment #33
lewisnymanBack to RTBC
Comment #35
lewisnymanComment #36
manjit.singh@LewisNyman Please verify the patch.
Comment #37
lewisnymanComment #38
lewisnymanIt looks like the most recent patch is missing the changes to the color module preview.js
Comment #41
pjbaertPatch #36 was indeed missing the changes to the color module preview.js
I could apply patch 29 without any problems so I queued #29 for a re-test.
Comment #42
pjbaertPlease ignore the last part of my previous comment :)
I re-rolled patch #29
Comment #43
pjbaertAdded the interdiff between patch 29 & 42
Comment #44
lewisnymanOk great! This looks good. Thanks.
Comment #45
alexpottI guess the rtl version needs the more specific selector too.
Comment #46
manjit.singh@alexpott Please verify the patch now.
Comment #47
pjbaertThanks for the updated patch @Manjit.Singh
I added an interdiff to show the difference between patch #42 & yours.
To me, this patch looks fine since you added the more specific selector @alexpott asked for in #45.
Comment #48
lewisnymanI had a quick look over the patch to make sure we haven't missed any other RTL changes and I couldn't see any. Thanks! This will bring our CSSlint error count down by about 85 errors :)
Comment #49
pjbaertI noticed we still have to delete this '\ No newline at end of file'
Comment #50
manjit.singh@pjbaert but if you check it manually there is a blank line after
</div>.Comment #51
pjbaert:) you're right. I checked this manually.
Comment #52
alexpottI can't wait to be able to use csslint to test all commits that change CSS.
Committed 1ea7b90 and pushed to 8.0.x. Thanks!
Thanks for adding the beta evaluation to the issue summary.
Comment #55
alexpottHmmm... the rtl variant is still missing for the more specific selector this patch adds.
Comment #56
alexpottThis can be removed it is the same as the default styling.
Comment #57
alexpottAlso the current patch completely messes up the form - it's a regression from head.
Patch
Head
Comment #58
manjit.singhComment #59
alexpottOkay I see from #16 that we fixing a regression from Drupal 7 here already. I think that fixing that here is scope creep but I guess we can let that slide to get this done. So #57 is not an issue but #55 and #56 are because the scope of this issue is to Refactor color module CSS inline with our CSS standards. #55 would be a regression introduced by the patch and #56 is part of the don't have unnecessary duplicate CSS that if it is not part of our standard - it should be.
Can the usability fix introduced by the patches subsequent to #16 by documented on the issue summary. Thanks.
Comment #60
alexpottPosting the interdiff of 46 to 58. Looks good.
Comment #61
alexpottAdding the followup to fix the hook display to the related issues.
Comment #62
lewisnymanComment #63
lewisnymanOk great, I've updated the issue summary to include the UI fix. Thanks.
Comment #64
alexpottCommitted 271766e and pushed to 8.0.x. Thanks!
Thanks for adding the beta evaluation to the issue summary.