Skip to content

Build your personal knowledge base with Trilium Notes

feat(print/pdf): use segmented buttons instead of toggle

Elian Doran454c18ff0e6b
diff --git a/apps/client/src/stylesheets/theme-next/forms.css b/apps/client/src/stylesheets/theme-next/forms.css
index cbe5f2cda0..6efe42a9d7 100644
--- a/apps/client/src/stylesheets/theme-next/forms.css
+++ b/apps/client/src/stylesheets/theme-next/forms.css
@@ -21,6 +21,20 @@ button.ck.ck-button:is(.ck-button-action, .ck-button-save, .ck-button-cancel, .c
&.dropdown-toggle-split {
min-width: unset;
}
+
+ .btn-group > & {
+ border-radius: 0;
+ }
+
+ .btn-group > &:first-child {
+ border-start-start-radius: 6px;
+ border-end-start-radius: 6px;
+ }
+
+ .btn-group > &:last-child {
+ border-start-end-radius: 6px;
+ border-end-end-radius: 6px;
+ }
}
button.btn.btn-primary:hover,
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index 4cb0a287da..41e575e5be 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -2309,6 +2309,8 @@
"title": "Print preview",
"close": "Close",
"save": "Save as PDF",
+ "orientation": "Orientation",
+ "portrait": "Portrait",
"landscape": "Landscape"
},
"pdf": {
diff --git a/apps/client/src/widgets/dialogs/print_preview.tsx b/apps/client/src/widgets/dialogs/print_preview.tsx
index 58307c6ea2..43e2edc1f8 100644
--- a/apps/client/src/widgets/dialogs/print_preview.tsx
+++ b/apps/client/src/widgets/dialogs/print_preview.tsx
@@ -3,11 +3,11 @@ import { useCallback, useRef, useState } from "preact/hooks";
import { t } from "../../services/i18n";
import toast from "../../services/toast";
import { dynamicRequire, isElectron } from "../../services/utils";
-import Button from "../react/Button";
+import Button, { ButtonGroup } from "../react/Button";
import { useTriliumEvent } from "../react/hooks";
import Modal from "../react/Modal";
import PdfViewer from "../type_widgets/file/PdfViewer";
-import { OptionsRowWithToggle } from "../type_widgets/options/components/OptionsRow";
+import OptionsRow from "../type_widgets/options/components/OptionsRow";
import OptionsSection from "../type_widgets/options/components/OptionsSection";
export interface PrintPreviewData {
@@ -71,9 +71,10 @@ export default function PrintPreviewDialog() {
handleClose();
}
- function handleLandscapeToggle(newValue: boolean) {
- setLandscape(newValue);
- regeneratePreview(newValue);
+ function handleOrientationChange(newLandscape: boolean) {
+ if (newLandscape === landscape) return;
+ setLandscape(newLandscape);
+ regeneratePreview(newLandscape);
}
function regeneratePreview(newLandscape: boolean) {
@@ -114,13 +115,26 @@ export default function PrintPreviewDialog() {
>
<div style={{ padding: "16px", minWidth: "250px", overflowY: "auto" }}>
<OptionsSection>
- <OptionsRowWithToggle
- name="printLandscape"
- label={t("print_preview.landscape")}
- currentValue={landscape}
- onChange={handleLandscapeToggle}
- disabled={loading}
- />
+ <OptionsRow name="orientation" label={t("print_preview.orientation")}>
+ <ButtonGroup>
+ <Button
+ text={t("print_preview.portrait")}
+ icon="bx-rectangle bx-rotate-90"
+ className={!landscape ? "active" : ""}
+ onClick={() => handleOrientationChange(false)}
+ disabled={loading}
+ size="small"
+ />
+ <Button
+ text={t("print_preview.landscape")}
+ icon="bx-rectangle"
+ className={landscape ? "active" : ""}
+ onClick={() => handleOrientationChange(true)}
+ disabled={loading}
+ size="small"
+ />
+ </ButtonGroup>
+ </OptionsRow>
</OptionsSection>
</div>