Problem/Motivation
As per the Drupal CSS file organisation standards for themes, see here.
State rules, including media queries, should be included with the component to which they apply.
Therefore we should not have the separate CSS file media.css containing all of the media query declarations for various components in Bartik .
The "media query" code needs to put with the component it applies to by moving each component section in media.css to the relevant component files.
Proposed resolution
Create a patch to move out all of the code from media.css and into the relevant component's CSS files.
If the component's CSS file does not exist yet create one alongside the existing.
Remove all traces of the media.css file.
Remaining tasks
Create a patch.
Carry out a code review - check the code is in the right places and the standards are met.
Carry out a visual review + screenshots - check nothing is broken visually in Bartik.
User interface changes
NONE - this is a code refactoring issue.
API changes
n/a
Beta phase evaluation
| Comment | File | Size | Author |
|---|---|---|---|
| #21 | interdiff-20-13.txt | 554 bytes | idebr |
| #21 | 2399709-20.patch | 11.51 KB | idebr |
| #17 | 2399709 - BackstopJS Report.pdf | 1.95 MB | lewisnyman |
Comments
Comment #1
DickJohnson commentedInvestigated this a bit and this seems to be pretty straight forward issue. Patch as attachment. Didn't touch coding standards as we have separate issues for coding standards per component.
Comment #2
DickJohnson commentedComment #3
lewisnymanWe can remove these comments now that they are in the same file. Also we don't need to leave any blank lines above the media queries
Let's try and make sure that we are placing the media queries as close as possible to the elements/components that they are affecting instead of at the bottom of the file
Comment #4
DickJohnson commentedMade the changes @lewisnyman suggested.
Comment #5
idebr commentedI think LewisNyman meant this part could be included below the first #logo {} declaration as well
I think this comment is superfluous as well and it can be deleted as well per #3 LewisNyman
Same for this comment
/* -- Triptych --- /*. Also this media query should be closer to the original#triptych h2declaration.Comment #6
DickJohnson commentedOkay.
1. Moved media-queries of .region-header to layout.css.
2. Reorganized header.css so that media-queries are right after original styles
2.1 In case there's LTR and RTL styles for same element media-queries are coming after both
3. Removed the triptych-comment
Comment #7
DickJohnson commentedComment #8
idebr commentedYou missed one comment from media.css (sorry :P)
After that, this is good to go.
Comment #9
DickJohnson commentedI thought that I removed it previous one, but maybe I missed the save button. On primary-menu.css I would keep the media queries on bottom.
Comment #10
DickJohnson commentedComment #11
idebr commentedLooks good, thanks @DickJohnson!
Comment #12
lewisnymanLooking good!
The only thing I found was this media query at the bottom of the file, instead of near the selectors components.
Comment #13
idebr commentedNice catch @LewisNyman, thanks :)
Let's finish this up so we can continue on the components
Comment #14
DickJohnson commentedChecked this patch and it fixing what @lewisnyman said on #12.
Comment #15
emma.mariaThis issue needs manual testing and a visual review with screenshots. We have moved CSS code around and we need to check we haven't broken anything on the frontend. I'd rather find this out before it is committed :)
Comment #16
emma.mariaComment #17
lewisnymanI ran Backstop JS on a decent selection of pages, no pages failed. Report attached,
Comment #21
idebr commentedPatch no longer applied after #2142653: Change default logo filetype to .svg and add an SVG version of Druplicon. Rerolled.
Comment #22
idebr commentedSettings back to RTBC per #17 and the last patch is a reroll.
Comment #23
wim leersThis is a big improvement from a maintainability and understandability POV, I think. Great patch!
Comment #25
alexpottCommitted c8ec0cd and pushed to 8.0.x. Thanks!
Why are these not joined together? Do we know of any performance impacts. Looking around on the web I found https://helloanselm.com/2014/web-performance-one-or-thousand-media-queries/ so it seems that the numbers of queries has no meaningful impact other than increase in file size (more bytes to be downloaded) and we need to ensure that a theme uses consistent queries. Obviously the more queries we have in a theme the more chance we have of them becoming inconsistent. For me this is like the typography issue. Splitting this out by component increases the possibility of inconsistencies. A way to mitigate this will be to document the allowed font stack and media queries somewhere - maybe the theme's .info.yml file? However that can be a follow up to this.
Unnecessary blank line added. Fixed on commit.
Comment #27
wim leers#25.1: I think the whole reason this issue is done is exactly to avoid inconsistencies. I think the thinking is that it's easier to ensure the same media query is applied consistently in all of a theme's CSS assets (since there will only be at most a handful different ones) than it is to ensure that the different CSS declarations for the same component under different media queries are all kept in sync/consistent.
Comment #28
lewisnymanIf we could use Sass then we could use variables to keep this consistent in the way everyone else does now-a-days. I guess we'll have to wait for CSS variables http://caniuse.com/#feat=css-variables
Comment #29
wim leers#28: , twice. :)