Skip to content

Build your personal knowledge base with Trilium Notes

feat(fonts): preview the document font on a heading and a paragraph

Elian Doran8a3bc24f387c
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index 178b5bed5b..478fad7bb0 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -1844,7 +1844,9 @@
"monospace": "Monospace",
"system-default": "System default",
"search_placeholder": "Search fonts",
- "no_fonts_found": "No font matches what you are looking for."
+ "no_fonts_found": "No font matches what you are looking for.",
+ "document_preview_heading": "Purple heart cuttings",
+ "document_preview_body": "Snipped 4 stems below a node and stood them in water on the sill; the first roots showed after 9 days. It holds its colour in full sun and fades to green in the shade."
},
"max_content_width": {
"title": "Content Width",
diff --git a/apps/client/src/widgets/type_widgets/options/appearance_fonts.css b/apps/client/src/widgets/type_widgets/options/appearance_fonts.css
index 62b8b33541..9025181945 100644
--- a/apps/client/src/widgets/type_widgets/options/appearance_fonts.css
+++ b/apps/client/src/widgets/type_widgets/options/appearance_fonts.css
@@ -179,6 +179,19 @@ body.desktop .modal.font-picker-modal {
line-height: 1.6;
}
+/* Sized in em, so the heading keeps its proportion to the text under it as the slider moves. */
+.font-preview-document {
+ h3 {
+ font-size: 1.5em;
+ font-weight: 600;
+ margin: 0 0 0.4em;
+ }
+
+ p {
+ margin: 0;
+ }
+}
+
/* Rows at the density the note tree stacks them at, which is what the font has to hold up at.
Sized in em throughout, so the whole thing follows the size slider rather than only the titles. */
.font-preview-tree {
diff --git a/apps/client/src/widgets/type_widgets/options/appearance_fonts.tsx b/apps/client/src/widgets/type_widgets/options/appearance_fonts.tsx
index a6c8ac2b67..20955da9a7 100644
--- a/apps/client/src/widgets/type_widgets/options/appearance_fonts.tsx
+++ b/apps/client/src/widgets/type_widgets/options/appearance_fonts.tsx
@@ -114,7 +114,8 @@ const FONT_TARGETS: FontTarget[] = [
label: t("fonts.note_detail_font"),
shortLabel: t("fonts.note_detail_font_short"),
sizeDescription: t("fonts.size_relative_to_general"),
- themeVariable: "var(--detail-font-family)"
+ themeVariable: "var(--detail-font-family)",
+ Preview: DocumentPreview
},
{
key: "monospace",
@@ -448,6 +449,20 @@ function TreePreviewRow({ note, expanded, nested }: { note: FNote; expanded?: bo
);
}
+/**
+ * A heading over a paragraph, which is the shape the font is being chosen for. One line says
+ * nothing about how a reading font behaves at length: the spacing between the lines, and the weight
+ * a heading takes against the text under it.
+ */
+function DocumentPreview() {
+ return (
+ <div className="font-preview-document">
+ <h3>{t("fonts.document_preview_heading")}</h3>
+ <p>{t("fonts.document_preview_body")}</p>
+ </div>
+ );
+}
+
const PREVIEW_TEXT = "The quick brown fox jumps over the lazy dog. 0123456789";
interface FontPickerModalProps {