Skip to content

Commit

Permalink
watch route change on print + better textare in defs
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo-Nicolle committed Nov 2, 2023
1 parent f54651c commit a327ac4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion client/src/components/ExportModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{{ $t("buttons.exportsvg") }}
</n-button>
<n-modal
v-if="grids && style && solutionsStyle && grids.length"
class="exportmodal"
v-model:show="visible"
preset="dialog"
Expand All @@ -14,7 +15,6 @@
<div class="modalbody">
<div class="exporter">
<SVGGrid
v-if="grids && style && grids.length"
:grid="grids[selectedIndex]"
dir="horizontal"
:export-options="exportOptions"
Expand Down
6 changes: 3 additions & 3 deletions client/src/components/svg-renderer/GridInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const props = defineProps<{
*/
zoom: number;
}>();
const { cellSize, textSize, textFont, defSize, defFont } = useSvgSizes(props);
const { cellSize, textSize, textFont, defSize, defSizePx, defFont } = useSvgSizes(props);
const transform = computed(() => useTransform(props, props.cell));
function onChange(evt: Event) {
const { x, y } = props.cell;
Expand Down Expand Up @@ -288,9 +288,9 @@ textarea:focus-visible {
color: #777;
}
.definition {
line-height: v-bind(defSize);
font-size: v-bind(defSize);
font: v-bind(defFont);
line-height: v-bind(defSizePx);
text-wrap: nowrap;
background: #aaa;
}
Expand Down
5 changes: 3 additions & 2 deletions client/src/components/svg-renderer/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ export function useSvgSizes(props: Props) {
const cellSizeC = computed(() => cellSize(props));
const textSize = computed(() => props.style.grid.cellSize * (props.zoom || 1));
const textFont = computed(() => `${textSize.value}px roboto`);
const defSize = computed(() => props.style.definition.size * (props.zoom || 1));
const defFont = computed(() => `${defSize.value}px ${props.style.definition.font}`);
const defSize = computed(() => props.style.grid.cellSize / 4 * props.style.definition.size * (props.zoom || 1));
const defFont = computed(() => `${defSize.value}px ${props.style.definition.family}`);

return {
cellSize: cellSizeC,
textSize,
textFont,
defSize,
defSizePx: `${Math.floor(defSize.value)}px`,
defFont,
};
}
Expand Down
5 changes: 4 additions & 1 deletion client/src/views/print/Book.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</template>

<script setup lang="ts">
import { ref, onMounted, onUnmounted } from "vue";
import { ref, onMounted, onUnmounted, watch } from "vue";
import { useRoute } from "vue-router";
import { Grid, GridStyle, SolutionStyle } from "grid";
import { ExportOptions } from "../../types";
Expand Down Expand Up @@ -56,6 +56,9 @@ function fetch() {
onMounted(() => {
fetch().then(() => usePrintMessage());
});
watch([route], () => {
fetch();
});
onUnmounted(() => {
cleanupPrintMessage();
});
Expand Down

0 comments on commit a327ac4

Please sign in to comment.