Suggested commit message

git commit -m 'Issue #2419475 by pjbaert, DickJohnson, emma.maria, Luxian, LewisNyman, tadityar, idebr, floretan, lauriii: Clean up the "Featured bottom" component in Bartik '

Problem/Motivation

Bartik's code needs to meet current Drupal coding standards.

Proposed resolution

This issue takes a specific section of Bartik's code, it acts as a "component" issue and improves that section of code with minimal impact on the rest of Bartik's codebase.

This issue aims to clean up and properly format the CSS and templates files without breaking Bartik visually.

This issue primarily looks at the css/components/featured-bottom.css file.

Work that needs to be included in patches for this issue are fully outlined in the META issue #1342054: [META] Clean up templates and CSS.

Remaining tasks

  • Write a patch
  • Review the patch - code review and visual changes
  • Upload screenshots to show nothing/something is broken on the frontend

User interface changes

None, we are cleaning up CSS and markup in templates. The use of Bartik's UI and design will stay the same.

API changes

n/a

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Task because it is a code clean up overhaul of a theme.
Unfrozen changes Unfrozen because it only refactors CSS and templates, no changes to UI or APIs
Prioritized changes The main goal of this issue is usability and performance. We want Bartik code to be up to date and something to be proud of.
Disruption No disruption it's only refactoring code not changing how to use the theme
CommentFileSizeAuthor
#45 clean_up_the_featured-2419475-45.patch5.15 KBlewisnyman
#45 interdiff.txt1.23 KBlewisnyman
#43 interdiff-39-43.txt1.89 KBemma.maria
#43 bartik-clean-featured-bottom-2419475-43.patch5.08 KBemma.maria
#39 inter-diff-2419475-35-39.txt1.68 KBLuxian
#39 bartik-clean-featured-bottom-2419475-39.patch4.4 KBLuxian
#35 no-need-for-padding.png136.77 KBpjbaert
#35 bartik-clean-featured-bottom-2419475-35.patch4.41 KBpjbaert
#35 interdiff-bartik-32-35.txt1.95 KBpjbaert
#32 interdiff-28-32.txt1.95 KBtadityar
#32 bartik-clean-featured-bottom-2419475-32.patch4.46 KBtadityar
#30 interdiff-bartik-23-28.txt4 KBpjbaert
#28 2419475-28-after.png222.1 KBpjbaert
#28 bartik-clean-featured-bottom-2419475-28.patch4.95 KBpjbaert
#23 2419475-23-after.png212.71 KBpjbaert
#23 bartik-clean-featured-bottom-2419475-23.patch4.04 KBpjbaert
#23 interdiff-bartik-clean-featured-bottom-23.txt509 bytespjbaert
#20 bartik-clean-featured-bottom-2419475-19.patch3.55 KBpjbaert
#20 interdiff-bartik-clean-featured-bottom-19.txt1.47 KBpjbaert
#16 2419475-11-after.gif95 KBidebr
#15 Screen Shot 2015-03-14 at 10.18.13 pm.png280.04 KBkyuubi
#13 Screen Shot 2015-03-04 at 15.01.41.png350.04 KBemma.maria
#11 after.png161.26 KBDickJohnson
#11 interdiff-2410475-5-12.txt2.95 KBDickJohnson
#11 bartik-clean-featured-bottom-2419475-11.patch4.04 KBDickJohnson
#6 Screen Shot 2015-02-11 at 13.00.28.png131.62 KBemma.maria
#5 interdiff-2419475-4-5.txt443 bytesDickJohnson
#5 bartik-clean-featured-bottom-2419475-5.patch4 KBDickJohnson
#4 bartik-clean-featured-bottom-2419475-4.patch3.93 KBDickJohnson

Comments

idebr’s picture

I don't think there currently is a css/components/featured-bottom.css file in Bartik. Is this a followup for an issue that is currently being worked on?

[edit] This issue is a followup for #1164784: “Triptych” term is not widely understood; add "Featured top" and "Featured bottom"

idebr’s picture

Status: Active » Postponed
idebr’s picture

