Skip to content

Commit

Permalink
Merge pull request #82 from Leo-Nicolle/develop
Browse files Browse the repository at this point in the history
Take account of paper size in print
  • Loading branch information
Leo-Nicolle authored Mar 26, 2024
2 parents 828ee94 + 9996ff6 commit 41b2a01
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
4 changes: 2 additions & 2 deletions client/src/components/Book.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<div class="book" v-if="grids && style && solutionStyle">
<GridPaper v-for="(grid, i) in grids" :key="grid.id" :grid="grid" :style="style" :exportOptions="gridExport"
:pagination="solutionStyle.pagination" :page="solutionStyle.pagination.startIdx + i" />
<IndexPaper :grids="grids" :solutionStyle="solutionStyle" :exportOptions="solutionExport"
<IndexPaper :grids="grids" :solutionStyle="solutionStyle" :format="style.paper" :exportOptions="solutionExport"
:page="solutionStyle.pagination.startIdx + grids.length" @pageCount="evt => indexPages = evt" />
<SolutionPaper :grids="grids" :solutionStyle="solutionStyle" :exportOptions="solutionExport"
<SolutionPaper :grids="grids" :solutionStyle="solutionStyle" :format="style.paper" :exportOptions="solutionExport"
:page="solutionStyle.pagination.startIdx + grids.length + indexPages" />
</div>
</template>
Expand Down
11 changes: 7 additions & 4 deletions client/src/components/Solutions.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<template>
<div v-if="grids && solutionStyle">
<FontLoader :value="solutionStyle.grids.gridN" />
<Paper v-for="(gs, i) in gridsPerPage" :key="i" :format="solutionStyle.paper" :showMargins="exportOptions.margins"
<Paper v-for="(gs, i) in gridsPerPage" :key="i" :format="printFormat" :showMargins="exportOptions.margins"
:page-number="page + i" :showPagination="exportOptions.pagination" :pagination="solutionStyle.pagination">
<div class="grids">
<div v-for="(grid, j) in gs" :key="j" class="grid-c">
<span class="gridN">{{ j + solutionStyle.pagination.startIdx }}</span>
<SVGGrid :grid="grid" :focus="nullCell" dir="horizontal" :style="solutionStyle" :export-options="exportOptions"
:export-style="exportOptions" />
<SVGGrid :grid="grid" :focus="nullCell" dir="horizontal" :style="solutionStyle"
:export-options="exportOptions" :export-style="exportOptions" />
</div>
</div>
</Paper>
Expand All @@ -19,7 +19,7 @@ import { defineProps, defineEmits } from "vue";
import SVGGrid from "./svg-renderer/Grid.vue";
import Paper from "./Paper.vue";
import FontLoader from "./fonts/FontLoader.vue";
import { Grid, nullCell, SolutionStyle } from "grid";
import { Format, Grid, nullCell, SolutionStyle } from "grid";
import { computed } from "vue";
import { ExportOptions } from "../types";
import { getFont } from "../js/useFont";
Expand All @@ -44,11 +44,14 @@ const props = defineProps<{
* What to export
*/
exportOptions: ExportOptions;
format?: Format;
/**
* number of the first page
*/
page: number;
}>();
const printFormat = computed(() => props.format || props.solutionStyle.paper);
const rows = computed(() => {
if (!props.solutionStyle) return "";
return `repeat(${props.solutionStyle.grids.rows},0)`;
Expand Down
15 changes: 8 additions & 7 deletions client/src/components/WordsIndex.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<template>
<div v-if="grids && solutionStyle">

<FontLoader :value="solutionStyle.grids.gridN" />
<FontLoader :value="solutionStyle.words" />
<Paper v-for="(words, i) in layout.wordsPerPage" :key="i" :format="solutionStyle.paper"
:showMargins="exportOptions.margins" :showPagination="exportOptions.pagination" :pageNumber="page + i"
:pagination="solutionStyle.pagination" bodyClass="body-index">
<Paper v-for="(words, i) in layout.wordsPerPage" :key="i" :format="printFormat" :showMargins="exportOptions.margins"
:showPagination="exportOptions.pagination" :pageNumber="page + i" :pagination="solutionStyle.pagination"
bodyClass="body-index">
<span class="words" ref="wordsContainer">
<span v-for="(word, j) in words" :class="typeof word === 'number' ? 'size' : 'word'" :key="word">
{{ word }}
</span>
</span>
</Paper>
<Teleport to="#outside">
<Paper class="paper ruler" :format="solutionStyle.paper" :showMargins="true" :showPagination="true" :pageNumber="1">
<Paper class="paper ruler" :format="solutionStyle.paper" :showMargins="true" :showPagination="true"
:pageNumber="1">
<span class="words ruler" ref="ruler"> </span>
</Paper>
</Teleport>
Expand All @@ -22,7 +22,7 @@

<script setup lang="ts">
import { defineProps, ref, defineEmits, watch } from "vue";
import { Grid, getAllWords, SolutionStyle } from "grid";
import { Grid, getAllWords, SolutionStyle, Format } from "grid";
import { computed } from "vue";
import Paper from "./Paper.vue";
import FontLoader from "./fonts/FontLoader.vue";
Expand All @@ -47,13 +47,14 @@ const props = defineProps<{
* The styles to render list
*/
solutionStyle: SolutionStyle;
format?: Format;
page: number;
}>();
const emit = defineEmits<{
(event: "pageCount", value: number): void;
}>();
const printFormat = computed(() => props.format || props.solutionStyle.paper);
const wordFont = computed(() => getFont(props.solutionStyle.words));
const wordsColor = computed(() => props.solutionStyle.words.color);
const sizeFont = computed(() => getFont(props.solutionStyle.size));
Expand Down

0 comments on commit 41b2a01

Please sign in to comment.