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
client/options/keep content centered: simplify the inner workings
Adorian Doran9bccc72668c9
diff --git a/apps/client/src/stylesheets/style.css b/apps/client/src/stylesheets/style.cssindex 02d3729ea5..399630fd60 100644--- a/apps/client/src/stylesheets/style.css+++ b/apps/client/src/stylesheets/style.css@@ -1811,8 +1811,6 @@ body:not(.mobile) #launcher-pane.horizontal .dropdown-submenu > .dropdown-menu {.note-split {/* Limits the maximum width of the note */--max-content-width: var(--preferred-max-content-width);- /* Indicates the inline margin of the content. If set to "auto" the content will be centered. */- --content-margin-inline: var(--preferred-content-margin-inline);margin-inline-start: auto;margin-inline-end: auto;diff --git a/apps/client/src/stylesheets/theme-next/pages.css b/apps/client/src/stylesheets/theme-next/pages.cssindex 4c33f727b5..85c120bf38 100644--- a/apps/client/src/stylesheets/theme-next/pages.css+++ b/apps/client/src/stylesheets/theme-next/pages.css@@ -174,7 +174,6 @@ div.note-detail-empty {.options-section:not(.tn-no-card) {margin-bottom: calc(var(--options-title-offset) + 26px) !important;- margin-inline: var(--content-margin-inline);box-shadow: var(--card-box-shadow);border: 1px solid var(--card-border-color) !important;border-radius: 8px;@@ -182,6 +181,10 @@ div.note-detail-empty {padding: var(--options-card-padding);}+body.prefers-centered-content .options-section:not(.tn-no-card) {+ margin-inline: auto;+}+body.desktop .options-section:not(.tn-no-card) {min-width: var(--options-card-min-width);max-width: var(--options-card-max-width);diff --git a/apps/client/src/widgets/collections/NoteList.css b/apps/client/src/widgets/collections/NoteList.cssindex ee2410ed18..4faffc14ff 100644--- a/apps/client/src/widgets/collections/NoteList.css+++ b/apps/client/src/widgets/collections/NoteList.css@@ -1,15 +1,16 @@.note-list-widget {min-height: 0;- /* Inherited from .note-split */- max-width: var(--max-content-width);- /* Inherited from .note-split. If set to "auto" the list widget will be centered horizontally. */- margin-inline: var(--content-margin-inline);--+ max-width: var(--max-content-width); /* Inherited from .note-split */+overflow: auto;contain: none !important;}+body.prefers-centered-content .note-list-widget {+ /* Horizontally center the widget in its parent when the "Keep content centered" option is on /*+ margin-inline: auto;+}+.note-list-widget .note-list {padding: 10px;}diff --git a/apps/client/src/widgets/containers/root_container.ts b/apps/client/src/widgets/containers/root_container.tsindex dd0ba384ee..d2622e6e2f 100644--- a/apps/client/src/widgets/containers/root_container.ts+++ b/apps/client/src/widgets/containers/root_container.ts@@ -69,13 +69,9 @@ export default class RootContainer extends FlexContainer<BasicWidget> {#setMaxContentWidth() {const width = Math.max(options.getInt("maxContentWidth") || 0, 640);- const centerContent = options.is("centerContent");-document.body.style.setProperty("--preferred-max-content-width", `${width}px`);- // To center the content, "--preferred-content-margin-inline" should be set to "auto".- document.body.style.setProperty("--preferred-content-margin-inline",- (centerContent) ? "auto" : "unset");+ document.body.classList.toggle("prefers-centered-content", options.is("centerContent"));}#setMotion() {diff --git a/apps/client/src/widgets/note_detail.ts b/apps/client/src/widgets/note_detail.tsindex 315260ca78..3fe13af0f8 100644--- a/apps/client/src/widgets/note_detail.ts+++ b/apps/client/src/widgets/note_detail.ts@@ -40,12 +40,15 @@ const TPL = /*html*/`<style>.note-detail {max-width: var(--max-content-width); /* Inherited from .note-split */- /* Inherited from .note-split. If set to "auto" the note detail widget will be centered horizontally. */- margin-inline: var(--content-margin-inline);font-family: var(--detail-font-family);font-size: var(--detail-font-size);}+ body.prefers-centered-content .note-detail {+ /* Horizontally center the widget in its parent when the "Keep content centered" option is on /*+ margin-inline: auto;+ }+.note-detail.full-height {height: 100%;}