Status: Postponed » Active
Issue tags: +frontend, +CSS
DickJohnson’s picture

Status: Active » Needs review
StatusFileSize
new3.93 KB

Started to work on this. Replaced id's from templates with classes and matched CSS with this change.

Sending to testbot.

DickJohnson’s picture

Fixed coding standard issue.

emma.maria’s picture

Issue summary: View changes
StatusFileSize
new131.62 KB

The latest patch breaks featured-bottom visually in a big way. Can we fix this? Then I will suggest further changes to the CSS.


 

+++ b/core/themes/bartik/templates/page.html.twig
@@ -163,8 +163,8 @@
-      <div id="featured-bottom-wrapper">
-        <aside id="featured-bottom" class="clearfix" role="complementary">
+      <div class="featured-bottom-wrapper">
+        <aside class="featured-bottom" class="clearfix" role="complementary">

The layout is broken as we have two declarations of class and we lose the second one with clearfix. Need to combine and keep the clearfix class please.

emma.maria’s picture

Status: Needs review » Needs work
Issue tags: +Novice
emma.maria’s picture

Assigned: Unassigned » emma.maria
harshil.maradiya’s picture

Hi Emma,

I have applied this patch on my system but not able to reproduce this issue as per attached screen shot
would you please provide exact step to reproduce.

As per #6 it is already fix in #5

Please let me know if you need more information on same .

Thanks & Regards
Harshil Maradiya

DickJohnson’s picture

Issue tags: +Needs reroll
DickJohnson’s picture

StatusFileSize
new4.04 KB
new2.95 KB
new161.26 KB

Rerolled this. Changed also the class-structure to be similar than it is in featured-top -component.

After the patch has been applied, featured-bottom looks like:
After

DickJohnson’s picture

Status: Needs work » Needs review
emma.maria’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: -Novice, -Needs reroll
StatusFileSize
new350.04 KB

The grey background no longer stretches across the full width of the screen.

emma.maria’s picture

Assigned: emma.maria » Unassigned
kyuubi’s picture

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

Hi,

I have tested patch #11 and I cannot replicate issue state in #13.

The bars go full with.

Attaching screenshot.

idebr’s picture

Issue summary: View changes
Status: Needs review » Needs work
StatusFileSize
new95 KB

@kyuubi The issue mentioned in #13 is correct and is also visible in your own screenshot. For a comparison I made a before/after screencap:

emma.maria’s picture

Issue summary: View changes
emma.maria’s picture

Issue tags: +Novice, +Needs reroll
pjbaert’s picture

I rerolled this.
I couldn't find fix the issue as mentioned in #13 yet, but I'll try to work on that later this week.

pjbaert’s picture

Well let's add the files then...

emma.maria’s picture

Status: Needs work » Needs review

Firing testbot to check the patch

emma.maria’s picture

Status: Needs review » Needs work
pjbaert’s picture

Status: Needs work » Needs review
StatusFileSize
new509 bytes
new4.04 KB
new212.71 KB

I updated the patch & fixed the bug mentioned in #13.
The grey background stretches back across the full width of the screen.

Status: Needs review » Needs work

The last submitted patch, 23: bartik-clean-featured-bottom-2419475-23.patch, failed testing.

pjbaert’s picture

Status: Needs work » Needs review

Patch passed after re-testing.

emma.maria’s picture

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

Code review.

I noticed a few issues.

  1. +++ b/core/themes/bartik/templates/page.html.twig
    @@ -159,8 +159,8 @@
    +        <aside class="featured-bottom-inner clearfix" role="complementary">
    

    .featured-bottom-inner needs to be changed to .featured-bottom__inner to represent a descendant of the featured-bottom component using BEM markup. See the featured-top markup for examples. Also this is a great article to explain it http://csswizardry.com/2013/01/mindbemding-getting-your-head-round-bem-syntax/

  2.  

  3. .region-featured-bottom-first,
    .region-featured-bottom-second,
    .region-featured-bottom-third {
     ...
    }
    

    There are so many declarations of the above selectors. As it is declaring all of the regions in featured-bottom we can just say .featured-bottom .region instead.

