Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Adopting the naming conventions defined at "CSS codings standards for Drupal 8" to layout classes
Proposed resolution
The layout classes core applies to the body tag should be updated appropriately.
.sidebar-first
.sidebar-last
.no-sidebars
.two-sidebars
should be...
.layout-sidebar-first
.layout-sidebar-last
.layout-no-sidebars
.layout-two-sidebars
User interface changes
Not applicable
API changes
Not applicable
Original report by pixelwhip
Comment | File | Size | Author |
---|---|---|---|
#71 | drupal-rename-layout-classes-1912610-71.patch | 15.79 KB | BryanCGreen24 |
Comments
Comment #1
pixelwhip CreditAttribution: pixelwhip commentedComment #2
Shyamala CreditAttribution: Shyamala commentedAdding tags
Comment #2.0
Shyamala CreditAttribution: Shyamala commentedUpdating issue Summary
Comment #3
psynaptic CreditAttribution: psynaptic commentedWhy are we not using the following?
Comment #4
pixelwhip CreditAttribution: pixelwhip commentedThe
.l-*
is the naming convention currently listed in the CSS Standards draft. That is why it is used here.As to whether or not it should be changed, I imagine is up to debate until that doc is no longer draft. I'm personally fine with the abbreviated syntax as that is what is recommended in SMACSS and is more likely to become a convention outside of Drupal.
Comment #5
psynaptic CreditAttribution: psynaptic commentedI just think it's a bit idiosyncratic.
Drupal has long espoused an admirable coding standard to avoid abbreviating the names of things to avoid encoding their meaning. I don't follow SMACSS per se but after reading the linked article it seems that I do indeed do everything described in my regular workflow (except use abbreviated classnames).
In the comments of the linked article, Jonathon Snook uses the following example when responding to a question (indentation/spacing mine):
Not having read through the whole SMACSS documentation, I think the general guidelines it presents makes a lot of sense and I'm all for adopting these patterns within Drupal but I do think the smaller details such as adopting the specific naming of things are much less important.
Does anyone else have strong feelings on this?
Comment #6
pixelwhip CreditAttribution: pixelwhip commentedI don't have strong feelings either way.
Comment #7
oresh CreditAttribution: oresh commented@pixelwhip, @psynaptic,
I think there is no difference from using l- or layout-
The naming conventions will take something like 10 line of documentation, and every themer can read them without any problem, before starting work.
I personally think we should keep the prefixes short, so it takes a little bit less time to understand what does a specific style do. And less time to write and mistake chance is lower: for foreigner not knowing English so good, 'layout' can be spelled with a mistake, but l- is more likely to be ok :)
Comment #8
oresh CreditAttribution: oresh commentedAll class names are proper and work fine. +1
Comment #9
oresh CreditAttribution: oresh commentedComment #10
xjmFor anyone else who did a double-take thinking "No way are those valid class names," those classes start with the lowercase letter L, not the numeral 1.
Comment #11
webchickIf someone can confirm/deny whether or not ".l" specifically is part of the recommendations at http://smacss.com/book/type-layout, that would be great. From my interpretation, it sounds like the method described there is part of the spec, not the specific, obtuse "l-xxx" class names which have screwed up at least 3 people reading this issue (myself included). I really disilke code standards guidelines like "don't ever abbreviate names of things" that have "oh, except for..." after them. :\ Makes it really difficult for reviewers and contributors alike.
Not marking "needs work," but marking "needs review" and assigning to John in case he can shed further light on this. I would much prefer to spell out "layout" here so it doesn't screw up anywhere else, as long as people familiar with SMACSS won't find this a weird Drupalism.
Comment #12
dead_armIn the SMACSS book Snookca does use ".l-" for layout, but that doesn't mean we need to.
In his talk at DrupalconPDX, the question of naming as it applies to classes and so on was put forward during Q&A, and his response was (and I'm paraphrasing) "Find conventions that work for your team."
I don't think that adding ".l-" is an improvement over what we have now. I am in favor of ".layout-". I realize that there could be the introduction of spelling error, brought up in #7, but at least a full word is translatable and adds more context than just a letter.
Comment #13
Sumit kumar CreditAttribution: Sumit kumar commented1: drupal-rename-layout-classes-1054616-1.patch queued for re-testing.
Comment #15
LewisNymanI prefer to use more meaningful names. I think it's hard to argue for '.l-' because it's so minimal. This is coming from someone who didn't realise what the l() function in core did for ages :P
Considering how old the previous patch way it seems easier just to rewrite it from scratch, please check to see if I've missed them somewhere.
Comment #17
LewisNyman15: drupal-rename-layout-classes-1054616-15.patch queued for re-testing.
Comment #19
Anonymous (not verified) CreditAttribution: Anonymous commentedI'm going to be *that person* and ask why, in the age of responsive design and semantic markup, we're still referring to them as "sidebars" and not "asides." Would this be a reasonable change to make? Also, perhaps "aside-before" and "aside-after" would be more reasonable than "aside-first" and "aside-second," since many sites only use one or the other.
Comment #20
echoz CreditAttribution: echoz commented@Abby805, related #2093341: Change the machine name/title of the sidebar regions to something more semantic
Comment #21
LewisNymanThis issue has kind of stalled. The best place to debate the CSS standards is here and they have already been RTBC'd. I think we should follow them for the time being and maybe take the '.l-' vs '.layout-' discussion over there.
Comment #22
LewisNyman15: drupal-rename-layout-classes-1054616-15.patch queued for re-testing.
Comment #24
barraponto CreditAttribution: barraponto commentedHere's a re-roll of #15. I've reverted to
l-
prefixes, following our standards. I hope there's still room to change the standards and adapt CSS later - but for this issue I'm sticking withl-
.Comment #26
barraponto CreditAttribution: barraponto commented24: drupal-rename_layout_classes-1054616-24.patch queued for re-testing.
Comment #27
RainbowArrayAlmost all of the comments above endorse the usage of layout- rather than l- in class names. So if we're going to introduce this change, why not just make the change to what most people would like to see?
Comment #28
barraponto CreditAttribution: barraponto commented@mdrummond I'd rather open a new issue for that.
Comment #29
LewisNymanEveryone who was involved in the creation of the CSS guidelines is not following this issue. It's not immediately clear that we are making a policy change in this issue either. I'd rather we didn't make the decision here.
Comment #30
barraponto CreditAttribution: barraponto commentedAgreed. Here's a policy issue: #2207647: [policy, no patch] Use layout- prefixes instead of l- in CSS Coding Standards
Comment #31
Sumit kumar CreditAttribution: Sumit kumar commented1: drupal-rename-layout-classes-1054616-1.patch queued for re-testing.
Comment #33
Sumit kumar CreditAttribution: Sumit kumar commented24: drupal-rename_layout_classes-1054616-24.patch queued for re-testing.
this patch is needed retest
Comment #35
echoz CreditAttribution: echoz commented#2207647: [policy, no patch] Use layout- prefixes instead of l- in CSS Coding Standards went through deciding to use "layout-" so here's the #24 patch back to using that.
Comment #37
Rajendar Reddy CreditAttribution: Rajendar Reddy commentedApplying patch with reroll and required changes which fixes this issue. Please review.
Comment #39
LewisNyman37: drupal8-rename_layout_classes_to_follow_the_layout_style_naming_convention-1912610-37.patch queued for re-testing.
Comment #41
Rajendar Reddy CreditAttribution: Rajendar Reddy commentedSubmitting patch again.
Comment #42
LewisNymanComment #43
emma.mariaComment #44
emma.mariaComment #45
dead_armUpdating classes in issue to follow naming.
Comment #46
bdevore CreditAttribution: bdevore commentedpatch fails to install on simplytest.me
Comment #47
cfox612 CreditAttribution: cfox612 commentedPatch fails to install
Comment #48
emma.mariaThe patch no longer applies so a reroll is needed.
Comment #49
dead_armRelated: #2234331: Change the body classes to follow Drupal 8 CSS standards proposing to remove sidebar classes altogether
Comment #50
dead_armComment #51
acabouet CreditAttribution: acabouet commentedI'll take on this issue as my first patch!
Comment #52
acabouet CreditAttribution: acabouet commentedComment #53
lokapujyaRerolled.
Someone should look at the uses of l-sidebar in these files and see if it is changing those is relevant to this issue:
core/modules/system/templates/install-page.html.twig
core/themes/seven/maintenance-page.css
core/themes/seven/templates/install-page.html.twig
core/themes/seven/templates/maintenance-page.html.twig
If no one looks at by next week, I'll take a closer look at it.
Comment #54
lokapujyaNeeds work as mentioned in #53.
Comment #55
BryanCGreen24 CreditAttribution: BryanCGreen24 commentedI'll take a peek at this later today.
Comment #56
BryanCGreen24 CreditAttribution: BryanCGreen24 commentedAll the files mentioned in #53 need to be edited to reflect this naming convention change. Patch to come.
Comment #57
BryanCGreen24 CreditAttribution: BryanCGreen24 commentedUgh, sorry...ignore this patch-- it's jacked up. Fixing now.
Comment #58
BryanCGreen24 CreditAttribution: BryanCGreen24 commentedComment #59
BryanCGreen24 CreditAttribution: BryanCGreen24 commentedOK, sorry, this is my first patch. Here's the new-and-improved version.
Comment #60
BryanCGreen24 CreditAttribution: BryanCGreen24 commentedComment #61
lokapujyaThe latest patch is basically an interdiff from #53 which is good to have. We also need the complete patch diffed from 8.x head.
The new changes look good to me.
Comment #62
BryanCGreen24 CreditAttribution: BryanCGreen24 commentedAhhh, OK. Sorry, I'm still learnin'!
Bryan
Comment #63
BryanCGreen24 CreditAttribution: BryanCGreen24 commentedHmm...I get this error when I try applying the patch from #53:
error: core/modules/block/custom_block/src/Tests/CustomBlockListTest.php: No such file or directory
I even re-cloned the D8 repo just to make sure I wasn't missing any files, but there's no 'custom_block' directory in /core/modules/block/...what kind of noob mistake am I making?
Thanks!
Bryan
Comment #64
lokapujyaThat file got renamed since my patch. So, now it needs a reroll, and then you can apply your patch. See https://drupal.org/patch/reroll.
Comment #65
BryanCGreen24 CreditAttribution: BryanCGreen24 commentedOK, here is the patch from #53 re-rolled.
Auto-merge, no conflicts.
Comment #66
BryanCGreen24 CreditAttribution: BryanCGreen24 commentedIf the re-rolled patch from #65 passes testing, I'll add my patch from #59.
Comment #67
BryanCGreen24 CreditAttribution: BryanCGreen24 commentedWhew! OK, here is the patch that combines the re-rolled patch from #65 with the patch I created on comment #59.
Many thanks to lokapujya for his patience and guidance!
Bryan
Comment #68
lokapujyaUn-needed new extra blank line. Other than that, it looks good to me. You can also remove the "Needs reroll" tag.
Comment #69
amitgoyal CreditAttribution: amitgoyal commentedPlease review updated patch as per fixes in #68.
Please note that changes in file core/modules/block_content/src/Tests/BlockContentListTest.php are no longer required as those changes are already in core.
Comment #71
BryanCGreen24 CreditAttribution: BryanCGreen24 commentedPatch from #67 with extra newline removed.
Comment #72
BryanCGreen24 CreditAttribution: BryanCGreen24 commentedComment #73
LewisNymanI went through all the themes, and install.php, and I don't see any layout bugs. I also had a look through the themes and modules to look for remaining .l- classes and I couldn't find any.
Comment #74
webchickAwesome, much better. :) Thanks for all the hard work on this.
Committed and pushed to 8.x. Thanks!