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/footer.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
- 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. -
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. - 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.
-
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 { }. - 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.
- 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.
- 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
- Add a File comment to the top of the stylesheet - see here for guidelines.
- Check any other comments are formatted correctly - see here for guidelines.
- Check Whitespace is being used correctly, this includes indentations and line breaks - see here for guidelines.
- Check the formatting of rulesets, properties and media queries are correct - see here for guidelines.
- 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
| 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 |
| Comment | File | Size | Author |
|---|---|---|---|
| #98 | bartik-clean-up-footer-2398471-98.patch | 10.77 KB | idebr |
| #96 | 2398471-95-after.png | 361.34 KB | idebr |
| #96 | 2398471-95-before.png | 359.26 KB | idebr |
| #95 | bartik-clean-up-footer-2398471-95.patch | 12.84 KB | crazyrohila |
| #95 | interdiff-93-95.txt | 1.23 KB | crazyrohila |
Comments
Comment #1
DickJohnson commentedInvestigated this a bit. I think that current footer.css (+some footer related stuff from other files) should be split up to either 2 or 4 separate files. If 2, then one for structural styles and one for visual styles. If 4, then one for footer menu, one for footer blocks, one for footer columns and one for footer generally.
Comment #2
lewisnymanIn SMACSS world, you would avoid re-styling components based on their location, and instead use variants. Maybe it would sense to do the same here.
I think separating the structural/layout and visual styling is a bad idea for themes, although I think it makes sense for modules. All code related to a component should be in the same file.
Comment #3
emma.mariaComment #4
DickJohnson commentedStarted to work a bit on this. At this stage I removed footer related id's from page.html.twig and changed css on typography.css, colors.css, contextual.css, footer.css, table.css, layout.css and print.css to match this change.
Comment #5
DickJohnson commentedTo see testbot.
Comment #6
DickJohnson commentedMade a split from footer.css to four different files: footer.css, footer-menu.css, footer-columns.css and footer-wrapper.css. Cleaned up a bit the footer.css and changed the preprocess that adds footer-columns class to body. Instead is adding layout-footer-columns now.
Comment #7
DickJohnson commentedNew files were missing and fixed some coding standard issues also.
Comment #8
lewisnyman.footer__wrapper is a child of .footer. So it should be able to be contained in the same file as .footer.
We have loads of mentioned of the word footer here, the logic is kind of weird. How can we have a footer class inside of a footer element? I think we need to rewrite this markup and maybe rename the footer region so it makes sense. We also switch between using the footer-wrapper element as the main parent and the .footer element. I also think it makes sense to rename this component to site-footer because it's more specific, vs the generic meaning of the footer HTML component.
Here's is a suggestion for the footer markup:
Comment #9
emma.mariaI agree that the footer element should be the only thing that is defined with a class of footer (or some variant like site-footer as above).
I agree with renaming the regions to footer-first, footer-second, etc etc. Other areas of the page that have multiple regions use this naming convention (sidebar, triptych etc) so the footer should do too.
My only change to add is that we have specific styles for the existing footer / proposed footer_fifth region. So there should be a class added to what is wrapped around this region. Also as the two sections (columns and the full width section) are both equally level but separate sections of the footer.
I think we should split footer into .site-footer__top and .site-footer__bottom.
So my proposed markup is...
Therefore the classes hierachy without all the markup bumf looks like this...
Comment #10
DickJohnson commentedI agree on most of stuff, but I wouldn't like to use footer_fifth as it's completely different element than previous four.
Comment #11
emma.maria@DickJohnson do you have an alternative suggestion? It shouldn't stay as Footer as the whole section is the footer and the other regions have specific names.
Comment #12
lewisnymanIt's not a good practice to name the region after how it looks, because on narrow devices those columns are no longer columns
Comment #13
DickJohnson commentedOk, point taken.
Comment #14
DickJohnson commentedNew patch around. Don't need feedback on this as it's nowhere near ready. Sending it to testbot to see what happens.
Comment #15
DickJohnson commentedAnd the patch.
Comment #17
DickJohnson commentedComment #18
DickJohnson commentedAfter investigating this a bit, it's probably better to continue with #7 instead of #15.
Comment #19
DickJohnson commentedDid some work on page.html.twig. Changed markup near the one @lewisnyman and @emma.maria suggested and changed the css to match it.
Comment #20
DickJohnson commentedTo see the testbot.
Comment #21
DickJohnson commentedDid some more changes to page.twig.html and the css-files related to it and now we're starting to be pretty close on emma.marias suggestion.
This one also to testbot just to see the results.
Comment #22
DickJohnson commentedNo idea where that came from.
Comment #23
lewisnymanThe site-footer__wrapper is a subcomponent of site-footer so it can got into the same file.
This should also be renamed to site-footer to match the new component name.
I think we need to replace this with site-footer__wrapper instead of removing it
Instead of replacing #footer with .site-footer__bottom we should be trying to be as broad as possible here. Let's just use .footer as the parent selector where ever possible
Comment #24
DickJohnson commented#23.1 Currently there is no styles for .site-footer.css outside layout.css, so I'll rename the file as site-footer.css which can be used for .site-footer and site-footer__wrapper styles, right?
#23.2 Footer.css is now for stuff that was previously targetted with #footer. #footer is now known ass .site-footer__bottom, so my guess is that this should be renamed as site-footer-bottom.css.
#23.3 I moved the style to footer-wrapper.css. Trying to think why I did it, but I'm not sure. For me it really doesnt make any difference in which one of these two files the bg-color is living. For consistency the original one is better tbh.
#23.4 I think this is as it should be. The styles were previously targetting only the content of blocks in #footer.
As a reminder. Originally the structure was:
Now it's:
Comment #25
DickJohnson commentedAssigned to myself.
Comment #26
DickJohnson commentedRenamed the files:
footer.css -> site-footer-bottom.css
footer-wrapper.css -> site-footer.css
footer-menu.css -> site-footer-bottom-menu.css
footer-columns.css -> site-footer-top.css
Out of remaining todo-list I'm not completely sure if:
suggested by both lewisnyman and emma.maria can fit the current issue summary. I think that is affecting a lot of different things and not being just pure refactoring, right?
Comment #27
DickJohnson commentedComment #28
emma.mariaAll of the footer styles need to be put into one file
site-footer.css.site-footer__topandsite-footer__bottomare variants of site-footer and not components in themselves.Also yes we should take the region naming outside of this issue to match other region issues currently open for Bartik.
See #2402639: Rename the footer regions in Bartik.
Comment #29
DickJohnson commentedRemoved the 3 extra files based on #28.
Comment #30
DickJohnson commentedComment #31
lewisnymanThanks. I found a few things :P
It looks like we've lost some styling here?
Is it even possible to add links to the footer that aren't in a block? Do you think we could get away with removing .block .content from the selectors?
In loads of these situations we are using the .site-footer__wrapper class as the parent selector but we should be using the main component as the selector, which is site-footer. The wrapper is a sub-component
Display block is redundant when using with float.
These two sets LTR and RTL properties don't seem to match up
We need a blank line before this comment
We can also remove the .content li from these selectors... I think
Also in these situations I think we should use site-footer instead of the wrapper.
We need to change this class to 'site-footer'
Comment #32
DickJohnson commentedRerolled after changes in layout.css.
Comment #33
emma.mariaSetting to needs work as the most recent patch does not contain the suggested changes in #31.
Comment #34
DickJohnson commentedFixed: 31.1, 31.3, 31.4, 31.6, 31.7, 31.8 and 31.9.
Comment #35
DickJohnson commentedpage.html.twig cleanup went just in, so this is in need of reroll, again.
Comment #36
lauriiiComment #37
lauriiiRerolled & combined classes into one single attribute instead of having multiple class attributes.
Comment #39
lauriiiRerolled after #2392361: Bartik theme: “triptych” and footer-columns classes added to body but never used in CSS
Comment #40
DickJohnson commentedIt's starting to look good, but I think that in contextual.css and print.css we could target .site-footer instead of .site-footer__wrapper.
Comment #41
lewisnymanMe to, also in colors.css
In these situations, we don't need to provide a fallback color for rgba, because we no longer support IE8
Comment #42
lewisnymanI'll need to go through the code in browser to check to see if there are any redundant styles in there.
Comment #43
DickJohnson commentedWorking on this at dc brighton sprint.
Comment #44
DickJohnson commentedLooks like last patch is missing whole site-footer.css.
Comment #45
lewisnymanI went through and tried to find optimisations here and there. It was too hard to suggest without checking out if they broke anything first. There were loads of redundant rgba colors being used on a solid background.
Comment #46
DickJohnson commentedThat one is making a huge difference in look of footer at least for me. Putting screenshots on in short while.
Comment #47
DickJohnson commentedBefore:

After:

Comment #48
emma.mariaFrom looking at #47 you have changed (the really bad contrast) footer column titles to be white now instead of that barely can see dark grey.
There is an issue for that in Bartik somewhere to make them lighter, because currently it really does not pass an color contrast tests.
Comment #49
DickJohnson commentedComment #50
thamasComment #51
DickJohnson commentedNeeds reroll after naming change on footer got commited.
Comment #52
saki007sterrerolled the patch in #45 to accommodate the naming changes on footer.
Comment #53
saki007sterComment #55
emma.mariaWaiting on the Footer CSS regressions patch to be committed.
#2422975: Bartik footer has CSS regressions.
Comment #56
lewisnyman#2422975: Bartik footer has CSS regressions. is now fixed
Comment #57
idebr commentedPatch no longer applies:
error: patch failed: core/themes/bartik/css/components/footer.css:1
error: core/themes/bartik/css/components/footer.css: patch does not apply
error: patch failed: core/themes/bartik/css/layout.css:55
error: core/themes/bartik/css/layout.css: patch does not apply
Comment #58
davidhernandezThis should apply. I had to merge in changes and wasn't sure if which css declarations should stay or go so I just kept what seemed to belong to this issue. I didn't read everything but it looks like there was some minor changes in layout.css, so that'll need reviewing.
Comment #59
DickJohnson commentedReviewing.
Comment #60
DickJohnson commentedDoes not apply anymore.
vagrant@dev:/var/www/drupal8(8.0.x⚡) » git apply clean_up_the_footer-2398471-58.patch
error: patch failed: core/themes/bartik/css/layout.css:142
error: core/themes/bartik/css/layout.css: patch does not apply
Comment #61
lanchez commentedRerolled.
Comment #62
emma.mariaThis patch needs work.
The changes to page.html.twig in the patch in #45 fell out during the reroll in #52.
Comment #63
emma.mariaComment #64
piyuesh23 commentedComment #65
piyuesh23 commentedAdded the changes to page.html.twig. Uploading the updated patch here.
Comment #66
crazyrohila commentedStyling breaks after applying patch

