Skip to content

Commit

Permalink
Adds correct calculations for pixel values
Browse files Browse the repository at this point in the history
  • Loading branch information
mgmeyers committed Apr 5, 2021
1 parent 048d633 commit 418e797
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 22 deletions.
31 changes: 20 additions & 11 deletions obsidian.css
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,8 @@ settings:

--rem: 18px;

--editor-font-size: 18px;
--editor-font-size: 18;
--editor-line-height: 1.88889;
--editor-line-height-rem: calc(var(--editor-line-height) * 1rem);
--editor-font-weight: 400;
--editor-font-features: "";

Expand All @@ -385,7 +384,7 @@ settings:
--font-smallest: 10px;
--normal-weight: 400;
--bold-weight: 600;
--line-width: 42rem;
--line-width: 42;
--line-height: 1.5;
--max-width: 100%;
--nested-padding: 3.5%;
Expand Down Expand Up @@ -560,6 +559,12 @@ settings:
--opacity-translucency: 1;
}

body {
--editor-font-size-px: calc(var(--editor-font-size) * 1px);
--editor-line-height-rem: calc(var(--editor-line-height) * 1rem);
--line-width-rem: calc(var(--line-width) * 1rem);
}

/*
------------------------------------------------------------------
*/
Expand Down Expand Up @@ -1362,14 +1367,14 @@ body.theme-dark:not(.is-translucent):not(.hider-frameless)

