Follow-up to #1342054: [META] Clean up templates and CSS

Problem/Motivation

  1. Bartik's template files need to be assessed and cleaned up of redundant markup, bad formatting and ID's.
  2. Bartik's CSS files need to follow Drupal's CSS Coding Standards.

Proposed resolution

For this issue we take "print.css" within Bartik in css/print.css plus any template file associated with the CSS and clean them up.

CSS formatting tasks to do

  1. The CSS file needs to use the correct Comment formats - see guidelines here and also reference other fixed Bartik CSS files for wording guidelines.

CSS architecture tasks to do

  1. Replace any ID's with classes within the CSS files and Twig files associated with it - see guidelines here.

CSS cleanup tasks to do

  1. Check all of the selector rules are correct and are currently in use. Fix any broken ones found.

Remaining tasks

  • (Done) Write a patch containing as much of the above as possible.
  • (Done) Post a patch with screenshots.
  • Visual review of a patch - check the print view of Bartik visually with and without patch applied. Take screenshots.
  • Code review of a patch - check the code follows coding standards, suggest improvements if needed in a comment.
  • Produce a new patch with improvements if needed.

User interface changes

Screen layout for reference: screen.png

Print layout A4 paper: Before / After

Print layout A3 paper: Before / After

API changes

None

Data model changes

None

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Task because it is refactoring CSS and templates in Bartik
Issue priority Not critical because Bartik functions fine we are just doing cleanup tasks
Unfrozen changes Unfrozen because it only changes CSS and markup
Prioritized changes The main goal of this issue is usability of the Bartik's codebase
Disruption non-Disruptive as it is just changing markup and CSS
CommentFileSizeAuthor
#47 clean-up-print-css-bartik-47.patch2.48 KBmrinalini9
#44 After-patch(A4).png186.82 KBgajendra_sharma
#44 Before-patch(A4)-2.png46.85 KBgajendra_sharma
#44 Before-patch(A4)-1.png186.91 KBgajendra_sharma
#44 After-patch(A3).png205.58 KBgajendra_sharma
#44 Before-patch(A3).png229.17 KBgajendra_sharma
#38 clean-up-print-css-bartik-38.patch2.73 KBkomalk
#29 before-patch.pdf135.97 KBbandanasharma
#29 after-patch.pdf72.17 KBbandanasharma
#22 clean-up-print-css-bartik-22.patch2.71 KBsimply021
#15 after_A4.pdf177.28 KBjuhog
#15 before_A4.pdf1.42 MBjuhog
#15 after_A3.pdf177.37 KBjuhog
#15 before_A3.pdf1.42 MBjuhog
#15 screen.png128.76 KBjuhog
#15 interdiff-13-15.txt2.03 KBjuhog
#15 clean-up-print-css-bartik-2542618-15.patch3.61 KBjuhog
#13 featured_bottom_no_float.pdf1.18 MBjuhog
#13 featured_bottom_float.pdf1.18 MBjuhog
#13 clean-up-print-css-bartik-2542618-13.patch2.97 KBjuhog
#13 interdiff-12-13.txt1.03 KBjuhog
#12 clean-up-print-css-bartik-2542618-12.patch.txt3.08 KBjuhog
#12 interdiff-11-12.txt2.19 KBjuhog
#11 clean-up-print-css-bartik-2542618-11.patch1.75 KBjuhog
#11 comment-forbidden.png232.76 KBjuhog
#11 interdiff-9-11.txt618 bytesjuhog
#10 d7_print_preview.png220.83 KBjuhog
#10 d7_screen.png515.38 KBjuhog
#9 clean-up-print-css-bartik-2542618-6.patch1.53 KBniklp
#5 clean-up-print-css-bartik-2542618-5.patch1.71 KBmanjit.singh
#4 print-css-after.jpg275.39 KBsimply021
#4 print-css-before.jpg276.21 KBsimply021
#4 clean-up-print-css-bartik-2542618-4.patch1.25 KBsimply021

Comments

simply021’s picture

Assigned: Unassigned » simply021
emma.maria’s picture

