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/base/header.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.

The work needs to be crossed off the list below as completed or stated why they were not applicable to this issue in the comments below, to make sure we cover everything.

Also very helpful! Noting the list items in your comment with the patch to show what parts you added to the patch.

Create a patch containing the potential following work:

Code cleanup work

  1. Check each selector in the CSS file (associated with the particular issue) is in use within core right now.
    If not...
    a) Check to see if the classes in core have been changed and correct them (for e.g. I found this in this issue ).
    or
    b) Remove that CSS completely from the CSS file.
  2. a) Check the CSS selectors are not being replicated in other stylesheets in Bartik.
    b) Check the CSS properties are not being overridden by other stylesheets in Bartik.
    If a) move all of the properties to the selector in the stylesheet that you think most appropriate for the component you are dealing with.
    If a) and b) also remove the CSS properties and values being overridden within that ruleset.
  3. If you find CSS for a component which seems out of place in the file it is currently in move it to the one you think is the correct one.
  4. If a selector appears to be too long and/or too specific, check if the selector can be simplified. for eg. .something .something .something { } being modified to .something .something { }.
  5. Check that RTL styles exist when needed and are formatted as per the guidelines. (for e.g. we found that RTL styles are broken on certain pages in this issue, so fix anything you see missing/incorrect in the CSS file.
  6. If you think the contents of the CSS file could be further broken down into more components CSS files, or grouped together with other existing CSS files to form one component do it. The initial SMACSS issue may not of been perfect, guidelines on CSS file organisation for Drupal 8 can be found here.
  7. Check the markup from the templates that all of the classes are used as selectors in the CSS files. If not remove them. See an example issue here for this.

Code formatting work

  1. Add a File comment to the top of the stylesheet - see here for guidelines.
  2. Check any other comments are formatted correctly - see here for guidelines.
  3. Check Whitespace is being used correctly, this includes indentations and line breaks - see here for guidelines.
  4. Check the formatting of rulesets, properties and media queries are correct - see here for guidelines.
  5. As mentioned above, check existing RTL styles are formatted correctly - see here for guidelines.

Remaining tasks

  • Assess the code applicable to this patch and figure out what work in the lists above need to be included in the patch.
  • Cross out work tasks that do not apply to this issue.
  • Write a patch with as much work as you want to include, upload and comment what you included
  • Cross off further tasks as you go
  • Review the patch - code review and visual changes
  • Upload screenshots to show nothing/something is broken on the frontend

User interface changes

Bartik should visually stay the same. Unless we discover CSS styles that have been lost over time which when corrected, change the design back to as it was in the past.

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

Comments

emma.maria’s picture

Tagging to remind ourselves to update the summary and figure out the work needed on the header.

jp.stacey’s picture

Issue summary: View changes
Issue tags: -Needs issue summary update

Copied the ticket description from #1342054: [META] Clean up templates and CSS as it only needed one line editing: I believe it's boilerplate for each issue?

It already mentions adding a header comment, which was @Manjit.Singh's recommendation on that other ticket, so that's captured.

I think this is now ready for anyone to pick up. If I get a chance I will, but I'll assign it to myself if I do.

jp.stacey’s picture

Assigned: Unassigned » jp.stacey

Reviewing.

jp.stacey’s picture

Issue summary: View changes
StatusFileSize
new3.49 KB

Crossed off in the description what I've done so far; patch attached.

Question: Bartik contains its own login and search blocks, enabled by default: should these have the same styles that the system blocks have? Currently they don't, as they've got different class names. However, there are a lot of selectors in the CSS that will have to be duplicated, to get that to work.

jp.stacey’s picture

Assigned: jp.stacey » Unassigned
tadityar’s picture

Issue summary: View changes

Checked that the comments follows the guidelines.

tadityar’s picture

Issue summary: View changes

Also checked for duplicates and override.

jp.stacey’s picture

Assigned: Unassigned » jp.stacey

@tadityar thanks - looking at this further now.

jp.stacey’s picture

Issue summary: View changes
StatusFileSize
new4.49 KB
new1.73 KB

Closed off remaining items in description; also tightened up some of the comments (need to end in full stops) and followed the whitespace advice to put a single newline before them. I've even added a couple of single-line sectional comments based on the ones that are already there.

Patch and interdiff attached.

This is now ready for testing: imma gonna try to run Wraith on it and see what happens, so I'll keep hold of this ticket for now.

jp.stacey’s picture

Assigned: jp.stacey » Unassigned
Status: Active » Needs review
StatusFileSize
new48.68 KB
new46.96 KB
new30.52 KB

It's not a great test of Wraith, to be honest: there are selectors in header.css that weren't applying to e.g. the login form because the classes were wrong. Having fixed these classes, the login form (and the language selector) do look completely different.

However, for complete honesty, I attach Wraith images and diff at 1280px.

I think this result is correct, though, because it was actually a bug in header.css that we've fixed. So I'm putting this for review anyway.

lewisnyman’s picture

Status: Needs review » Needs work

Nice :) Are there any other blocks we need to add to the header to test?

  1. +++ b/core/themes/bartik/css/components/header.css
    @@ -179,50 +182,50 @@ h1.site-name {
    +.region-header #block-userlogin {
    ...
    +.region-header #block-userlogin .content {
    ...
    -.region-header #block-user-login div.description {
    +.region-header #block-userlogin div.item-list,
    +.region-header #block-userlogin div.description {
    

    Can we use a class instead of IDs?

  2. +++ b/core/themes/bartik/css/components/header.css
    @@ -179,50 +182,50 @@ h1.site-name {
    +.region-header #block-userlogin div.item-list {
    ...
    +.region-header #block-userlogin div.description {
    

    As well as the ID, we should be able to remove the div declaration

  3. +++ b/core/themes/bartik/css/components/header.css
    @@ -179,50 +182,50 @@ h1.site-name {
    +.region-header #block-userlogin .item-list ul {
    ...
    +.region-header #block-userlogin .item-list li {
    ...
    +.region-header #block-userlogin .item-list li:last-child {
    ...
    +[dir="rtl"] .region-header #block-userlogin .item-list li:last-child {
    

    I think we should be able to remove the .item-list class in this selector

jp.stacey’s picture

@LewisNyman Regarding your initial comment, I tested with all the blocks mentioned explicitly in header.css:

* userlogin,
* language picker,
* search
* branding

I'm not sure if there's much merit in testing many others. For the branding, I also checked Bartik's block--system-branding-block.html.twig, to ensure there were no extraneous classes.

Regarding your three bulleted points, I can look at that. Without knowing for sure how block classes work, I was wary of replacing a semantically unique-ifying ID with what merely looks to me like a good candidate class (e.g. "is .language-switcher-language-url unique enough?") but I can stick that in the patch and the worst that happens is you say it's wrong!

Won't assign this to me as I'm about to head off out, but if I'm free later I'll look at it.

jp.stacey’s picture

Status: Needs work » Needs review
Issue tags: +drupaldevdays
StatusFileSize
new4.38 KB
new2.32 KB

Patch attached implements the extra requests in #11. At the same time I've done the following:

* Added a couple more leading newlines before comments, in line with whitespace standards.
* Spotted a bug in the search CSS: the search input field has class "search-text", whereas the CSS was still assuming "form-text".

Interdiff wraith testing only highlights that fix to search CSS; all the other changes have no visual effect. Which is good!

lewisnyman’s picture

Status: Needs review » Needs work
StatusFileSize
new4.44 KB

Here is the rerolled patch. I saw a few things in the CSS file that could also be improved.

#site-slogan,
.site-slogan {
#site-name a,
.site-name a {
#site-name,
.site-name {
#logo,
.site-logo {
#name-and-slogan,
.site-branding-text {
#header {

Can we remove all these IDs and just use the class? Maybe we can delete these IDs from the tpl?

h1#site-name,
h1.site-name {

We should be able to just use the class here without the H1

.region-header {
  float: right; /* LTR */
  margin: .5em 5px .75em;
}

We use leading 0s on out decimal units.

#site-name a,
.site-name a {
  font-weight: normal;
}

I wonder if we even need this?

.region-header .block > h2 {

Can we use a class like .title instead of the h2? It would be less fragile

.region-header .block > h2 {
  /* @extend .visually-hidden */
  position: absolute !important;

Maybe we can get can try and rid of the !important here? I'm not sure

tadityar’s picture

Status: Needs work » Needs review
StatusFileSize
new8.21 KB
new4.4 KB

Fixed point 2,3 and 4 (might need to check if this break something though). Also tried to do point 1. So the remaining task if my patch is successful is:

.region-header .block > h2 {
Can we use a class like .title instead of the h2? It would be less fragile

.region-header .block > h2 {
  /* @extend .visually-hidden */
  position: absolute !important;

Maybe we can get can try and rid of the !important here? I'm not sure

The last submitted patch, 13: clean-up-bartik-header-2466983-13.patch, failed testing.

lewisnyman’s picture

StatusFileSize
new4.44 KB
new10.26 KB

I found a load of regressions in the most recent patch where we had removed ID's but not replaced them with classes or updated colors.css.

.region-header .block > h2 {
  /* @extend .visually-hidden */
  position: absolute !important;
  clip: rect(1px, 1px, 1px, 1px);
  overflow: hidden;
  height: 1px;
}

Turns out we don't need this CSS because all of the default blocks in the header have their titles hidden in config. If we are consistent with the decision in #2148319: h2 on footer blocks must be hidden by default but must show when its enable then we shouldn't be overridding the config if the user does decide the title will show.

emma.maria’s picture

Issue summary: View changes
Issue tags: +Needs change record
StatusFileSize
new241.79 KB

I ran visual regression testing on the header with just the default components in play and there were no visual regressions.

If you add the search block to the header which has specific header styles, the patch introduces 2 regressions.
 

 

  1. The search box length is now wider **
  2. The search box title is now showing due to us no longer hiding things through styling. - I fully agree with this change, however should it be properly documented for future users?

** I did some digging in the code and markup and noticed the following...

+++ b/core/themes/bartik/css/components/header.css
@@ -231,20 +213,21 @@ h1.site-name {
-.region-header #block-search-form .form-text {
+.region-header .block-search .form-search {
   width: 154px;
 }

Before the patch I cannot find ".form-text" in the markup anywhere. So this is a long lost style that has been put back and does not look broken at all. So this technically is not a regression and it's putting a style back from the original design.

So the only thing I see that we need to address is do we need to document the new functionality of the block titles being shown by default unless the user un-ticks the option in the UI?

jp.stacey’s picture

Yeah, I'm pretty certain we've reawakened some long-forgotten selectors as we were going along: see my Wraith attachments on comment #10, and the note "I think this result is correct, though, because it was actually a bug in header.css that we've fixed. So I'm putting this for review anyway."

lewisnyman’s picture

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

Issue summary: View changes

Yes we have fixed bugs in the code and "reawakened" the design by fixing the selectors. I always wondered why the search box was not very wide.

I need to ask @alexpott or probably @xjm if we need a change record as if people upgrade their sites, any block that the user added will now show block titles by default. The issue that took out the theme hiding the titles in the footer did not have a change record #2148319: h2 on footer blocks must be hidden by default but must show when its enable.

I've also adjusted the issue summary to accept the UI changes if we are fixing legacy code that affects the design.

emma.maria’s picture

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

Status: Postponed » Active

This will probably need a brand new implementation as we overhauled how the Header functions in #2005546: Use branding block in place of page template branding variables (site name, slogan, site logo). I will take a look at what we have existing in this issue.

emma.maria’s picture

Version: 8.0.x-dev » 8.1.x-dev
Issue tags: +Novice

As the header has had it's markup and functionality of the regions and blocks overhauled in #2005546: Use branding block in place of page template branding variables (site name, slogan, site logo) a fresh patch to clean up the header CSS and markup to follow Drupal coding standards is needed.

We also want to make sure that we are not purposively hiding any block titles in the CSS and that this option is added to the config where you set the visibility of the block titles instead.

shubhangibb’s picture

Assigned: Unassigned » shubhangibb
shubhangibb’s picture

Issue tags: +drupalconasia2016
manjit.singh’s picture

Assigned: shubhangibb » Unassigned
Status: Active » Needs review
StatusFileSize
new2.03 KB

Here is the first set of rerolling. Let see what test bot say.

dcrocks’s picture

Shouldn't this be header-wrapper instead of header. I didn't think class names the same as element names was proper?

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.

emma.maria’s picture

Status: Needs review » Active
Issue tags: -Needs change record

As the header was overhauled here #2005546: Use branding block in place of page template branding variables (site name, slogan, site logo), this issue needs a fresh patch as the markup and CSS has changed a lot in that issue.

Thanks!

emma.maria’s picture

Issue summary: View changes
Akenward’s picture

Assigned: Unassigned » Akenward
Akenward’s picture

Assigned: Akenward » Unassigned
Akenward’s picture

Assigned: Unassigned » Akenward
Akenward’s picture

StatusFileSize
new2.46 KB

New patch against current 8.2.x-dev. Same changes as clean-up-bartik-header-2466983-29.patch re-rolled for current target.

Akenward’s picture

Assigned: Akenward » Unassigned
Status: Active » Needs review

The last submitted patch, 4: clean-up-bartik-header-2466983-4.patch, failed testing.

The last submitted patch, 9: clean-up-bartik-header-2466983-9.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 37: clean-up-bartik-header-2466983-39.patch, failed testing.

Akenward’s picture

Issue tags: +Drupalcamp Bristol
StatusFileSize
new2.03 KB

Previous patch failed automatic testing. Here's another attempt to get it working.

Akenward’s picture

Status: Needs work » Needs review
manjit.singh’s picture

I am wondering that why we are not considering the header of maintenance page ? I have check the maintenance template that contains lot of ID's, that Drupal 8 is not allowing to use. Can we change that also in this issue itself ?

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.

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.

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.

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

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Project: Drupal core » Bartik
Version: 10.1.x-dev » 1.0.2
Component: Bartik theme » Look and Feel

So this appears to be bartik specific and since bartik has been removed from core in D10 moving this to the contrib project.

roberttabigue’s picture

Status: Needs review » Needs work

Hi,

Patch #42 doesn't work for me when applying it to the Bartik contrib theme against 1.0.2 version and with the Drupal core version 9.5.6.

Moving now to Needs work and please advise.
Thank you.