pjbaert’s picture

Thanks for the feedback @emma.maria

I processed the remarks you mentioned in #27.

pjbaert’s picture

Status: Needs work » Needs review
pjbaert’s picture

StatusFileSize
new4 KB

Seems like I forgot to add the interdiff...

idebr’s picture

Status: Needs review » Needs work

@pjbaert Great changes, thanks :)

Some things I noticed:

  1. +++ b/core/themes/bartik/css/components/featured-bottom.css
    @@ -1,29 +1,26 @@
       padding: 0 20px 0;
    

    The last 0 can be removed, as it is infered by the first value, eg. padding: 0 20px;

  2. +++ b/core/themes/bartik/css/components/featured-bottom.css
    @@ -45,43 +40,43 @@
    -#featured-bottom #block-user-login .form-text {
    +.featured-bottom__inner #block-user-login .form-text {
    ...
    -#featured-bottom #block-user-online p {
    ...
    -#featured-bottom-third #block-node-syndicate {
    +.featured-bottom-third #block-node-syndicate {
    ...
    -#featured-bottom #block-search-form .form-type-search input {
    +.featured-bottom__inner #block-search-form .form-type-search input {
    ...
    -#featured-bottom-second #block-system-powered-by {
    +.featured-bottom-second #block-system-powered-by {
    ...
    -#featured-bottom-third #block-system-powered-by {
    +.featured-bottom-third #block-system-powered-by {
    

    Is it possible to rewrite the id selector to a class? The CSS guidelines highly discourage the use of using ids for styling, because of its specificity.

  3. +++ b/core/themes/bartik/css/layout.css
    @@ -6,13 +6,13 @@
    -.layout-container {
    +.layout-container, .featured-bottom__inner {
    

    Instead of extending the selector, apply the class 'layout-container' to the html to apply its styling. This makes for much cleaner css selectors and maintenance.

  4. +++ b/core/themes/bartik/css/print.css
    @@ -27,13 +27,13 @@ body {
    -#featured-bottom-wrapper {
    +.featured-bottom  {
    

    There's 2 spaces between the selector and the {. The CSS coding standards mandate a single space, eg. .featured-bottom {

  5. +++ b/core/themes/bartik/css/print.css
    @@ -27,13 +27,13 @@ body {
    +.featured-bottom-first, .featured-bottom-second, .featured-bottom-third {
    

    Let's place each selector on a new line instead of creating one long line.

tadityar’s picture

Status: Needs work » Needs review
StatusFileSize
new4.46 KB
new1.95 KB

Created a patch addressing 1,3,4, and 5. Other css files still uses ID for block thingy, should we change it or leave it as is?

idebr’s picture

Status: Needs review » Needs work

@tadityar Thanks for working on this issue! We should definitely try to rewrite it unless there is a valid reason to leave it.

I noticed a regression in the latest interdiff:

+++ b/core/themes/bartik/templates/page.html.twig
@@ -160,7 +160,7 @@
-        <aside class="featured-bottom__inner clearfix" role="complementary">
+        <aside class="layout-container clearfix" role="complementary">

The class .featured-bottom__inner was removed in your patch, but it is still referenced in the complete patch file as a selector.

emma.maria’s picture

I also noticed the following...

These classes are currently not in Core so they are doing nothing. I'm not sure how long this has been the case but I suppose we should fix this code.

.featured-bottom-second

.featured-bottom-third

pjbaert’s picture

Status: Needs work » Needs review
StatusFileSize
new1.95 KB
new4.41 KB
new136.77 KB

Posting a small update here:
All featured-bottom__inner references are updated to layout-container

.region-featured-bottom-second {
   padding: 20px 5px 30px;
}

I noticed that there was no use for the above code snippet
Since this part beneath was overruling it (see attached screenshot):

@media all and (min-width: 560px) {
  .featured-bottom .region {
    float: left; /* LTR */
    position: relative;
    box-sizing: border-box;
    padding: 20px 15px 30px;
    width: 33%;
  }
...

So a short recap of what we still need to do:

1. Rewrite the id selectors to a classes (mentioned in #31)

+++ b/core/themes/bartik/css/components/featured-bottom.css
@@ -45,43 +40,43 @@
-#featured-bottom #block-user-login .form-text {
+.featured-bottom__inner #block-user-login .form-text {
...
-#featured-bottom #block-user-online p {
...
-#featured-bottom-third #block-node-syndicate {
+.featured-bottom-third #block-node-syndicate {
...
-#featured-bottom #block-search-form .form-type-search input {
+.featured-bottom__inner #block-search-form .form-type-search input {
...
-#featured-bottom-second #block-system-powered-by {
+.featured-bottom-second #block-system-powered-by {
...
-#featured-bottom-third #block-system-powered-by {
+.featured-bottom-third #block-system-powered-by {

2. fix this code of these classes who aren't in Core. (see #34)

.featured-bottom-second
.featured-bottom-third

pjbaert’s picture

Status: Needs review » Needs work
emma.maria’s picture

.layout-container is only used to define the grid on the page and it is added to every section of Bartik. We should not use that selector to style any specific elements. Take a look at page.html.twig to see it's use. Please put back .featured-bottom__inner.

Luxian’s picture

Assigned: Unassigned » Luxian

Checking this issue.

Luxian’s picture

Status: Needs work » Needs review
StatusFileSize
new4.4 KB
new1.68 KB

Here is a new patch. I've changed the .layout-container selector used inside featured-bottom.css to .featured-bottom and things didn't break. Class featured-bottom__inner it's not needed and I left it out.

Luxian’s picture

Assigned: Luxian » Unassigned
emma.maria’s picture

Status: Needs review » Needs work

We are almost there! Just a few more things to improve.

  1. .featured-bottom #block-user-login .form-text {
      width: 185px;
    }
    .featured-bottom #block-user-online p {
      margin-bottom: 0;
    }
    .featured-bottom #block-node-syndicate h2 {
      overflow: hidden;
      width: 0;
      height: 0;
    }
    .featured-bottom-third #block-node-syndicate {
      text-align: right;
    }
    .featured-bottom .search-block-form .form-type-search input {
      width: 185px;
    }
    .featured-bottom-second #block-system-powered-by {
      text-align: center;
    }
    .featured-bottom-third #block-system-powered-by {
      text-align: right;
    }
    

    We need to replace all instances of IDs with sensible classes found on all of the blocks mentioned above.

  2.  

  3. .featured-bottom-second
    .featured-bottom-third

    do not exist in the markup.
    Please replace with the current existing classes...

    .region-featured-bottom-second
    region-featured-bottom-third

    etc.

  4.  

  5. I will raise a follow up to discuss the styles above which add design touches to certain blocks added to Featured Bottom. For eg. We can remove the specific
floretan’s picture

Looking into it, the IDs mentioned in the first point of #41 are not there anymore, and for some of them there are no usable classes or IDs to replace them. We would need to add them somehow before the CSS code can work again.

emma.maria’s picture

Status: Needs work » Needs review
StatusFileSize
new5.08 KB
new1.89 KB

I have fixed the last parts of the file that I pointed out in #41. I have listed the reasoning for the changes I added below to help.
 

  1. -.featured-bottom #block-search-form .form-type-search input {
    -  width: 185px;
    -}
    
    -.featured-bottom #block-user-login .form-text {
    +.featured-bottom input:not(.form-submit) {
       width: 185px;
     }

    Instead of declaring widths on many inputs we should just say all form inputs that are not buttons should print at that width,

  2.  

  3. -.featured-bottom #block-user-online p {
    -  margin-bottom: 0;

    The user online block no longer prints p tags.

  4.  

  5. -.featured-bottom-third #block-node-syndicate {
    -  text-align: right;
    -}
    
    +.region-featured-bottom-third .feed-icon {
    +  float: right;
     }

    We have changed how the feed icon works, it is now uses text replacement so text-align:right breaks this. So instead I targeted the icon specifically to float right.

  6.  

  7. -.featured-bottom #block-node-syndicate h2 {
    -  overflow: hidden;
    -  width: 0;
    -  height: 0;
    -}

    We have had other issues in Core which removes the forceful hiding of block titles with CSS. Therefore I removed this code, users can use block settings instead.

  8.  

  9. -.featured-bottom-second #block-system-powered-by {
    +.region-featured-bottom-second .block-system-powered-by-block {
       text-align: center;
     }

    Removed this purely because it doesn't look right when put alongside other blocks with text in. Removed with recommendation from lewisnyman.

 