Comment #67
crazyrohila commentedComment #68
crazyrohila commentedTried to inter-diff from #45, but failed.
So created patch with changes in page.htm.twig and css files according to that.
This cleanup will also cover https://www.drupal.org/node/2148319 and https://www.drupal.org/node/2304971.
Comment #69
lewisnymanI think it's better to keep each issue separate so it's easier to review and test.
Comment #71
crazyrohila commentedRemoved css of other issues and re-reolled & updated patch.
Comment #72
crazyrohila commentedSend to test bot
Comment #73
crazyrohila commentedComment #74
lewisnymanNice thanks
We need to convert this comment into a similar style that is at the top of every other file, with w @file tag, also rename it site footer
These comments aren't inline with our single line comment standards, see: https://www.drupal.org/node/1887862#comments
Comment #75
rpayanmComment #76
idebr commented@rpayanm Thanks for working on this!
The comment by @Lewis Nyman was ment for site-footer.css only. There are separate issues for the different stylesheets, for more info have a look at the meta issue: #1342054: [META] Clean up templates and CSS
The comment should be updated to 'Site footer' to reflect the new name of the component.
This patch introduces two new id-attributes that are not referenced in any CSS or javascript. If I'm not mistaken these can be removed.
Comment #77
rpayanmok thank you for you review :)
Comment #79
idebr commentedDon't mind the testbot, it's having a bad day :)
The CSS file is renamed, but the file reference is not updated in bartik.libraries.yml. This means the CSS file is no longer loaded.
These comments are not in line with our CSS coding standards, see #74.2
Comment #80
rpayanmohh that rigth :)
Comment #81
rpayanmOr would be this.
Comment #84
idebr commentedLet's leave this selector as is, since there is a separate issue for this file at #2398465: Clean up the "contextual" component in Bartik
The duplicate color statement is to provide a fallback for browsers that don't support rgba colors. Removing those is probably better to leave for another issue.
Same here: the duplicate color attribute is to provide a fallback for browsers that have no support for rgba colors.
And here
This is a different selector. The .site-footer__top has no margin-top.
These changes introduce a visual regression of the contextual links in the footer:
Let's remove this id as well when it is no longer in use.
Comment #85
crazyrohila commented@lewis,
Both done.
@idebr,
1. Done.
2/3/4. I think we should do this in same issue, when cleaning up specific file.
5. Done.
6. Done, but not sure this is best approach. For now
ul, liinside.contentwill get effected by styling.7. Done.
Comment #86
idebr commentedPatch no longer applies after #2398451: Clean up "layout" CSS in Bartik was committed.
@crazyrohila RE: 84.2 / 84.3 / 83.4 We left the fallback colors in on purpose in other issues mentioned in the meta #1342054: [META] Clean up templates and CSS. I love cleaning up code as much as you do (probably more), but let's leave this for another day :)
Comment #87
crazyrohila commented@idebr, That's fine.
Updated code.
Comment #88
idebr commentedChanges look good! Needs a reroll after #2148319: h2 on footer blocks must be hidden by default but must show when its enable was committed.
Comment #89
crazyrohila commentedComment #90
idebr commented@crazyrohila Thanks for the reroll! I found no more visual regressions, so that's great :). I do think we can clean up some more unused and unnecessary css:
Let's replace these selectors with
.site-footer .region?Let's replace these selectors with
.site-footer__top .region?These styles don't seem to have any effect and can be removed.
Let's split these selectors up, since the
marginandlist-styledeclaration have no effect on.menu-item.The styling for
border-coloris not RTL specific and can be removed here.Let's move these overrides to the site-footer stylesheet, as they belong to the site-footer component.
The site-footer currently uses three wrappers. Let's reduce this to two:
.site-footerand.site-footer__top/__bottom.The
.sectionclass here doesn't do anything and can be removed.The newly added class
clearfixdoesn't do anything and can be removed.Comment #91
crazyrohila commentedThere was visual regression issue against latest HEAD. Attached Screenshot.

