-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Include print styles in main stylesheet #6922
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will be worthwhile, thank you!
@media screen { | ||
@import "./header"; | ||
@import "./forms"; | ||
@import "./components/comments"; | ||
@import "./components/flash_messages"; | ||
@import "./components/date_picker"; | ||
@import "./components/tables"; | ||
@import "./components/batch_actions"; | ||
@import "./components/modal_dialog"; | ||
@import "./components/blank_slates"; | ||
@import "./components/breadcrumbs"; | ||
@import "./components/dropdown_menu"; | ||
@import "./components/buttons"; | ||
@import "./components/grid"; | ||
@import "./components/links"; | ||
@import "./components/pagination"; | ||
@import "./components/panels"; | ||
@import "./components/columns"; | ||
@import "./components/scopes"; | ||
@import "./components/status_tags"; | ||
@import "./components/table_tools"; | ||
@import "./components/index_list"; | ||
@import "./components/unsupported_browser"; | ||
@import "./components/tabs"; | ||
@import "./pages/logged_out"; | ||
@import "./structure/footer"; | ||
@import "./structure/main_structure"; | ||
@import "./structure/title_bar"; | ||
|
||
body { | ||
@include sans-family; | ||
line-height: 1.5; | ||
font-size: 72%; | ||
background: $body-background-color; | ||
color: $text-color; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The admin CSS is already loaded as a screen media stylesheet so this isn't necessary. It would be best to remove the screen media wrapper part.
@media screen { | |
@import "./header"; | |
@import "./forms"; | |
@import "./components/comments"; | |
@import "./components/flash_messages"; | |
@import "./components/date_picker"; | |
@import "./components/tables"; | |
@import "./components/batch_actions"; | |
@import "./components/modal_dialog"; | |
@import "./components/blank_slates"; | |
@import "./components/breadcrumbs"; | |
@import "./components/dropdown_menu"; | |
@import "./components/buttons"; | |
@import "./components/grid"; | |
@import "./components/links"; | |
@import "./components/pagination"; | |
@import "./components/panels"; | |
@import "./components/columns"; | |
@import "./components/scopes"; | |
@import "./components/status_tags"; | |
@import "./components/table_tools"; | |
@import "./components/index_list"; | |
@import "./components/unsupported_browser"; | |
@import "./components/tabs"; | |
@import "./pages/logged_out"; | |
@import "./structure/footer"; | |
@import "./structure/main_structure"; | |
@import "./structure/title_bar"; | |
body { | |
@include sans-family; | |
line-height: 1.5; | |
font-size: 72%; | |
background: $body-background-color; | |
color: $text-color; | |
} | |
} | |
@import "./header"; | |
@import "./forms"; | |
@import "./components/comments"; | |
@import "./components/flash_messages"; | |
@import "./components/date_picker"; | |
@import "./components/tables"; | |
@import "./components/batch_actions"; | |
@import "./components/modal_dialog"; | |
@import "./components/blank_slates"; | |
@import "./components/breadcrumbs"; | |
@import "./components/dropdown_menu"; | |
@import "./components/buttons"; | |
@import "./components/grid"; | |
@import "./components/links"; | |
@import "./components/pagination"; | |
@import "./components/panels"; | |
@import "./components/columns"; | |
@import "./components/scopes"; | |
@import "./components/status_tags"; | |
@import "./components/table_tools"; | |
@import "./components/index_list"; | |
@import "./components/unsupported_browser"; | |
@import "./components/tabs"; | |
@import "./pages/logged_out"; | |
@import "./structure/footer"; | |
@import "./structure/main_structure"; | |
@import "./structure/title_bar"; | |
body { | |
@include sans-family; | |
line-height: 1.5; | |
font-size: 72%; | |
background: $body-background-color; | |
color: $text-color; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this is an unintentional mistake on my part, I'm loading the (now only) stylesheet with media="screen"
, but the stylesheet should be loaded for all media types, right?
If I understood your idea correctly, these blocks are correct because otherwise all the styles will be applied in the "print view" which is unintented (at least not how it works currently).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that makes sense about the separate screen/print blocks because in #3862 the print styles were updated so many of the elements that were originally displayed in print mode weren't anymore. Thanks!
} | ||
} | ||
|
||
@media print { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had this line defined in the _print.scss
partial instead. I'm not sure but I figured that is required for it to work because I think Sass only allows @import "...";
at the outermost level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I moved it ouside, because since I was wrapping the rest of the styles under @media screen
, moving it outside brought a nice simmetry in my opinion.
Not sure about Sass an not outermost imports, it seems to work just fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok great, thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for having a look @javierjulio.
I replied to your comments, the PR as it was didn't work correctly. I'll push an update with a working version so you can re-review.
01a23fc
to
890c680
Compare
This should be working now, but it seems that I need to fix some specs. Anyways, the idea of the outermost |
890c680
to
5f251af
Compare
No need to do this separately which makes an extra http request, plus this has the benefit of delaying print styles until needed. I’ve been doing this for a long time now and as its been well supported to include print styles using a media block. The HTML5 Boilerplate has stressed this as a good default approach for many years now. https://github.com/h5bp/html5-boilerplate/blob/c9f88cc79d380150e4e2e39e3c2deccfe8aa3d8c/dist/css/style.css#L189-L193
5f251af
to
14b64cd
Compare
Alright, I spotted yet another error. I had changed the load order for the print media, so that a couple of SASS variables were being set after the typography import was using them, so they were not getting applied. I think the current version should be 100% equivalent to what we have now, and only provide the improvement of loading a single stylesheet. |
Yes that sounds right and makes sense. The two I had changed/removed were |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! ❤️
@deivid-rodriguez would it be possible to do another release to include this now that it's merged? |
Sorry for the delay, I'll work on a release 👍. |
@deivid-rodriguez Was it released since? I can't find references to issue EDIT: My deepest apologies. Just realized my project had a direct reference to that file in the manifest, and the file got renamed to |
No need to do this separately which makes an extra http request, plus this has the benefit of delaying print styles until needed. I’ve been doing this for a long time now and as its been well supported to include print styles using a media block. The HTML5 Boilerplate has stressed this as a good default approach for many years now. https://github.com/h5bp/html5-boilerplate/blob/master/src/css/main.css#L205-L209
Extracted from #3862.
Closes #6908.