Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

Tidy booklet imposition UI and add guide diagrams (#8454)

ConnorYohf0dce6ebe56f
diff --git a/frontend/editor/src/core/assets/booklet/assembly.svg b/frontend/editor/src/core/assets/booklet/assembly.svg
new file mode 100644
index 0000000000..8f493a6404
--- /dev/null
+++ b/frontend/editor/src/core/assets/booklet/assembly.svg
@@ -0,0 +1,10 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 280 88" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
+ <rect x="10" y="26" width="56" height="38" rx="2"/>
+ <path d="M15 21h54a2 2 0 0 1 2 2v36M20 16h54a2 2 0 0 1 2 2v36M38 30v30" stroke-dasharray="3 4"/>
+ <path d="M86 44h17m-5-5 5 5-5 5"/>
+ <path d="m144 28-24-10v43l24 10 28-10V18l-28 10v43"/>
+ <path d="M126 10c9-6 24-6 33 0m-1-6 1 6-6 1"/>
+ <path d="M183 44h17m-5-5 5 5-5 5"/>
+ <rect x="219" y="16" width="38" height="54" rx="3"/>
+ <path d="M224 16v54M216 29h8v7h-8m0 15h8v7h-8M229 75h31a2 2 0 0 0 2-2V21M233 30h15m-15 7h15m-15 7h9"/>
+</svg>
diff --git a/frontend/editor/src/core/assets/booklet/page-order.svg b/frontend/editor/src/core/assets/booklet/page-order.svg
new file mode 100644
index 0000000000..231a2ffb36
--- /dev/null
+++ b/frontend/editor/src/core/assets/booklet/page-order.svg
@@ -0,0 +1,22 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 280 124" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
+ <rect x="16" y="10" width="96" height="44" rx="3"/>
+ <path d="M64 14v36" stroke-dasharray="3 4"/>
+ <rect x="168" y="10" width="96" height="44" rx="3"/>
+ <path d="M216 14v36" stroke-dasharray="3 4"/>
+ <path d="M128 32h24m-5-5 5 5-5 5"/>
+ <rect x="16" y="70" width="96" height="44" rx="3"/>
+ <path d="M64 74v36" stroke-dasharray="3 4"/>
+ <rect x="168" y="70" width="96" height="44" rx="3"/>
+ <path d="M216 74v36" stroke-dasharray="3 4"/>
+ <path d="M128 92h24m-5-5 5 5-5 5"/>
+ <g fill="currentColor" stroke="none" font-family="sans-serif" font-size="16" text-anchor="middle">
+ <text x="40" y="38">8</text>
+ <text x="88" y="38">1</text>
+ <text x="192" y="38">2</text>
+ <text x="240" y="38">7</text>
+ <text x="40" y="98">6</text>
+ <text x="88" y="98">3</text>
+ <text x="192" y="98">4</text>
+ <text x="240" y="98">5</text>
+ </g>
+</svg>
diff --git a/frontend/editor/src/core/components/tools/bookletImposition/BookletGuideDiagram.tsx b/frontend/editor/src/core/components/tools/bookletImposition/BookletGuideDiagram.tsx
new file mode 100644
index 0000000000..ee906fa092
--- /dev/null
+++ b/frontend/editor/src/core/components/tools/bookletImposition/BookletGuideDiagram.tsx
@@ -0,0 +1,26 @@
+import pageOrder from "@app/assets/booklet/page-order.svg";
+import assembly from "@app/assets/booklet/assembly.svg";
+
+const diagrams = {
+ pageOrder: { source: pageOrder, ratio: "280 / 124" },
+ assembly: { source: assembly, ratio: "280 / 88" },
+};
+
+/** Decorative line art; the adjacent guide text provides the instructions. */
+export function BookletGuideDiagram({ name }: { name: keyof typeof diagrams }) {
+ const { source, ratio } = diagrams[name];
+
+ return (
+ <div
+ aria-hidden="true"
+ style={{
+ width: "100%",
+ maxWidth: "280px",
+ aspectRatio: ratio,
+ marginInline: "auto",
+ backgroundColor: "var(--c-text-muted)",
+ mask: `url("${source}") center / contain no-repeat`,
+ }}
+ />
+ );
+}
diff --git a/frontend/editor/src/core/components/tools/bookletImposition/BookletImpositionSettings.tsx b/frontend/editor/src/core/components/tools/bookletImposition/BookletImpositionSettings.tsx
index ed0f96bb2e..14206d0dbf 100644
--- a/frontend/editor/src/core/components/tools/bookletImposition/BookletImpositionSettings.tsx
+++ b/frontend/editor/src/core/components/tools/bookletImposition/BookletImpositionSettings.tsx
@@ -4,11 +4,12 @@ import {
Stack,
Text,
Divider,
- Collapse,
+ Group,
NumberInput,
Checkbox,
} from "@mantine/core";
-import { Button } from "@app/ui/Button";
+import { Collapsible } from "@app/ui/Collapsible";
+import { InfoTooltip } from "@app/ui/InfoTooltip";
import { BookletImpositionParameters } from "@app/hooks/tools/bookletImposition/useBookletImpositionParameters";
import ButtonSelector from "@app/components/shared/ButtonSelector";
@@ -31,103 +32,89 @@ const BookletImpositionSettings = ({
return (
<Stack gap="md">
- <Divider ml="-md"></Divider>
+ <Divider ml="-md" />
- {/* Double Sided */}
- <Stack gap="sm">
+ <Group gap="xs" wrap="nowrap">
<Checkbox
checked={parameters.doubleSided}
onChange={(event) => {
const isDoubleSided = event.currentTarget.checked;
onParameterChange("doubleSided", isDoubleSided);
- // Reset to BOTH when turning double-sided back on
- if (isDoubleSided) {
- onParameterChange("duplexPass", "BOTH");
- } else {
- // Default to FIRST pass when going to manual duplex
- onParameterChange("duplexPass", "FIRST");
- }
+ onParameterChange("duplexPass", isDoubleSided ? "BOTH" : "FIRST");
}}
disabled={disabled}
- label={
- <div>
- <Text size="sm">
- {t(
- "bookletImposition.doubleSided.label",
- "Double-sided printing",
- )}
- </Text>
- <Text size="xs" c="dimmed">
- {t(
- "bookletImposition.doubleSided.tooltip",
- "Creates both front and back sides for proper booklet printing",
- )}
- </Text>
- </div>
- }
+ label={t(
+ "bookletImposition.doubleSided.label",
+ "Double-sided printing",
+ )}
+ />
+ <InfoTooltip
+ label={t(
+ "bookletImposition.doubleSided.tooltip",
+ "Creates both front and back sides for proper booklet printing",
+ )}
/>
+ </Group>
- {/* Manual Duplex Pass Selection - only show when double-sided is OFF */}
- {!parameters.doubleSided && (
- <Stack gap="xs" ml="lg">
- <Text size="sm" fw={500} c="var(--color-amber-dark)">
+ {!parameters.doubleSided && (
+ <Stack gap="sm" ml="lg">
+ <Group gap="xs" wrap="nowrap">
+ <Text size="sm" fw={500}>
{t("bookletImposition.manualDuplex.title", "Manual Duplex Mode")}
</Text>
- <Text size="xs" c="dimmed">
- {t(
+ <InfoTooltip
+ label={t(
"bookletImposition.manualDuplex.instructions",
"For printers without automatic duplex. You'll need to run this twice:",
)}
- </Text>
-
- <ButtonSelector
- label={t("bookletImposition.duplexPass.label", "Print Pass")}
- value={parameters.duplexPass}
- onChange={(value) => onParameterChange("duplexPass", value)}
- options={[
- {
- value: "FIRST",
- label: t("bookletImposition.duplexPass.first", "1st Pass"),
- },
- {
- value: "SECOND",
- label: t("bookletImposition.duplexPass.second", "2nd Pass"),
- },
- ]}
- disabled={disabled}
/>
+ </Group>
- <Text size="xs" c="var(--c-accent-text)" fs="italic">
- {parameters.duplexPass === "FIRST"
- ? t(
- "bookletImposition.duplexPass.firstInstructions",
- "Prints front sides → stack face-down → run again with 2nd Pass",
- )
- : t(
- "bookletImposition.duplexPass.secondInstructions",
- "Load printed stack face-down → prints back sides",
- )}
+ <Group gap="xs" wrap="nowrap">
+ <Text size="sm" fw={500}>
+ {t("bookletImposition.duplexPass.label", "Print Pass")}
</Text>
- </Stack>
- )}
- </Stack>
+ <InfoTooltip
+ label={
+ parameters.duplexPass === "FIRST"
+ ? t(
+ "bookletImposition.duplexPass.firstInstructions",
+ "Prints front sides → stack face-down → run again with 2nd Pass",
+ )
+ : t(
+ "bookletImposition.duplexPass.secondInstructions",
+ "Load printed stack face-down → prints back sides",
+ )
+ }
+ />
+ </Group>
+ <ButtonSelector
+ value={parameters.duplexPass}
+ onChange={(value) => onParameterChange("duplexPass", value)}
+ options={[
+ {
+ value: "FIRST",
+ label: t("bookletImposition.duplexPass.first", "First Pass"),
+ },
+ {
+ value: "SECOND",
+ label: t("bookletImposition.duplexPass.second", "Second Pass"),
+ },
+ ]}
+ disabled={disabled}
+ />
+ </Stack>
+ )}
<Divider />
- {/* Advanced Options */}
- <Stack gap="sm">
- <Button
- variant="tertiary"
- onClick={() => setAdvancedOpen(!advancedOpen)}
- disabled={disabled}
- >
- {t("bookletImposition.advanced.toggle", "Advanced Options")}{" "}
- {advancedOpen ? "▲" : "▼"}
- </Button>
-
- <Collapse in={advancedOpen}>
- <Stack gap="md" mt="md">
- {/* Right-to-Left Binding */}
+ <Collapsible
+ open={advancedOpen}
+ onToggle={() => setAdvancedOpen((open) => !open)}
+ header={t("bookletImposition.advanced.toggle", "Advanced Options")}
+ >
+ <Stack gap="md" inert={!advancedOpen}>
+ <Group gap="xs" wrap="nowrap">
<Checkbox
checked={parameters.spineLocation === "RIGHT"}
onChange={(event) =>
@@ -137,98 +124,83 @@ const BookletImpositionSettings = ({
)
}
disabled={disabled}
- label={
- <div>
- <Text size="sm">
- {t(
- "bookletImposition.rtlBinding.label",
- "Right-to-left binding",
- )}
- </Text>
- <Text size="xs" c="dimmed">
- {t(
- "bookletImposition.rtlBinding.tooltip",
- "For Arabic, Hebrew, or other right-to-left languages",
- )}
- </Text>
- </div>
- }
+ label={t(
+ "bookletImposition.rtlBinding.label",
+ "Right-to-left binding",
+ )}
/>
+ <InfoTooltip
+ label={t(
+ "bookletImposition.rtlBinding.tooltip",
+ "For Arabic, Hebrew, or other right-to-left languages",
+ )}
+ />
+ </Group>
- {/* Add Border Option */}
+ <Group gap="xs" wrap="nowrap">
<Checkbox
checked={parameters.addBorder}
onChange={(event) =>
onParameterChange("addBorder", event.currentTarget.checked)
}
disabled={disabled}
- label={
- <div>
- <Text size="sm">
- {t(
- "bookletImposition.addBorder.label",
- "Add borders around pages",
- )}
- </Text>
- <Text size="xs" c="dimmed">
- {t(
- "bookletImposition.addBorder.tooltip",
- "Adds borders around each page section to help with cutting and alignment",
- )}
- </Text>
- </div>
- }
+ label={t(
+ "bookletImposition.addBorder.label",
+ "Add borders around pages",
+ )}
/>
+ <InfoTooltip
+ label={t(
+ "bookletImposition.addBorder.tooltip",
+ "Adds borders around each page section to help with cutting and alignment",
+ )}
+ />
+ </Group>
- {/* Gutter Margin */}
- <Stack gap="xs">
+ <Stack gap="xs">
+ <Group gap="xs" wrap="nowrap">
<Checkbox
checked={parameters.addGutter}
onChange={(event) =>
onParameterChange("addGutter", event.currentTarget.checked)
}
disabled={disabled}
- label={
- <div>
- <Text size="sm">
- {t(
- "bookletImposition.addGutter.label",
- "Add gutter margin",
- )}
- </Text>
- <Text size="xs" c="dimmed">
- {t(
- "bookletImposition.addGutter.tooltip",
- "Adds inner margin space for binding",
- )}
- </Text>
- </div>
- }
+ label={t(
+ "bookletImposition.addGutter.label",
+ "Add gutter margin",
+ )}
+ />
+ <InfoTooltip
+ label={t(
+ "bookletImposition.addGutter.tooltip",
+ "Adds inner margin space for binding",
+ )}
/>
+ </Group>
- {parameters.addGutter && (
- <NumberInput
- label={t(
- "bookletImposition.gutterSize.label",
- "Gutter size (points)",
- )}
- value={parameters.gutterSize}
- onChange={(value) =>
- onParameterChange(
- "gutterSize",
- typeof value === "number" ? value : 12,
- )
- }
- min={6}
- max={72}
- step={6}
- disabled={disabled}
- size="sm"
- />
- )}
- </Stack>
+ {parameters.addGutter && (
+ <NumberInput
+ label={t(
+ "bookletImposition.gutterSize.label",
+ "Gutter size (points)",
+ )}
+ value={parameters.gutterSize}
+ onChange={(value) =>
+ onParameterChange(
+ "gutterSize",
+ typeof value === "number" ? value : 12,
+ )
+ }
+ min={6}
+ max={72}
+ step={6}
+ disabled={disabled}
+ size="sm"
+ />
+ )}
+ </Stack>
- {/* Flip on Short Edge */}
+ <Group gap="xs" wrap="nowrap">
<Checkbox
checked={parameters.flipOnShortEdge}
onChange={(event) =>
@@ -238,42 +210,27 @@ const BookletImpositionSettings = ({
)
}
disabled={disabled || !parameters.doubleSided}
+ label={t(
+ "bookletImposition.flipOnShortEdge.label",
+ "Flip on short edge",
+ )}
+ />
+ <InfoTooltip
label={
- <div>
- <Text
- size="sm"
- c={!parameters.doubleSided ? "dimmed" : undefined}
- >
- {t(
- "bookletImposition.flipOnShortEdge.label",
- "Flip on short edge",
- )}
- </Text>
- <Text size="xs" c="dimmed">
- {!parameters.doubleSided
- ? t(
- "bookletImposition.flipOnShortEdge.manualNote",
- "Not needed in manual mode - you flip the stack yourself",
- )
- : t(
- "bookletImposition.flipOnShortEdge.tooltip",
- "Enable for short-edge duplex printing (automatic duplex only - ignored in manual mode)",
- )}
- </Text>
- </div>
+ !parameters.doubleSided
+ ? t(
+ "bookletImposition.flipOnShortEdge.manualNote",
+ "Not needed in manual mode - you flip the stack yourself",
+ )
+ : t(
+ "bookletImposition.flipOnShortEdge.tooltip",
+ "Enable for short-edge duplex printing (automatic duplex only - ignored in manual mode)",
+ )
}
/>
-
- {/* Paper Size Note */}
- <Text size="xs" c="dimmed" fs="italic">
- {t(
- "bookletImposition.paperSizeNote",
- "Paper size is automatically derived from your first page.",
- )}
- </Text>
- </Stack>
- </Collapse>
- </Stack>
+ </Group>
+ </Stack>
+ </Collapsible>
</Stack>
);
};
diff --git a/frontend/editor/src/core/components/tooltips/useBookletImpositionTips.ts b/frontend/editor/src/core/components/tooltips/useBookletImpositionTips.tsx
similarity index 90%
rename from frontend/editor/src/core/components/tooltips/useBookletImpositionTips.ts
rename to frontend/editor/src/core/components/tooltips/useBookletImpositionTips.tsx
index af885e6ba2..8e92aa5483 100644
--- a/frontend/editor/src/core/components/tooltips/useBookletImpositionTips.ts
+++ b/frontend/editor/src/core/components/tooltips/useBookletImpositionTips.tsx
@@ -1,6 +1,8 @@
import { useTranslation } from "react-i18next";
import { TooltipContent } from "@app/types/tips";
+import { BookletGuideDiagram } from "@app/components/tools/bookletImposition/BookletGuideDiagram";
+/** Booklet printing guidance, with diagrams supplementing the translated steps. */
export const useBookletImpositionTips = (): TooltipContent => {
const { t } = useTranslation();
@@ -21,6 +23,12 @@ export const useBookletImpositionTips = (): TooltipContent => {
"bookletImposition.tooltip.description.text",
"Creates professional booklets by arranging pages in the correct printing order. Your PDF pages are placed 2-up on landscape sheets so when folded and bound, they read in proper sequence like a real book.",
),
+ bullets: [
+ t(
+ "bookletImposition.paperSizeNote",
+ "Paper size is automatically derived from your first page.",
+ ),
+ ],
},
{
title: t(
@@ -45,6 +53,7 @@ export const useBookletImpositionTips = (): TooltipContent => {
"When folded & stacked: Reads 1→2→3→4→5→6→7→8",
),
],
+ body: <BookletGuideDiagram name="pageOrder" />,
},
{
title: t(
@@ -73,6 +82,7 @@ export const useBookletImpositionTips = (): TooltipContent => {
"For short-edge printers: Enable 'Flip on short edge' option",
),
],
+ body: <BookletGuideDiagram name="assembly" />,
},
{
title: t(