Problem/Motivation
Our CSS standards recommend that CSS is split up into smaller files inline with these categories:
- Base
- Layout
- Component
- Theme
Explanations of what each file contains can be found here.
Proposed resolution
Let's split up Bartik's style.css into these categories, just like we did with the Seven theme. Let's not fix any problems we see while moving files, just shift the CSS as it is into whichever file it fits into.
Remaining tasks
Write a patch.Make sure the legacy color module doesn't break, see #2.Fix theCssCollectionGrouperUnitTest.php(tests/Drupal/Tests/Asset/CssCollectionGrouperUnitTest.php).Review the patch (code). Keep in mind that you should have some knowledge about SMACSS in order to review this patch. Are the files separated correctly?- Manually review the patch. Does everything look the same when the patch is applied, since only files are moved?
Test scenario: Standard install, with 2 nodes (Foo and Bar), each shown in the main menu, with Bar being a child of Foo. Also a custom block.
Compare the following with Phantom CSS, and manually when using contextual links//user/login/user/register/user/1/node/1- Article node/node/2- Basic page node/contact/search/node/search/user?keys=admin
Finally, also test with Color module.
- RTBC!
User interface changes
None
API changes
None
Beta phase evaluation
| Issue category | Tasks because currently Bartik is not inline with our own coding standards. We did the same thing for Seven. |
|---|---|
| Issue priority | Important because this is part of #2372045: [META] The plan for Bartik which tries to make Bartik a better theme for front-end developers. It's a blocker for getting other (css) issues fixed. |
| Unfrozen changes | Unfrozen because it only changes the Bartik theme css file structure. |
| Prioritized changes | The main goal of this issue is getting Bartik compatible with our css file organisation coding standards. |
| Comment | File | Size | Author |
|---|---|---|---|
| #128 | Create_Article___drupal8_dev.png | 619.12 KB | lewisnyman |
| #125 | Screen Shot 2014-12-13 at 1.04.48 PM.png | 126.41 KB | lauriii |
| #118 | split_bartik_c_css_into-2375673-118.patch | 121.06 KB | lauriii |
| #118 | interdiff.txt | 51.17 KB | lauriii |
| #106 | after-patch-dropdowns.png | 98.34 KB | emma.maria |
Comments
Comment #1
davidhernandezIs this a typo? Does it mean "not fix any problems we see..." ?
Comment #2
jensimmons commentedI just want to reiterate for anyone new, the CSS which handles colors that can be changed by Color module need to be in a separate style sheet — the way it's structured in Bartik for D7. This will be a deviation from the core OCSS plan, but it's needed to prevent much head banging. I went into much more detail about why here: https://www.drupal.org/node/2372045#comment-9338781
Comment #3
sqndr commentedComment #4
sqndr commentedIf we add some documentation to the file, with some of the historical background that you've provided, it wouldn't be a problem that these rules live inside a separate stylesheet. I feel like it some way it would make sense, since it's a "component" of it's own.
Currently I've created a patch that does the basic magic. I've basically been splitting up into separate files based on the comments. It's in no way done yet. The are still some base elements in the components, the media queries are in a separate file, … There's more work to do!
I found a test that uses the
style.css. We'll have to fix this test as well when moving files.With the changes I've made here, the color module seems to continue to work just fine.
Comment #5
lauriiiPutting to Needs review to see failing tests
Comment #7
lauriiiComment #8
sqndr commentedI'll work some on this issue later today.
Comment #9
stephr commentedWorked on this issue on the DrupalCamp Gothenburg Sprint Day. (Re)Created files, directories, and moved files and content according to https://www.drupal.org/files/issues/split_bartik_s_css_into-2375673-4.patch up until line 496 (breadcrumb.css created, Breadcrumbs css content added).
Found some issues, e.g. with a missing book.css file that was not added to bartik.libraries.yml file, which I fixed.
Pls feel free to pick this up and continue work on it.
Drupal 8 commit version was:
commit 1397bd65bc2614287621622b113396593333813c
Author: Nathaniel Catchpole
Comment #11
sqndr commented@stephr: Please make sure to not work on issues that are assigned to someone, especially if they commented that they're working on it. If the issue is assigned to someone and the last update was more than a week ago, ask first if it's okay to work on the issue. ;)Comment #12
sqndr commentedAnother patch, that fixes most of the file movements + fixes some comments and tests that refer to the old
css/style.cssfile.Changing to needs review to run the tests on testbot. If everything goes well, only one test should fail. Fingers crossed!
Comment #13
sqndr commentedComment #17
sqndr commentedNeed to fix this comment.
Comment #18
sqndr commentedComment #19
Jeff Burnz commentedColor module can rewrite an array of stylesheets, so that could be SMACCified also if we wanted to go that far.
Comment #20
DickJohnson commentedWorking on this today 22.11.14 on finnish Drupal user groups sprint. Assigned to myself.
Comment #21
emma.mariaComment #22
DickJohnson commentedDid a manual reroll for patch as some css had changed. It would be very good not to make the changes before split is done. I have a backup of style.css before the change and I'm going to add it to next message tomorrow morning.
Didn't touch the tests. Just made a split for css's.
Comment #23
lauriiiPutting to needs review to see what testbot has to say
Comment #24
DickJohnson commentedLast patch lacked few things f.ex bartik.libraries.yml file. Also added few tests.
Comment #27
DickJohnson commentedTried to fix the tests.
Comment #28
DickJohnson commentedWhile looking into split with fresh pair of eyes around we made a notice that even stuff from layout.css was moved to layout/layout.css the ole layout.css was still around. We also found an failure from CssCollectionGrouperUnitTest as elements.css had wrong basename.
I didn't touch the file print.css -file as I think it should be handled separately. Another completely wrongly being thing is the components/media.css but also for that I think that best way to handle it is after the smaccsifying has been done and separately to this issue.
Comment #31
DickJohnson commentedFixed the taxonomy and menu tests. Should be one failure left.
Comment #32
DickJohnson commentedTo get testbot stuff.
Comment #33
lauriiiComment #35
lauriiiWe need the beta evaluation block to the issue summary
Comment #36
lauriiiWe still have some visual changes on the layout
Before:

After:

Comment #37
DickJohnson commentedTypo on buttons.css on bartik.libraries.yml. Fixed it.
Comment #38
DickJohnson commentedComment #39
lauriiiProblem with the sidebars is that it color.css sets color for the borders but its being overrided on the sidebar.css with
border: 1px solid;. We could useborder-width: 1px; border-style: solid;in the sidebar.css to avoid this problem.Comment #40
DickJohnson commentedFixed the broken border.
Comment #42
lewisnymanI don't think we should have todo's in this file, let's just create follow up issues. Also should we be removing the print css? Is there an issue for that?
We are also loading this css file unnecessarily, as it is being loaded in it's own library below. We should update the page for that css file
Missing new lines at the end of files
Content seems like a very generic name for a file. It looks like a lot of the classes in here are to do with nodes. So node.css might be a good idea.
There are also a lot of field CSS so maybe we should move them to field.css?
node-preview should go into it's own CSS file that that is it's own component.
Skip link should go into it's own file.
pager styles should go into their own CSS file
tips look like it's own component as well
Maybe this can just go into layout.css?
Can we split up search form and search results into separate files? They are separate components
Looks like this styling should go into base/elements.css?
Can we not have a hacks file please? Can we move these styles into meaningful file name? Maybe user.css/forum.css/contextual.css?
Comment #43
lauriiiThanks for working on this issue @DickJohnson! To make reviewing easier next time you should create interdiff.
Comment #45
DickJohnson commentedFixed the problems on coding standards. Fixed bartik.libraries.yml for all parts reported. Got rid of main.css, made a set of new files to components. Thanks for tip on interdiff, going to create that kind of thing next time I'll make a patch.
I left few unwanted files like hacks.css and media.css around as those are mostly the kind of things we should get rid of when doing more refactoring & recoding of bartik. On this issue the importantest thing was the split. Still, if you want to name hacks.css as common.css or contextual.css or whatever we can do it.
Comment #46
DickJohnson commentedComment #48
DickJohnson commentedAdded interdiff for last two patches.
Comment #49
lewisnymanI've been trying to figured out why the patch is failing. I've narrowed it down to some change in the libraries file. If I delete the last 10 css files from the libraries.yml file then the test seems to pass. I have no idea why. See the interdiff
Comment #50
sqndr commentedChanging back to Needs work because of #49. The test now passes, but not all the files are included. Let's figure out why!
Comment #51
DickJohnson commentedAfter talking with @lewisnyman we decided to try different kind of setup on bartik.libraries.yml to see what happens.
Comment #52
sqndr commentedSeems like testbot like the patch now. Any idea why it works now? Great work! If #2377397: Themes should use libraries, not individual stylesheets gets committed first, it will also rename the tag in the info file. We would also ask there to no touch Bartik and fix it in this issue, to make sure we don't break each others work.
Comment #53
lauriii@sqndr: The problem we had there was really tricky. When I looked it I couldn't find any connection between the failing test and this patch. Both ways CSS files were loaded and visually everything was good. Any how this fixes the test.
Libraries were not attached on the info file so they were not loaded anywhere. I added them to the info file and I see something like this so this still needs work:
Comment #54
lauriiiPutting still to needs review for testbot
Comment #56
DickJohnson commentedOk, so my first test went well because the css-files weren't actually added because of lackness of css/components on bartik.info.yml. Now the issue is being "fixed" (read: not getting failure from testbot) if you drop any 6 css files from components on bartik.libraries.yml. So it looks like there somekind of limit for 26 files on one tree in yml file. Makes no sense.
Comment #57
fabianx commentedAssigning to Wim, that is his specialty :)
Comment #58
DickJohnson commentedAnd as a proof a patch and interdiff.
Comment #59
DickJohnson commentedComment #61
DickJohnson commentedWow.
Comment #62
wim leersI haven't finished debugging yet, but I'm betting it has something to do with the different way of loading CSS files to support IE's silly limitations. From
CssCollectionRenderer:Comment #64
wim leersMy suspicion was correct. But not in the way I thought it'd be; it's a very subtle, very ridiculous problem! :)
It's a combination of:
assertText()to verify strings are present that happen to also be CSS file names (system.themeis a config entity and part of the name of the CSS file/core/modules/system/css/system.theme.cssassertText()works on<link rel="stylesheet" href="…/system.theme.css">(HEAD, because there are much fewer CSS files to load) versus<style>@import("…/system.theme.css")</style>(with patch, because we exceed the 31-file limit cited in #62): in the former, the CSS file is in an attribute of the element and hence doesn't match, in the latter, the CSS file is in thetextNodeof the element and hence does match. I think it'd be fair to say that we never ever ever want to match the text content of a<style>tag, but that's unfortunately how it works in HEAD.Attached is the suggested interdiff to fix
ConfigImportUITest, which makes it more specific. I'll leave it to the people active in this issue to choose which patch to apply this suggested interdiff to; it's not quite clear to me which it should be applied to :)Comment #65
wim leersComment #67
DickJohnson commentedRerolled to #45 and applied Wim Leers patch.
Comment #68
lauriiiStarts looking better. Could we remove that extra space?
Comment #69
DickJohnson commentedSure.
Comment #70
lauriiiMenu is still broken:
Comment #71
wim leersYep, this is why I was saying in IRC that the CSS was still broken; during the splitting up into multiple files, some specifically ordered CSS was probably changed.
Comment #72
lewisnymanI guess we shouldn't place them in alphabetical order for now until we have cleaned up to selectors so conflict less.
Comment #73
DickJohnson commentedYeah. Media.css must be loaded after others and also files were pointing to wrong directories.
Comment #74
wim leersComment #76
DickJohnson commentedAccidentally removed bartik.libraries.yml from the latest patch.
Comment #77
DickJohnson commentedComment #79
DickJohnson commentedTried to reroll.
Comment #81
DickJohnson commentedFixed the issues on ConfigImportUITest.php.
Comment #82
DickJohnson commentedTo see testbot.
Comment #84
lewisnymanReroll. I can't see why this would fail now. Where are we changing Bartik settings in this test?
Comment #86
lauriiiThis patch is not gonna apply because it needs reroll. This should fix the tests.
Comment #88
lauriiiRErolled
Comment #89
lauriiiLast patch didnt remove the styles.css file
Comment #90
wim leersI'm afraid this looks very broken:

Probably a silly mistake? :)
Comment #91
lewisnymanI will take a look at this. It's also important to verify that we aren't loosing CSS changes that have been committed when we reroll
I used this command to find all CSS changes in Bartik since: #22
git log --since="2014-11-22" core/themes/bartik/css/The output was:
Comment #92
lewisnymanThe paths for colors.css and layout.css were wrong. I also changed global-styling to global_styling because it seems consistent with maintenance_page?
Also, we did regress on #2365653: CSS definition for one sidebar and 560 to 850 px not correct so i fixed that.
Comment #93
wim leers#92: I'd say: stick to
global-stylingat least for now, so that it's consistent with every other theme in core? But it's a tiny, tiny detail, so you can choose what you want. We have periods, dashes and underscores all across core. That's another thing to standardize… :P(Also: AFAICT we use dashes to separate words in filenames as well, including in Bartik, so we probably want to apply the same logic here?)
Other than that: this one works! It looks exactly the same. What's the best way to get this to RTBC? Sit down with two D8 sites next to each other, look at many pages, try to spot any differences?
Comment #94
lewisnymanSure thing.
Let's make a list of test pages and put them in the issue summary. I might get a PhantomCSS install running to check the pages
Comment #95
wim leersWOOT! :)
Added some initial steps to the IS. Feel free to expand.
Comment #96
sqndr commentedGreat idea! LewisNyman++
Comment #97
sqndr commentedAdd the Beta phase evaluation. Please review and make changes. :)
Comment #98
DickJohnson commentedI spent few hours on testing this. Testing was done with latest Chrome and Firefox.
What I did:
1. Added different kind of content of various content types. Long nodes, short nodes, comments etc.
1.1 Also custom blocks
2. Created views listing content, and taxonomy terms inc descriptions
3. I placed the content, blocks and views to all regions, one by one
4. Checked all the listing pages, checked user page, checked article & basic page pages.
5. Added new menus to different regions
6. If I saw anything unusual I took a clean install of Drupal 8 and compared
What I noticed:
There was a lot of moments where I thought something is broken but it wasn't. From my point of view everything is working in the patch.
And as a proof a screenshot that I actually did something. There's no sane way to screenshot that everything is working.
So I'd say RTBC.
-Erno
Comment #99
lewisnymanComment #100
lewisnymanOk, I played around with BackstopJS and found it to be very useful indeed. I've attached my configuration file, renamed to backstop.json._txt, so instead of running
gulp genConfigyou can just copy my config into the correct place and make sure that it's rename to the .json file extension. You will have to change the URLs to your local install though.I found some regressions! Some of them are very subtle. The only problem is that the report runs locally and I haven't found a way to share it in a .zip or flat html. The best I can do now is take screenshots of the failures.
Comment #101
DickJohnson commentedThere seems to be two kind of issues: regression and non-regression issues. Example on non-regression issue is on menu right corner. The bug really is because of ../../../ instead of ../../../../
Comment #102
DickJohnson commentedHere is a patch fixing the non-regression issue.
Comment #103
DickJohnson commentedComment #104
DickJohnson commentedIt looks like basic copy-paste error instead of regression after all.
Comment #105
DickJohnson commentedForgot the patch.
Comment #106
emma.mariaThe latest patch still has some visual failures.
The sidebar has moved higher up at every screen width...
For example on desktop when it sits on the left of the main content it is higher up.
Desktop testing:

Before patch:

After patch:

And on mobile the same thing happens the sidebar is underneath the main content section, it sits higher up too...
Mobile testing:

Also the primary tabs lose their horizontal line across at every screen width...
Seen in...

Also when Bartik is the admin theme, all of the above happens, plus dropbuttons have lost their styling completely....
Desktop testing...

Mobile testing...

Clear screenshot...

Also with the file structure can we please try to remove hacks.css. If it's contents cannot be placed in a CSS file, please rename to _overrides.css or something similiar.
From all the above this needs a little more work. But it's getting there :)
Edit: I have highlighted the bugs in bold to help them to stand out.
Comment #107
lewisnymanComment #108
lewisnymanThe tabs issue was a relative image url.
The sidebar issue was a CSS ordering issue, fixed by moving layout.css back up to the top.
The dropbutton problem was because CSS files are still set to replace each other if they have the same name, and for some reason the misc/dropbutton.css is being loaded after the theme dropbutton.css and overwriting it. This is annoying but not a problem to fix in this issue. I copied the naming from Seven and called the file dropbutton.component.css.
Looks like we're almost there?
Comment #109
lauriiiI did huge amount of testing on this and it seems to be working mostly. I've tested all the core modules, even the ones disabled by default. Only thing I could find was these tabs are still having some regression:
Comment #110
lewisnymanNice, I fixed this problem by moving the vertical tabs CSS from form.css into another file. The filename also has to include .component because there is already a vertical-tabs.css in core. This is still really annoying so I've created an issue here: #2389735: Core and base theme CSS files in libraries override theme CSS files with the same name
Comment #111
lauriiiGood job! Looks good to me. I can say visually this is RTBC. I haven't looked at the code so I won't RTBC this.
Comment #112
wim leersIMHO this makes it much easier to work on Bartik's CSS. Much easier to navigate around. Hurray :)
Here's a code review. It looks great, so only nits.
Perhaps comments for explaining the reason for the inconsistent filenames would be useful?
Are these headers still necessary? Aren't they implied by the filename?
Also: sometimes, they have a newline after them, sometimes they don't. And occasionally, there even is no header at all.
Missing trailing newline.
Comment #113
emma.maria@Wim Leers for #112
1. We had to name the files like this as for some reason the system CSS files of the same names were stopping the Bartik ones from loading and we were missing CSS. We have this file naming structure in Seven too.
2. We are fixing the headers in a follow up patch or patches. We wanted to just get everything split up, leave the code as it is and then we can improve each stylesheet separately in issues instead of it all being in one monster patch.
3. But yes we do need to fix trailing spaces however! They are a result of the work in this issue.
Setting to Needs Work to fix 3.
Comment #114
wim leers#113:
Comment #115
emma.mariaHate to say this but after changes to core today, the patch no longer applies.
Comment #116
lauriiiComment #117
lauriiiComment #118
lauriiiThis patch fixed Wim Leers' points 1 & 3 from #112. Btw last patch wasn't removing the styles.css so ignore it completely.
Comment #119
wim leers#118 is identical code-wise to #110 (I manually compared), it was merely a rebase on latest HEAD. It was RTBC visually (style-wise) as of #111. It only needed a code review. I just did that.
So: RTBC! :)
Comment #120
emma.mariaI tested the newest patch visually and the issues in #106 have been fixed.
I also applied the patch and it applied cleanly with no whitespace errors.
RTBC++
Comment #121
sqndr commentedNice! Go Team Bartik!
RTBC++
Comment #123
tim.plunkettWhy all these changes? I don't see how they are related?
Comment #124
wim leers@Tim: see #62 and #64. Basically: those tests verify config keys showing up in the HTML source, but some of those keys happen to be identical to asset file names!
Comment #125
lauriiiI'm sorry but I found one more bug on the RTL layout:

Comment #126
sqndr commentedCould you tell us where you found the bug - on what page? Is this since the patch?
Comment #127
wim leers@sqndr: that's the node form in a narrow viewport.
Comment #128
lewisnymanI tested this scenario without the patch and it already exists in HEAD. This problem was not introduced in this patch.

Comment #130
DickJohnson commentedI can confirm lewisnymans report. It exists in core already.
Comment #132
lewisnymanPhew, it was a ghost fail :D
Comment #133
wim leersThe pre-existing RTL problems in #125–#128 are going to be fixed by #2329649: Fix node create page RTL CSS and don't conflict with this patch :)
Comment #135
DickJohnson commentedPatch doesn't apply to latest head. Needs reroll.
Comment #136
DickJohnson commentedNo, sorry, it should work after all.
Comment #138
DickJohnson commentedComment #139
webchickWow, great work on this, folks! Exciting to see Bartik getting some love in D8. :)
I will fully admit I did not review every line of this patch. :) However, I can see that lots of effort and testing went into this, and if it does introduce some bugs, much easier to fix them in tiny ~500b patches than as part of a ~150K patch.
Since this is a markup-affecting patch, it's under the list of things we can commit at https://www.drupal.org/contribute/core/beta-changes, committed and pushed to 8.0.x. YEAH! :)
Comment #141
emma.mariaYay an early Christmas present! Thanks Webchick, thanks all for your hard work.