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-top.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
  • 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
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

emma.maria’s picture

Title: Clean up "featured" CSS in Bartik » Clean up the "featured" component in Bartik
DickJohnson’s picture

Status: Active » Needs review
FileSize
3.17 KB

Investigated this a bit.

Currently featured is mentioned in 5 different css-files.

1. featured.css
2. media.css
3. messages.css
4. layout.css
5. admin.css

First four are pretty simple, but I'm not sure if the demo-block related css should be placed to it's own component-file or to featured.css.

On template we have following featured-related things:

    {% if page.featured %}
      <div id="featured">
        <aside class="section clearfix" role="complementary">
          {{ page.featured }}
        </aside> <!-- /.section -->
      </div> <!-- /#featured -->
   {% endif %}

I don't really understand the usage of aside on this kind of region and by what we've been talking on #2398471: Clean up the "footer" component in Bartik, i think that this should be probably done like:

    {% if page.featured %}
      <div class="site-featured__wrapper">
        <div class="site-featured clearfix" role="complementary">
          {{ page.featured }}
        </div>
      </div>
   {% endif %}

I think the

idebr’s picture

Is the duplicate .featured__wrapper/.featured wrapper used for anything or can it be removed?

DickJohnson’s picture

There was different styles wrote for .featured_wrapper and .featured, but currently it looks like .featured styles are not actually doing anything. I'll rewrite it so that we don't have anything on .featured_wrapper and if everything goes well, I'll remove the it completely.

DickJohnson’s picture

Started to re-do on this. Sending this patch to see what test-bot is saying. Took the wrapper out completely.

On this patch the markup for featured is

<div class="featured">
  <div class="region-featured">

Before it was

<div id="featured>
  <aside class="section">
    <div class="region-featured">

Region-featured stuff is actually coming somewhere out of the template. I also had to change the bartik.theme because it was putting class featured to body. Changed that to "has-featured".

LewisNyman’s picture

Status: Needs review » Needs work
  1. +++ b/core/themes/bartik/css/components/featured.css
    @@ -12,11 +12,35 @@
    +@media all and (min-width: 520px) {
    +
    +  /* ----------------- Featured ----------------- */
    +  .featured {
    +    font-size: 1.643em;
    +  }
    +  .featured h2 {
    +    font-size: 1.174em;
    +  }
    +}
    

    Can we move this code to be directly below the elements it's editing? Also we can remove the comment within it

  2. +++ b/core/themes/bartik/css/components/featured.css
    @@ -12,11 +12,35 @@
    +@media all and (min-width: 901px) {
    +  .has-featured .region-primary-menu .menu li a:active,
    +  .has-featured .region-primary-menu .menu li a.active {
    +    background: #f0f0f0;
    +    background: rgba(240, 240, 240, 1.0);
    +  }
    +}
    

    I actually this this styling should go with the primary-menu component, because .has-featured is a modifier of the menu component in this case. Also, this styling makes no sense, what does it do?

  3. +++ b/core/themes/bartik/templates/page.html.twig
    @@ -117,10 +117,8 @@
    -      <div id="featured">
    -        <aside class="section clearfix" role="complementary">
    -          {{ page.featured }}
    -        </aside>
    +      <div class="featured">
    +        {{ page.featured }}
    

    We've lost the semantics of the aside element and the role attribute. Can we add them back in?

Are we missing a deleted file from the patch? I see some CSS added that isn't remove from somewhere else.

DickJohnson’s picture

#6.1 Agreed
#6.2 With styles:
With
Without styles:
Without
It is true that it doesn't make sense. Correct breakpoint is somewhere around 810px, but I decided to keep it this way and create follow up on this.
#6.3 Can be done, but I still dislike the idea of having minimum of 4 wrapper'ish things on this kind of region to output anything. Your suggestion?

DickJohnson’s picture

Assigned: Unassigned » DickJohnson
FileSize
3.52 KB

Worked a bit on this, not needing a review on this patch.

DickJohnson’s picture

Title: Clean up the "featured" component in Bartik » Clean up the "Featured top" component in Bartik
Assigned: DickJohnson » Unassigned
Issue summary: View changes
DickJohnson’s picture

Title: Clean up the "Featured top" component in Bartik » Clean up the "Featured" component in Bartik
Issue summary: View changes
DickJohnson’s picture

After the region was renamed rerolled and added the semantics of aside back.

DickJohnson’s picture

Title: Clean up the "Featured" component in Bartik » Clean up the "Featured-top" component in Bartik
Issue summary: View changes
DickJohnson’s picture

Status: Needs work » Needs review

The last submitted patch, 8: bartik-clean-up-featured-2398469-8.patch, failed testing.

emma.maria’s picture

Issue summary: View changes
Status: Needs review » Needs work
FileSize
199.33 KB

The patch in #11 breaks Bartik visually all over!

DickJohnson’s picture

Status: Needs work » Needs review
FileSize
3.07 KB

It seems that I forgot to add changes on bartik.theme to latest patch.

mherchel’s picture

Status: Needs review » Needs work

Visually, the patch in #16 looks perfect. That being said, it needs some work to conform to the Drupal 8 CSS standards (see https://www.drupal.org/node/1887918#sub-components)

So, ideally we should see something like

<div class="featured-top">
<aside class="featured-top__inner clearfix" role="complementary">

with a class name of

.featured-top__inner  {...}
kandra’s picture

I'm taking a look at this

kandra’s picture

Status: Needs work » Needs review
FileSize
3.14 KB

Updated patch

LewisNyman’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
FileSize
533.71 KB

Thanks for the fixes. Here is a screenshot to show everything looking lovely.

LewisNyman’s picture

Issue tags: +latinamerica2014
DickJohnson’s picture

I'm not saying the __inner class if wrong, but we didn't put anything similar to footer, right?

And do we really want to use the

.wrapper
  .inner
     .region

structure?

LewisNyman’s picture

I think we have something similar:

.footer is similar to featured__inner
.featured is similar to footer__wrapper

So, I don't know if we want to decide between using either __wrapper subcomponents or __inner subcomponents in Bartik or across of all themes. It feels a bit like a bikeshed discussion, shall we discuss this in a follow up?

kandra’s picture

Issue tags: -latinamerica2014 +LatinAmerica2015
LewisNyman’s picture

Status: Reviewed & tested by the community » Needs work

Sorry! I spotted something

+++ b/core/themes/bartik/css/layout.css
@@ -10,7 +10,7 @@ body,
-#featured-top aside.section,
+.feature-top__inner,

I noticed that we have a small typo here.

LewisNyman’s picture

LewisNyman’s picture

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

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
FileSize
199.39 KB
196.05 KB

The patch applied cleanly.
I visually compared the region before and after applying the patch and featured top looks the same.
 

Before

After


 
The code is formatted correctly. There is now a file comment, no IDs, correct line spacing etc.
We haven't lost any code anywhere.
I love the .has-featured-top class on the body element, it makes so much more sense.
I see nothing wrong with the patch, setting to RTBC.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 26: 2398469-clean-up-feature-top-26.patch, failed testing.

DickJohnson’s picture

Status: Needs work » Reviewed & tested by the community
webchick’s picture

Status: Reviewed & tested by the community » Fixed

I was a little confused about has-featured-top vs. featured-top but I see one goes in the body tag and the other goes on the div.

Committed and pushed to 8.0.x. Thanks!

  • webchick committed 33ec961 on 8.0.x
    Issue #2398469 by DickJohnson, LewisNyman, emma.maria, kandra, mherchel...

Status: Fixed » Closed (fixed)

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