Problem/Motivation

According to Drupal's CSS Standards...

Layout — macro arrangement of a web page, including any grid systems.

Therefore layout.css should only contain the basic page layout "grid" styles and nothing specific to particular components on the page
for eg. Float styles for sidebar should go into sidebar.css and padding styles for a particular component should go into the component files being referenced etc

Proposed resolution

Move any styles that do not belong in layout.css out into the relevant component files found in css/component/....
Clean up the relevant layout styles left in the file, make sure the CSS follows the CSS standards here.

Remaining tasks

Write a patch.
Visual review of the patch to check that nothing has changed + screenshots - we are not changing the design!
Code review of the patch to check the work is correct.

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
#68 2398451-68.patch14.34 KBidebr
#65 2309451-65.patch14.54 KBidebr
#61 2398451-61.patch14.5 KBidebr
#58 interdiff-2398451-55-58.txt1.58 KBDickJohnson
#58 2398451-58.patch14.53 KBDickJohnson
#55 2398451-55.patch15.2 KBidebr
#51 2398451-51.patch15.18 KBemma.maria
#50 2398451-50.patch15.15 KBidebr
#50 interdiff-50-48.txt377 bytesidebr
#48 2398451-48.patch15.18 KBidebr
#48 interdiff-48-46.txt563 bytesidebr
#47 before-after-patch-desktop.png645.11 KBemma.maria
#47 before-after-patch-tablet.png637.5 KBemma.maria
#47 before-after-patch-mob.png629.55 KBemma.maria
#47 region-header-regression.png10.29 KBemma.maria
#47 region-header-no-margin.png71.2 KBemma.maria
#47 region-header-margin.png97.69 KBemma.maria
#46 2398451-44.patch14.97 KBidebr
#44 2398451-44-after.png378.78 KBidebr
#44 2398451-44-before.png365.49 KBidebr
#43 interdiff-34-41.txt5.44 KBLewisNyman
#41 2398451-41.patch12.4 KBsaki007ster
#35 mobile-footer-after.png34.87 KBDickJohnson
#35 mobile-footer-before.png36.7 KBDickJohnson
#35 mobile-after.png107.91 KBDickJohnson
#35 mobile-before.png109.72 KBDickJohnson
#35 tablet-after.png132.15 KBDickJohnson
#35 tablet-before.png126.58 KBDickJohnson
#35 desktop-after.png89.93 KBDickJohnson
#35 desktop-before.png88.56 KBDickJohnson
#34 2398451-34.patch15.1 KBidebr
#34 interdiff-34-32.txt3.96 KBidebr
#32 interdiff.txt259 bytesthamas
#32 2398451-32.patch16.24 KBthamas
#30 interdiff.txt3.4 KBthamas
#30 2398451-30.patch16.24 KBthamas
#28 2398451-28-desktop-rtl-after.png396.67 KBidebr
#28 2398451-28-desktop-rtl-before.png395.58 KBidebr
#28 2398451-28-desktop-after.png398.84 KBidebr
#28 2398451-28-desktop-before.png400.54 KBidebr
#28 2398451-28.patch16.23 KBidebr
#28 interdiff-28-15.txt3.25 KBidebr
#15 2398451-15.patch15.52 KBidebr
#15 interdiff-15-13.txt5.04 KBidebr
#13 interdiff-13-10.txt2.62 KBidebr
#13 2398451-13.patch14.01 KBidebr
#10 2398451-10.patch13.87 KBidebr
#6 layout-css-cleanup-2398451-6.patch15.78 KBDragan Eror
#5 layout-css-cleanup-2398451-5.patch15.78 KBDragan Eror
#4 layout-css-cleanup-2398451-4.patch15.86 KBDragan Eror
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

emma.maria’s picture

Title: Clean up layout code in Bartik » Clean up "layout" CSS in Bartik
emma.maria’s picture

Issue summary: View changes
Dragan Eror’s picture

Assigned: Unassigned » Dragan Eror
Dragan Eror’s picture

Assigned: Dragan Eror » Unassigned
Status: Active » Needs review
FileSize
15.86 KB