Hello @simply021 do you need help working on this issue? I am available on IRC to help out.
Also you should only assign issues to yourself if you are actively working on a patch.
If you are no longer going to work on this issue can you please unassign?
Thanks.

simply021’s picture

Hi emma.maria, yes i'm working on it. If i get blocked by something ill ping you. Thanks for asking.

simply021’s picture

Assigned: simply021 » Unassigned
Status: Active » Needs review
StatusFileSize
new1.25 KB
new276.21 KB
new275.39 KB

Changes in this patch are adding class in markup and replacing id's with class.

manjit.singh’s picture

StatusFileSize
new1.71 KB

Adding file comment :)

manjit.singh’s picture

+++ b/core/themes/bartik/css/print.css
@@ -33,11 +35,15 @@ body {
+#featured-bottom-first,
+#featured-bottom-second,
+#featured-bottom-third {

@simply021 I think this also need to be replaced with classes.

Status: Needs review » Needs work

The last submitted patch, 5: clean-up-print-css-bartik-2542618-5.patch, failed testing.

niklp’s picture

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

Rerolled. Something went awry. Should be ok.

juhog’s picture

StatusFileSize
new515.38 KB
new220.83 KB

Hi, I'm working on a patch for this issue.

Before I go ahead and submit a patch, I'd like to ask about a couple of things.

1) D7 Bartik print styles hide the comment area title "Comments". I believe this is not intentional. The style was probably meant to hide just the comment form title "Add new comment" but it accidentally hides the "Comments" title too (since they are both h2.title). Should we leave the "Comments" title visible in D8 Bartik? I attached some screenshots.

2) How important is IE8 support in D8 Bartik? I noticed "Toolbar" module is using a media query to hide the admin toolbar for print. This of course works on all modern browsers but does not do the job in IE8. Should we keep something like ".toolbar { display: none; }" in the Bartik print css to support IE8 admins who want to print some pages?

3) There's a selector weight issue regarding this style: ".comment-forbidden { display: none; }". We want to hide this node-link but it's getting a "display:inline" from another selector with a greater weight so our "display:none" has no effect. Normally I would never use an !important in a project, but this might be case where it's a viable choice. These are the two options:

  • .comment-forbidden { display: none !important; }
  • ul.inline li.comment-forbidden { display: none; }

Should we use the first option?

juhog’s picture

StatusFileSize
new618 bytes
new232.76 KB
new1.75 KB

I decided to do the following in this patch:

1) Keep the "Comments" heading visible in print styles.

2) Remove "Toolbar" related print style from Bartik. I talked with @lauriii about IE8 and apparently there's no reason to support IE8.

3) Selector weight issue regarding ".comment-forbidden" is solved. (The attached screenshot clarifies what that element is.)

juhog’s picture

Maybe we should follow Seven theme's example and use a media query for the print styles? This patch does that. Here's a link to the issue about Seven's print styles: https://www.drupal.org/node/1892006.

If we want to go a step further, we could move print styles to each corresponding component's css file, wrapped in a print media query of course. For example comment print styles would go to components/comments.css and featured-bottom region styles would go to components/featured-bottom etc. There's some pros and cons in this approach but I think it might be a good idea. Any thoughts?

juhog’s picture

Three things happening in this patch:

A) Body width has been removed. I did some research and came to the conclusion that there is no need to set a body width for printing.

B) Sidebar related styles have been removed (main-content width 100%). In D7 Bartik this declaration was used to reset styles from layout.css but in D8 Bartik we don't need to do this anymore since the layout styles are in a media query and won't affect print styles.

