client/options/keep content centered: simplify the inner workings

This commit is contained in:
Adorian Doran 2025-11-07 21:15:51 +02:00
parent c617c84d86
commit 9bccc72668
5 changed files with 17 additions and 16 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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;
}

View File

@ -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() {

View File

@ -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%;
}