@idebr, Thanks for feedback, appreciate that. Hope I'll have sharp eye like that after 3-4 months continue working on core's css, and can avoid these silly mistakes :P
1., 2. Done.
3., 4. Merged
site-footer__topandsite-footer__bottomli. Removedlist-styleandmargin, but we still need padding to override default padding fromsystem.theme.css5., 6. Done
7. There are two wrappers around
site-footer__topandsite-footer__bottom, one to applybackgroundand other formax-width. For Now I have removed one, and applied.layout-containerclass tosite-footer__topandsite-footer__bottom.8., 9. Done
Comment #92
idebr commented@crazyrohila Awesome changes! I found a last one:
By removing the list-style attribute, the list items now displays discs outside the container. Let's either keep the current styling (eg. no discs) or fix the display of the discs so they are placed inside the container:
Comment #93
crazyrohila commentedRemoving
list-stylefrom alluldoesn't seem a good option to me, because we are providing wysiwyg to user. So change that selector to.menuand increased padding a bit forul, ol.And there was a issue with
blockquotetoo, text was visible, which is fixed now.Before

After

Comment #94
idebr commented@crazyrohila Thanks, this is looking really great! I found two minor nitpicks and one regression:
Nitpick: the attribute has 4 spaces while the Drupal coding standards requires 2.
This adds a 1.4em padding-left to the footer menu in site-footer_bottom. You can either use .site-footer .content ul:not(.menu) or add a new selector to override the padding.
Nitpick: this newline can be removed.
Comment #95
crazyrohila commentedUpdated code.
Didn't get time to check UI, just did suggested changes. tomorrow will check changes in UI.
Comment #96
idebr commented@crazyrohila Cheers! I did another manual test to confirm there are no visual regressions.
Screenshot before:
Screenshot after:
Comment #97
wim leersThis would be much, much easier to review if it were rolled with
git diff -M10%— that'd make the diff show changes to the footer CSS, rather than showing a deleted file and an added file.Might be wise to still do that, to make it easier for a committer.
Comment #98
idebr commented@Wim Leers Thanks for the pro-tip, I learned something new today :)
Rerolled the patch in #95 with the tip from #97
Comment #99
alexpottCSS is not frozen in beta. Committed b3ab01c and pushed to 8.0.x. Thanks!