C) Featured bottom area styles have been rewritten. This is now a copy-paste from components/featured-bottom.css (I'll make a new issue about combining print styles to the component styles). Regarding this area, I think we have three options: 1) We could show the regions one below the other (mobile style), or 2) Side by side (desktop style), or 3) We don't show this area at all. I chose the second option because on a paper we have enough space to show them side by side. And also because if one of the regions happens to have an image, it would be printed out in huge size (see attached print preview pdf files). Hiding this area in print might be a good idea as well.

emma.maria’s picture

Wow thanks @juhog this looks great! Thanks for the research and improvements. I will review this and write a reply in the morning.

juhog’s picture

Issue summary: View changes
StatusFileSize
new3.61 KB
new2.03 KB
new128.76 KB
new1.42 MB
new177.37 KB
new1.42 MB
new177.28 KB
  1. +++ b/core/themes/bartik/css/components/main-content.css
    @@ -12,7 +12,7 @@
    -@media all and (min-width: 851px) {
    +@media screen and (min-width: 851px) {
    

    Sidebars won't be visible on print so we don't want to make main-content narrow either.

  2. +++ b/core/themes/bartik/css/print.css
    @@ -4,44 +4,58 @@
       /**
    ...
    +   * Regions
    +   *
    +   * Hide regions which are unlikely to have relevant content for printing.
        */
    ...
    +  .highlighted,
    +  .featured-top,
    +  .sidebar,
    +  .featured-bottom,
    +  .site-footer {
    +    display: none;
       }
    

    I had a chat with @mortendk and we agreed that most regions should be hidden on print layout. I can elaborate more if needed.

  3. +++ b/core/themes/bartik/css/print.css
    @@ -4,44 +4,58 @@
    +  /**
    +   * Navigation elements.
    +   */
    +  nav:not(.breadcrumb) {
    +    display: none;
       }
    

    Almost all nav elements are irrelevant on print.

juhog’s picture

...

juhog’s picture

Issue summary: View changes
juhog’s picture

Issue summary: View changes
juhog’s picture

Issue summary: View changes
juhog’s picture

davidhernandez’s picture

Status: Needs review » Needs work
+++ b/core/themes/bartik/templates/page.html.twig
@@ -101,14 +101,14 @@
+          <div id="sidebar-first" class="sidebar-first column sidebar ">

Why are the sidebar-first and sidebar-second classes being added here? They don't seemed to be referenced in any rule being changed. Also, there is a trailing space before the close quote. That should be removed.

simply021’s picture

StatusFileSize
new2.71 KB

Based on #22 removing unused classes sidebar-first and sidebar-second so as unnecessary space at the end of closing tag.

visabhishek’s picture

Status: Needs work » Needs review

updating status to trigger tests

himanshu5050’s picture

Assigned: Unassigned » himanshu5050
emma.maria’s picture

Version: 8.0.x-dev » 8.1.x-dev
Assigned: himanshu5050 » Unassigned
Issue tags: -Novice +Needs issue summary update

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mgifford’s picture

Issue tags: +print.css
bandanasharma’s picture

StatusFileSize
new72.17 KB
new135.97 KB

I have applied #22 patch and it works fine. Code changes are reflected but I can't see any UI changes, when print screen is used. Please find the attached screen shots (PDF).

manjit.singh’s picture

Status: Needs review » Needs work

@bandanasharma I am changing its status as its issue summary needs to be update.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

komalk’s picture

Status: Needs work » Needs review
StatusFileSize
new2.73 KB

patch #22 failed to apply on 9.1.x.
patch Re-rolled to the 9.1.x branch

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

gajendra_sharma’s picture

Assigned: Unassigned » gajendra_sharma
gajendra_sharma’s picture

StatusFileSize
new229.17 KB
new205.58 KB
new186.91 KB
new46.85 KB
new186.82 KB

Patch #38 tested and applied successfully on Drupal 9.5.x.

gajendra_sharma’s picture

Assigned: gajendra_sharma » Unassigned
Status: Needs review » Reviewed & tested by the community

Patch #38 tested and applied successfully on Drupal 9.5.x.

lauriii’s picture

Project: Drupal core » Bartik
Version: 9.5.x-dev » 1.0.2
Component: Bartik theme » Code
Status: Reviewed & tested by the community » Needs work

Bartik has been moved to contrib. Please update the patches against the contributed project.

mrinalini9’s picture

Status: Needs work » Needs review
StatusFileSize
new2.48 KB

Updated patch #38 by addressing #46, please review it.

liam morland’s picture

Version: 1.0.2 » 1.0.x-dev
Status: Needs review » Needs work

Please put the patch into an issue fork and merge request.