I've just moved stuff from layout.css to appropriate component css file, didn't look about coding standard in this patch.

Dragan Eror’s picture

Fixed new line errors from previous patch...

Dragan Eror’s picture

Removed white space in page.css.

idebr’s picture

Status: Needs review » Needs work

This patch should also make the switch from id selectors to classes in line with the Drupal CSS coding standards. This change was originally one issue, but was split into subtasks to make the transition easier. More info available #2347751: Remove id selectors from templates of Bartik

thamas’s picture

  1. +++ b/core/themes/bartik/css/components/messages.css
    @@ -15,3 +21,11 @@ div.messages {
    diff --git a/core/themes/bartik/css/components/page.css b/core/themes/bartik/css/components/page.css
    

    I think we should keep the rest of the file in layout.css and shold not move it to a "page" component. (Page is not a compoent IMHO.)

  2. +++ b/core/themes/bartik/css/components/sidebar.css
    @@ -29,3 +29,93 @@
    +  .layout-two-sidebars #content {
    

    The following rules are about #content so they should be in the content component.
    I was also thinking about if we should use modifiers like .content--one-sidebar, .content--two-sidebars, .content--first-sidebar etc. instead of using context.

thamas’s picture

Issue tags: +SprintWeekend2015
idebr’s picture

Status: Needs work » Needs review
Issue tags: +Needs screenshots
FileSize
13.87 KB

This patch should also make the switch from id selectors to classes in line with the Drupal CSS coding standards. This change was originally one issue, but was split into subtasks to make the transition easier.

The remaining css in layout.css no longer has any id selectors. To complete the transition, the id selector would have to replaced in every file that references this selector. Instead, I added an additional class on the element with the id and used that selector instead. After each file has been cleaned, the id attribute can be removed from the template file.

I think we should keep the rest of the file in layout.css and shold not move it to a "page" component. (Page is not a compoent IMHO.)

Done

The following rules are about #content so they should be in the content component.
I was also thinking about if we should use modifiers like .content--one-sidebar, .content--two-sidebars, .content--first-sidebar etc. instead of using context.

Ideally, yes. But this would require preprocessing for each separate element instead adding a body class. The current implementation is a lot more practical, so I kept it for now.

idebr’s picture

thamas’s picture

+++ b/core/themes/bartik/css/components/sidebar.css
@@ -1,7 +1,76 @@
+@media all and (min-width: 851px) {
+  #content {
+    float: left; /* LTR */
+    position: relative;
+  }
+  [dir="rtl"] #content {
+    float: right;
+  }
+  .layout-two-sidebars #content {
+    margin-left: 25%;
+    margin-right: 25%;
+    width: 50%;
+  }
+  .layout-one-sidebar #content {
+    width: 75%;
+  }
+  .layout-no-sidebars #content {
+    width: 100%;
+  }
…

Should use the newly added .main__content class instead?

Also should be moved to components/content.scss

Keeping the body class usage is OK, I think. :)

idebr’s picture

FileSize
14.01 KB
2.62 KB

Should use the newly added .main__content class instead?

Yes, correct. I updated the patch accordingly.

Also should be moved to components/content.scss

Done

Keeping the body class usage is OK, I think. :)

Alright :)

thamas’s picture