Also note that I have added a block class suggestion to Classy's and Bartik's block Twig template on recommendation from lauriii and lewisnyman. Some blocks that are provided by Drupal on install such as the Powered by block have no usable classes out of the box.

This is what you are given out of the box right now:
 
<div id="block-poweredbydrupal-2" class="contextual-region block block-system" role="complementary">
 
A beginner suggested that I should just use the ID. Which is bad bad bad! The current markup will definitely encourage bad practices.

Therefore I added the following variable to the Set Classes array in the block template...
 
'block-' ~ plugin_id|clean_class,
 
and it worked perfectly for what I needed, which was a class for the block that could be used no matter how many instances of the block on the page or where it was positioned.

lewisnyman’s picture

Status: Needs review » Needs work
  1. +++ b/core/themes/bartik/css/components/featured-bottom.css
    @@ -1,43 +1,35 @@
       background-color: #f0f0f0;
       background: rgba(30, 50, 10, 0.08);
    

    We can remove all color properties that are being used as fallbacks for rgba properties because we no longer support browsers that do not support rgba.

  2. +++ b/core/themes/bartik/css/components/featured-bottom.css
    @@ -1,43 +1,35 @@
    +.featured-bottom .region {
       box-sizing: border-box;
    

    I think we can remove border-box from here as we aren't setting a width on mobile. border-box is already applied on desktop

  3. +++ b/core/themes/bartik/css/components/featured-bottom.css
    @@ -45,43 +37,29 @@
       line-height: 1;
    ...
       line-height: 1.3;
    

    In most files I think we also add em to the end of line-height declarations.

  4. +++ b/core/themes/bartik/css/components/featured-bottom.css
    @@ -45,43 +37,29 @@
    -#featured-bottom .block ul li,
    -#featured-bottom .block ol li {
    +.featured-bottom .block ul li,
    +.featured-bottom .block ol li {
    ...
    -#featured-bottom .block ul,
    -#featured-bottom .block ol {
    +.featured-bottom .block ul,
    +.featured-bottom .block ol {
    

    We can remove .block from these selectors and they seem to work the same

lewisnyman’s picture

Status: Needs work » Needs review
StatusFileSize
new1.23 KB
new5.15 KB
lauriii’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/core/themes/bartik/templates/block.html.twig
@@ -40,6 +40,7 @@
+    'block-' ~ plugin_id|clean_class,

+++ b/core/themes/classy/templates/block/block.html.twig
@@ -36,6 +36,7 @@
+    'block-' ~ plugin_id|clean_class,

I give +1 for this class being added. Without this theming blocks is almost impossible because there is no existing class to match all the instances of specific block plugin.

Anyway the patch fixes the problem that is being fixed in the parent meta issue. There is no blocks by default set to the featured bottom regions but I tested adding some random blocks with different combination and the functionality has remained the same as before the patch.

emma.maria’s picture

Issue summary: View changes

Suggested commit message

git commit -m 'Issue #2419475 by pjbaert, DickJohnson, emma.maria, Luxian, LewisNyman, tadityar, idebr, floretan, lauriii: Clean up the "Featured bottom" component in Bartik '

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 3a0002f and pushed to 8.0.x. Thanks!

Thanks for adding the beta evaluation to the issue summary.

  • alexpott committed 3a0002f on 8.0.x
    Issue #2419475 by pjbaert, DickJohnson, emma.maria, Luxian, LewisNyman,...

Status: Fixed » Closed (fixed)

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