.markdown-preview-view.is-readable-line-width .markdown-preview-sizer {
max-width: var(--max-width);
width: var(--line-width);
width: var(--line-width-rem);
}
.markdown-source-view.is-readable-line-width .CodeMirror,
.is-readable-line-width .markdown-preview-section {
padding-left: 0;
padding-right: 0;
margin: 0 auto 0 auto;
width: var(--line-width);
width: var(--line-width-rem);
max-width: var(--max-width);
}
.markdown-preview-sizer {
Expand All @@ -1382,7 +1387,7 @@ body.theme-dark:not(.is-translucent):not(.hider-frameless)

.is-readable-line-width .markdown-preview-section > div {
margin: 0 auto 0 auto;
width: var(--line-width);
width: var(--line-width-rem);
max-width: var(--max-width);
}

Expand Down Expand Up @@ -2764,7 +2769,7 @@ input[type="range"]::-webkit-slider-thumb:active {
.mod-root .local-graph-jumps-slider-container {
right: 0;
left: 0;
width: var(--line-width);
width: var(--line-width-rem);
max-width: var(--max-width);
margin: 0 auto;
top: 30px;
Expand Down Expand Up @@ -3140,7 +3145,7 @@ html .plugin-sliding-panes-rotate-header.embedded-note-title .CodeMirror-lines {
font-size: 16px;
}
.mod-root #calendar-container {
width: var(--line-width);
width: var(--line-width-rem);
max-width: var(--max-width);
margin: 0 auto;
padding: 0;
Expand Down Expand Up @@ -4743,7 +4748,7 @@ a[href*="obsidian://search"]:after
}
.cm-s-obsidian {
font-family: var(--text-editor);
font-size: var(--editor-font-size);
font-size: var(--editor-font-size-px);
font-weight: var(--editor-font-weight);
line-height: var(--editor-line-height);
font-feature-settings: var(--editor-font-features);
Expand Down Expand Up @@ -4944,9 +4949,13 @@ body {
--preview-font-features: var(--editor-font-features);
}

body {
--preview-font-size-px: calc(var(--preview-font-size) * 1px);
}

.markdown-preview-view {
font-family: var(--text-preview);
font-size: var(--preview-font-size);
font-size: var(--preview-font-size-px);
font-weight: var(--preview-font-weight);
line-height: var(--preview-line-height);
font-feature-settings: var(--preview-font-features);
Expand Down Expand Up @@ -5524,7 +5533,7 @@ html .embedded-note-titles .CodeMirror-lines {
.is-readable-line-width.markdown-preview-view
> h1 {
margin: 0 auto;
width: var(--line-width) !important;
width: var(--line-width-rem) !important;
max-width: var(--max-width) !important;
}

Expand Down
19 changes: 12 additions & 7 deletions src/010-main.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@

--rem: 18px;

--editor-font-size: 18px;
--editor-font-size: 18;
--editor-line-height: 1.88889;
--editor-line-height-rem: calc(var(--editor-line-height) * 1rem);
--editor-font-weight: 400;
--editor-font-features: "";

Expand All @@ -29,7 +28,7 @@
--font-smallest: 10px;
--normal-weight: 400;
--bold-weight: 600;
--line-width: 42rem;
--line-width: 42;
--line-height: 1.5;
--max-width: 100%;
--nested-padding: 3.5%;
Expand Down Expand Up @@ -204,6 +203,12 @@
--opacity-translucency: 1;
}

body {
--editor-font-size-px: calc(var(--editor-font-size) * 1px);
--editor-line-height-rem: calc(var(--editor-line-height) * 1rem);
--line-width-rem: calc(var(--line-width) * 1rem);
}

/*
------------------------------------------------------------------
*/
Expand Down Expand Up @@ -1006,14 +1011,14 @@ body.theme-dark:not(.is-translucent):not(.hider-frameless)

.markdown-preview-view.is-readable-line-width .markdown-preview-sizer {
max-width: var(--max-width);
width: var(--line-width);
width: var(--line-width-rem);
}
.markdown-source-view.is-readable-line-width .CodeMirror,
.is-readable-line-width .markdown-preview-section {
padding-left: 0;
padding-right: 0;
margin: 0 auto 0 auto;
width: var(--line-width);
width: var(--line-width-rem);
max-width: var(--max-width);
}
.markdown-preview-sizer {
Expand All @@ -1026,7 +1031,7 @@ body.theme-dark:not(.is-translucent):not(.hider-frameless)

.is-readable-line-width .markdown-preview-section > div {
margin: 0 auto 0 auto;
width: var(--line-width);
width: var(--line-width-rem);
max-width: var(--max-width);
}

Expand Down Expand Up @@ -2408,7 +2413,7 @@ input[type="range"]::-webkit-slider-thumb:active {
.mod-root .local-graph-jumps-slider-container {
right: 0;
left: 0;
width: var(--line-width);
width: var(--line-width-rem);
max-width: var(--max-width);
margin: 0 auto;
top: 30px;
Expand Down
2 changes: 1 addition & 1 deletion src/012-calendar.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
font-size: 16px;
}
.mod-root #calendar-container {
width: var(--line-width);
width: var(--line-width-rem);
max-width: var(--max-width);
margin: 0 auto;
padding: 0;
Expand Down
2 changes: 1 addition & 1 deletion src/050-editor.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.cm-s-obsidian {
font-family: var(--text-editor);
font-size: var(--editor-font-size);
font-size: var(--editor-font-size-px);
font-weight: var(--editor-font-weight);
line-height: var(--editor-line-height);
font-feature-settings: var(--editor-font-features);
Expand Down
6 changes: 5 additions & 1 deletion src/060-preview.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ body {
--preview-font-features: var(--editor-font-features);
}

body {
--preview-font-size-px: calc(var(--preview-font-size) * 1px);
}

.markdown-preview-view {
font-family: var(--text-preview);
font-size: var(--preview-font-size);
font-size: var(--preview-font-size-px);
font-weight: var(--preview-font-weight);
line-height: var(--preview-line-height);
font-feature-settings: var(--preview-font-features);
Expand Down
2 changes: 1 addition & 1 deletion src/070-headers.css
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ html .embedded-note-titles .CodeMirror-lines {
.is-readable-line-width.markdown-preview-view
> h1 {
margin: 0 auto;
width: var(--line-width) !important;
width: var(--line-width-rem) !important;
max-width: var(--max-width) !important;
}

Expand Down

0 comments on commit 418e797

Please sign in to comment.