A small thing: maybe it would be better to use .main-content instead of .main__content because

  • .main is not a component but a layout element (if I'm right)
  • sidebars can be found within .main but we do not call them eg. .main__sidebar-first (and we should not)
  • "content" itself is a component, just like a "sidebar"

If I'm right, "content.css" should be renamed to "main-content.css" too.

idebr’s picture

FileSize
5.04 KB
15.52 KB

A small thing: maybe it would be better to use .main-content instead of .main__content because

  • .main is not a component but a layout element (if I'm right)
  • sidebars can be found within .main but we do not call them eg. .main__sidebar-first (and we should not)
  • "content" itself is a component, just like a "sidebar"

Yes, either .main or .main-content would work for me. Bartik currently has a weird construction where a <div id="main"> wraps the <main> element. I have removed the redundant wrapper and added the .main-content class to the <main> element.

If I'm right, "content.css" should be renamed to "main-content.css" too.

Lets leave this for #2398463: Clean up the "content" component in Bartik depending on what gets committed for this issue.

LewisNyman’s picture

Status: Needs review » Needs work

Yes, either .main or .main-content would work for me. Bartik currently has a weird construction where a

wraps the element. I have removed the redundant wrapper and added the .main-content class to the element.

Totally agree but I think it's easier to keep these issues to just copying and pasting stuff out and into the correct files, and then using the other files to do the clean up and renaming. Otherwise it becomes really hard to tell if something has dropped out by mistake.

Anything left in layout.css should definitely be prefixed with .layout-

thamas’s picture

@LevisNyman Ohh. So no changes in moved code, only in the remaining code. I understand but sad because of made work idebr more than it was needed… :(

I add the related issues here to help who work on those keep an eye on this issue.

thamas’s picture

Hm, I'm not able to save related issues…

thamas’s picture

Ohh, I had to (start to) write the title of the issue instead of its id… :)

DickJohnson’s picture

Just my two cents about the naming. Content.css will be renamed and splitted up anyways, so there's no need to handle it here.

LewisNyman’s picture

Let's keep this issue focused. Maybe we should start again from the patch in #2398451: Clean up "layout" CSS in Bartik? It's very hard to keep track of changes if we are also moving the code around into different files. We have an issue to handle the naming conventions for content.css etc

Dragan Eror’s picture

@LewisNyman which patch? :)
You linked to this issue, but we have multiple patches. Guess you wanted to link specific comment?

LewisNyman’s picture

@Dragan Eror Ah yes thanks, I meant the patch in #10

idebr’s picture

The patches after #10 only change id selectors to class selectors, update existing code to adhere to the current CSS coding standards and provides a base for other cleanup issues to work with. Taking these changes out to make reviewing a little easier seems like a step backwards to me.

Totally agree but I think it's easier to keep these issues to just copying and pasting stuff out and into the correct files, and then using the other files to do the clean up and renaming. Otherwise it becomes really hard to tell if something has dropped out by mistake.

The cleanup in files other than layout.css is relatively minor compared to the changes to the layout.css itself. The nice thing about these changes is all the selectors can be tested on a single (home-)page. Perhaps a report like #2399709: Remove media.css from Bartik, add it's current code directly to the components it references. would help or some full page screenshots would help?

thamas’s picture

Another thing: shouldn't we postpone #2398463: Clean up the "content" component in Bartik and #2398471: Clean up the "footer" component in Bartik until this issue is resolved? They are affected by the output of this issue.

DickJohnson’s picture

Don't think so. Even there will be rerolls as we touch the same code etc the major discussion we have on content or footer clearup is mostly completely different.

emma.maria’s picture

We shouldn't postpone any issues. There are no dependencies between these issues. we should get them all ready no matter what they affect as we have no idea which order the issues will be looked at and committed.

idebr’s picture

Status: Needs work » Needs review
Issue tags: -Needs screenshots
FileSize
3.25 KB
16.23 KB
400.54 KB
398.84 KB
395.58 KB
396.67 KB

Anything left in layout.css should definitely be prefixed with .layout-

Done

Screenshot desktop (before/after):

Screenshot desktop RTL (before/after):

LewisNyman’s picture

Status: Needs review » Needs work
+++ b/core/themes/bartik/css/layout.css
@@ -6,13 +6,13 @@
 /**
  * Section
  */
-.section {
+.layout-section {
...
-  .section {
+  .layout-section {

Sorry to be annoying, but I think we have an opportunity here to rename this class to something reusable and meaningful. This looks similar in purpose to th 'layout-container' class we use in the Seven theme. I think we can rename it to that?

thamas’s picture

Status: Needs work » Needs review
Issue tags: +Needs screenshots
FileSize
16.24 KB
3.4 KB

Here is the patch rerolled from #2398451-28: Clean up "layout" CSS in Bartik. I've just simply replaced all "layout-section" to "layout-container".

LewisNyman’s picture

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

Thanks, I don't think we need more screenshots.

+++ /Users/thamas/Projects/d8/2398451-30.patch  Sun Feb  1 09:34:41 2015
@@ -277,7 +277,7 @@
 +/**
 + * Section
 + */

We need to update this CSS comment to match the new class name.

thamas’s picture

Status: Needs work » Needs review
FileSize
16.24 KB
259 bytes

We need to update this CSS comment to match the new class name.

Now it says: Container

LewisNyman’s picture

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

Ah no reroll needed :(

idebr’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
3.96 KB
15.1 KB

Rerolled the patch and applied two fixes:

  1. -#footer-wrapper {
    +#site-footer__wrapper {
       font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    

    This line was not updated when the footer regions were renamed.

  2.  .layout-main-wrapper {
       min-height: 300px;
    +}
    +.layout-main {
       margin-top: 20px;
       margin-bottom: 40px;
     }

    I had to reintroduce this wrapper since min-height together with margin has a different size than before where these selectors were applied on two different elements.

DickJohnson’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
88.56 KB
89.93 KB
126.58 KB
132.15 KB
109.72 KB
107.91 KB
36.7 KB
34.87 KB

Looks good.

Compared layouts in different widths after reroll.
Desktop before:
Desktop before

Desktop after:
Desktop after

Tablet before:
Tablet before

Tablet after:
Tablet after

Mobile before:
Mobile before

Mobile after:
Mobile after

Mobile footer before:
Mobile before

Mobile footer after:
Mobile after

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 34: 2398451-34.patch, failed testing.

idebr’s picture

Status: Needs work » Needs review

Drupal\system\Tests\Routing\ExceptionHandlingTest->testBacktraceEscaping()

I doubt that's related

DickJohnson queued 34: 2398451-34.patch for re-testing.

idebr’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC per #35 after testbot hickup.

webchick’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

Hm, this no longer applies for me.

saki007ster’s picture

FileSize
12.4 KB

rerolled the patch in #34

saki007ster’s picture

Status: Needs work » Needs review
LewisNyman’s picture

Issue tags: -Needs reroll
FileSize
5.44 KB

I diffed the two patches using diff 2398451-34.patch 2398451-41.patch. There seems to be a big difference between the two patches, I've attched the output. I'm not sure if this means we are missing something or not, but it probably needs another manual test.

idebr’s picture

Issue summary: View changes
FileSize
365.49 KB
378.78 KB

I updated my local branch from #34 and I can confirm the reroll in #41 missed quite a big hunk in layout.css. Attached patch is a new reroll from #34 with the changes from #2422975: Bartik footer has CSS regressions. merged in.

Some before/after screenshots for good measure:


LewisNyman’s picture

Status: Needs review » Needs work

@idebr Hey, I think you missed the patch?

idebr’s picture

Status: Needs work » Needs review
FileSize
14.97 KB

Ugh.. thanks

emma.maria’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Novice
FileSize
97.69 KB
71.2 KB
10.29 KB
629.55 KB
637.5 KB
645.11 KB

I found a problem with the CSS. We need to remove the margin for default .region-header selector. See screenshots below code snippet.
 

+++ b/core/themes/bartik/css/components/header.css
@@ -2,6 +2,16 @@
+.region-header {
+  float: right; /* LTR */
+  margin: .5em 5px .75em;
+}

 

 

 
Also we have lost the media query selectors for region-header in the latest patch which is causing the regression on desktop currently.
 

 
Can the following code please be added to header.css file....
 

+++ b/core/themes/bartik/css/layout.css
@@ -1,242 +1,29 @@
-@media all and (min-width: 461px) and (max-width: 900px) {
-  .region-header {
-    margin: .5em 5px .75em;
-  }
-}
-@media all and (min-width: 901px) {
-  .region-header {
-    margin: 1em 5px 1.5em;
-  }
-}

The code above was removed from layout.css and not added to header.css.

Otherwise I have found no other CSS regressions. The Layout file now only contains the appropriate CSS needed.

Here are screenshots with the before and after patches screenshots overlayed with the top one at 50% opacity to compare.

Mobile (Looks great)

Tablet (Looks great)

Desktop (with the one regression bug mentioned above)


 
Also tagging with Novice incase someone new wants to have a go creating a new patch from the patch in #46 containing the small fixes above.

idebr’s picture

Status: Needs work » Needs review
FileSize
563 bytes
15.18 KB

@emma.maria Thanks for the extensive testing :). I can confirm the media queries for the .region-header were missing. I have re-added them in the attached patch.

emma.maria’s picture

Status: Needs review » Needs work

That's great, thanks @idebr!

One last thing can you please remove the margin from this section. It is there by mistake and is only needed for the 461 - 900px section.

+++ b/core/themes/bartik/css/components/header.css
@@ -2,6 +2,26 @@
+}
+.region-header {
+  float: right; /* LTR */
+  margin: .5em 5px .75em;
+}
idebr’s picture

Status: Needs work » Needs review
FileSize
377 bytes
15.15 KB

Sure! I was hesitant to remove it since the proposed resolution was not to change the existing design, but as long as you're okay with it :)

emma.maria’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
15.18 KB

Bah! On second thoughts let's leave that margin bug out of this issue as it is a design change (even if it is one line of CSS) and raise a follow up issue.

The patch to be considered is from #48.

I am reposting the patch from @idebr in #48 here again to not confuse people.

This patch fixes the missing CSS problem mentioned in #47 and introduces no other regressions from #46.

All looks good to me! RTBC.

emma.maria’s picture

Status: Reviewed & tested by the community » Needs review
emma.maria’s picture

Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 51: 2398451-51.patch, failed testing.

idebr’s picture

Status: Needs work » Needs review
FileSize
15.2 KB
LewisNyman’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Novice

I compared the two patches and they seem to be very similar. So setting back to RTBC.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/themes/bartik/templates/page.html.twig
@@ -147,14 +147,14 @@
+          <div id="sidebar-first" class="column sidebar sidebar--first">
...
+          <div id="sidebar-second" class="column sidebar sidebar--second">

@@ -164,7 +164,7 @@
+        <aside id="featured-bottom" class="section layout-container clearfix" role="complementary">

Why are we introducing the .sidebar--first and .sidebar--second classes but not a .featured-bottom? This change seems to be unnecessary to complete the task of the issue and out-of-scope.

DickJohnson’s picture

Status: Needs work » Needs review
FileSize
14.53 KB
1.58 KB

Fixed the issues mentioned by @alexpott in #57.

idebr’s picture

Status: Needs review » Reviewed & tested by the community

The id's were updated to classes since our CSS coding standards dictate id's should not be used to styling when a class can used instead. The patch doesn't touch any css from #featured-bottom, so the id is not converted. If this is out of scope, the updated patch in #58 addresses this feedback appropriately.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 58: 2398451-58.patch, failed testing.

idebr’s picture

Status: Needs work » Needs review
FileSize
14.5 KB
LewisNyman’s picture

Status: Needs review » Reviewed & tested by the community

The reroll looks good!

The patch doesn't touch any css from #featured-bottom, so the id is not converted. If this is out of scope, the updated patch in #58 addresses this feedback appropriately.

That is correct, this issue is mainly about moving CSS into the correct component files so they can then be cleaned up.

joshtaylor’s picture

Status: Reviewed & tested by the community » Needs work

https://www.drupal.org/node/1273052 has broken the last patch, with core/themes/bartik/css/layout.css not applying any more.

emma.maria’s picture

Issue tags: +Needs reroll

Thanks for pointing that out @joshtaylor! Tagging the issue.

idebr’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
14.54 KB
LewisNyman’s picture

Status: Needs review » Reviewed & tested by the community

Reroll looks good!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 65: 2309451-65.patch, failed testing.

idebr’s picture

Status: Needs work » Needs review
FileSize
14.34 KB
LewisNyman’s picture

Status: Needs review » Reviewed & tested by the community

Reroll looks good!

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.0.x. Thanks!

  • webchick committed a6893b4 on 8.0.x
    Issue #2398451 by idebr, Dragan Eror, thamas, DickJohnson, emma.maria,...

Status: Fixed » Closed (fixed)

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