Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

Commit

Permalink
feat: use browser feature to print preview a pdf (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjent authored Apr 23, 2024
1 parent f2376f5 commit 4cee1dc
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
3 changes: 2 additions & 1 deletion components/Preview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ const component: Component = computed(() => templateMapper[template.value]);
</script>

<template>
<aside class="lg:overflow-y-auto">
<aside class="lg:overflow-y-auto print:hidden">
<section
class="w-[210mm] h-[297mm] bg-white shadow origin-top-center m-auto after:content-[''] after:block after:left-0 after:right-0 after:border-b-2 after:border-black after:border-dotted"
:style="`transform: scale(${zoomLevel / 100})`"
>
<component :is="component" />
</section>
</aside>
<component class="hidden print:block" :is="component" />
</template>
14 changes: 13 additions & 1 deletion components/TheHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ const resume = storeToRefs(useResumeStore());
const isImportError = ref(false);
function downloadPdf() {
window.print();
}
function exportToJson() {
const toExport = {
...letter,
Expand Down Expand Up @@ -93,7 +97,7 @@ function importFromJson(event: Event) {

<template>
<header
class="sticky top-0 z-10 h-[100px] flex justify-between items-center gap-2 px-10 bg-white text-pink-500 shadow-lg"
class="print:hidden sticky top-0 z-10 h-[100px] flex justify-between items-center gap-2 px-10 bg-white text-pink-500 shadow-lg"
>
<NuxtLink to="/">
<h1
Expand Down Expand Up @@ -166,6 +170,14 @@ function importFromJson(event: Event) {
</option>
</select>
</label>

<button
class="text-blue-500 flex items-center gap-1"
@click="downloadPdf"
>
<ArrowDownOnSquareIcon class="h-6" />
Download
</button>
</div>
</header>
</template>
2 changes: 1 addition & 1 deletion pages/editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const title = ref("Nice resume");
<section
class="flex flex-col bg-gradient-to-br from-blue-700 to-pink-500 backdrop-contrast-200 lg:h-[calc(100svh-100px)] lg:flex-row"
>
<Editor class="flex-1" />
<Editor class="print:hidden flex-1" />
<!-- <div class="bg-white h:2 w-full lg:h-full lg:w-2" /> -->
<Preview />
</section>
Expand Down
7 changes: 6 additions & 1 deletion tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ export default {
"./app.vue",
],
theme: {
extend: {},
extend: {
screens: {
print: { raw: "print" },
screen: { raw: "screen" },
},
},
},
plugins: [],
};

0 comments on commit 4cee1dc

Please sign in to comment.