✨(courses) Added new CSS stylesheet dedicated to print for course details #1853
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose
Courses details should be exportable as PDF.
Proposal
This pull request implement a new CSS stylesheet dedicated to print media type, it means it almost restart from zero a basic layout optimized for printing. This way has been choosen over the "additional print override" (using
@media
rule) because overriding is very complicated to manage against the tons of layout styles, it would mean to rewrite almost everything to neutralize the "screen" media stylesheet.Print optimization
Print optimization is essentially about readability and space saving. The layout is almost fully "black on white", because site theme colors are really accurate with the theme background and backgrounds are disabled by default from every browser (to economize printers ink).
Content break management
Also with printing there is an important behavior to manage: content break between pages because browser will split an image or a paragraph on two pages if they do not fit in the same page when it reach its end of space. So we need to add some rules to avoid breaking some content and instead prefers to push it to another page. This is not perfect, because it can lead some time to some empty space on pages because a content can not stand in when it is too long to fit, but in the end it is the safest one for readability.
Conclusion
Finally an user that would want to export a course detail to a PDF will just have to use the print method and choose the "export to file" method.
Here is a sample from a demo course page printed to PDF file using the default browser (Firefox, but Chrome is similar) print options (default margin, no background and with page context header and footer):
Cross-platform_scalable_migration.print-only.without-background.pdf