Skip to content
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

chore(print): use css @page landscape instead of content rotation #4347

Merged
merged 1 commit into from
Dec 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions print/assets/print-preview.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
margin: 35px auto;
}

.tw-break-after-page.landscape-page {
max-width: 1123px; /* page width: A4 landscape width of 297mm at 96dpi */
min-height: 794px; /* page height: A4 landscape height of 210mm at 96dpi */
}
Comment on lines +20 to +23
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for the developer HTML preview which you can see in the iframe on the print page.


.tw-break-after-page .tw-break-after-page {
margin: 0; /* avoid margin stacking for nested `tw-break-after-page` */
padding: 0;
Expand Down
26 changes: 14 additions & 12 deletions print/components/PicassoChunk.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="tw-break-after-page">
<div class="tw-break-after-page" :class="{ 'landscape-page': landscape }">
<div :class="landscape ? 'landscape' : 'portrait'">
<div class="tw-flex tw-flex-row tw-items-baseline fullwidth">
<h1
Expand All @@ -12,8 +12,8 @@
<span>{{ camp.organizer }}</span>
<img
v-if="camp.printYSLogoOnPicasso"
:height="landscape ? 24 : 35"
:width="landscape ? 24 : 35"
height="35"
width="35"
:src="ysLogoUrl"
class="tw-self-start tw-ml-2"
/>
Expand All @@ -24,7 +24,7 @@
:days="days"
:times="times"
:schedule-entries="scheduleEntries"
:content-height="landscape ? 312 : 768"
:content-height="landscape ? 480 : 768"
/>
</div>
<div class="categories fullwidth text-sm-relative">
Expand Down Expand Up @@ -161,18 +161,20 @@ export default {
$portrait-content-width: 680; /* 794px minus 114px (=2*15mm margin) */
$portrait-content-height: 1009; /* 1123px minus 114px (=2*15mm margin) */

/* render a landscape picasso which fits into $portrait-content-width and then scale it up during rotation */
$landscape-scale: calc(#{$portrait-content-height} / #{$portrait-content-width});
@page landscape {
size: a4 landscape;
}

.landscape-page {
page: landscape;
}

.landscape {
font-size: calc(10pt / #{$landscape-scale});
font-size: 10pt;

transform-origin: top left;
transform: scale($landscape-scale, $landscape-scale)
translateY(#{$portrait-content-width}px) rotate(-90deg);
width: #{$portrait-content-height}px;
height: #{$portrait-content-width}px;

width: #{$portrait-content-width}px;
height: calc(#{$portrait-content-width} / #{$landscape-scale} * 1px);
overflow: visible;
}

Expand Down