Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
style/task state checkboxes: improve caption alignment
Adorian Doran50418f13cf2f
diff --git a/apps/client/src/print.css b/apps/client/src/print.cssindex 34f65fa993..b340e0e101 100644--- a/apps/client/src/print.css+++ b/apps/client/src/print.css@@ -48,6 +48,7 @@ body[data-note-type="text"] .ck-content {color: #374a75;}+.ck-content .todo-list__label,.ck-content .todo-list__label * {-webkit-print-color-adjust: exact;print-color-adjust: exact;@@ -82,7 +83,7 @@ body[data-note-type="text"] .ck-content {--task-state-glyph-font-family: boxicons;}- .ck-content .todo-list__label__description {+ .ck-content .todo-list li {/* The percentage of the line height that the check box occupies */--box-ratio: 0.75;/* The size of the gap between the check box and the caption */@@ -91,9 +92,22 @@ body[data-note-type="text"] .ck-content {/* The percentage of the box size that the glyph occupies. */--glyph-ratio: .70;+ /* Registered as <length> above, so the `lh` unit is resolved to an+ absolute length here at the li; descendants and pseudo-elements+ inherit that frozen value, so changing the glyph's font-size on+ ::after no longer feeds back into the box dimensions. */--box-size: calc(1lh * var(--box-ratio));--box-vert-offset: calc((1lh - var(--box-size)) / 2);+ }++ /* The print document does not load the app stylesheet, so neutralise the UA+ paragraph margins for real-<p> item descriptions — the box is centred on+ the li's first line and the text must start there too. */+ .ck-content .todo-list li p {+ margin-block: 0;+ }+ .ck-content .todo-list__label__description {display: inline-block;padding-inline-start: calc(var(--box-size) + var(--box-text-gap));position: relative;@@ -109,14 +123,38 @@ body[data-note-type="text"] .ck-content {height: var(--box-size);}- .ck-content .todo-list__label__description::before {+ /* The `_without-description` variant has no description span — the item text is+ a sibling <p>. Turn the (otherwise empty) label itself into the box, anchored+ on the li's first line, and indent the paragraph(s) to make room for it. */+ .ck-content .todo-list__label.todo-list__label_without-description {+ position: absolute;+ left: 0;+ top: var(--box-vert-offset);+ width: var(--box-size);+ height: var(--box-size);+ }++ .ck-content .todo-list__label.todo-list__label_without-description::before,+ .ck-content .todo-list__label.todo-list__label_without-description::after {+ content: "";+ position: absolute;+ inset: 0;+ }++ .ck-content .todo-list li > .todo-list__label_without-description ~ p {+ padding-inline-start: calc(var(--box-size) + var(--box-text-gap));+ }++ .ck-content .todo-list__label__description::before,+ .ck-content .todo-list__label.todo-list__label_without-description::before {--_border-tickness: 1pt;outline: var(--_border-tickness) solid black;outline-offset: calc(0pt - var(--_border-tickness));border-radius: 2pt;}- .ck-content .todo-list__label__description::after {+ .ck-content .todo-list__label__description::after,+ .ck-content .todo-list__label.todo-list__label_without-description::after {content: var(--task-state-glyph);line-height: var(--box-size);text-align: center;diff --git a/apps/client/src/stylesheets/style.css b/apps/client/src/stylesheets/style.cssindex 0da8b0bbeb..16ea9790a6 100644--- a/apps/client/src/stylesheets/style.css+++ b/apps/client/src/stylesheets/style.css@@ -2995,8 +2995,37 @@ iframe.print-iframe {--_task-checkbox-background: var(--task-checkbox-done-color);}+/* The read-only view renders a real <label>, which Bootstrap's reboot makes+ inline-block — an empty label (its checkbox is absolutely positioned below)+ then produces a full-height line of its own, pushing the item text onto the+ next line. Restore the plain inline display so the empty label collapses. */+:root .ck-content.ck-content ul.todo-list li .todo-list__label {+ display: inline;+}+:root .ck-content.ck-content ul.todo-list li .todo-list__label input[type="checkbox"] {--_checkbox-size: var(--ck-content-todo-list-checkmark-size);++ /* Take the checkbox out of the inline flow in every variant and centre it+ geometrically on the first text line (the li is the positioned ancestor,+ `li p` has no margin, and CKEditor's own `left/right: -25px` still places+ it in the gutter). Centering via `vertical-align: middle` depends on font+ metrics and differs from the absolutely-positioned `_without-description`+ variant — this makes both variants share one deterministic geometry. */+ position: absolute;+ top: calc((1lh - var(--_checkbox-size)) / 2);+ /* `1lh` must resolve against the text's line height, not the UA form-control+ font, and the UA's 3px checkbox margins would offset the absolute position.+ (Bootstrap's reboot happens to do both, but don't depend on it.) */+ margin: 0;+ font: inherit;+}++/* CKEditor middle-aligns the inline description span, while a real-<p> description+ (the `_without-description` variant) sits on the plain baseline — so the text+ position depended on which variant rendered. Align both on the baseline. */+:root .ck-content.ck-content ul.todo-list li .todo-list__label .todo-list__label__description {+ vertical-align: baseline;}/* Checkbox */diff --git a/packages/share-theme/src/styles/task-states.css b/packages/share-theme/src/styles/task-states.cssindex a0adb45ee2..2baac147bb 100644--- a/packages/share-theme/src/styles/task-states.css+++ b/packages/share-theme/src/styles/task-states.css@@ -58,3 +58,26 @@ html.theme-dark [data-trilium-task-state] {color: var(--_task-state-color);transform: scale(0.8);}++/* One deterministic geometry for both rendering variants (inline description span vs+ the real-<p> `_without-description` one): the checkbox leaves the inline flow and is+ centred geometrically on the first text line, and the description always sits on the+ plain baseline instead of CKEditor's metric-dependent `vertical-align: middle`. */+.ck-content.ck-content .todo-list li .todo-list__label {+ /* An empty inline-block label would create a line of its own (see the client+ stylesheet); keep it collapsible. */+ display: inline;+}++.ck-content.ck-content .todo-list li .todo-list__label input[type="checkbox"] {+ position: absolute;+ top: calc((1lh - var(--ck-content-todo-list-checkmark-size)) / 2);+ /* `1lh` must resolve against the text's line height, not the UA form-control+ font, and the UA's 3px checkbox margins would offset the absolute position. */+ margin: 0;+ font: inherit;+}++.ck-content.ck-content .todo-list li .todo-list__label .todo-list__label__description {+ vertical-align: baseline;+}