Skip to content

Commit

Permalink
feat: resize elements according to --basic-font-size globally
Browse files Browse the repository at this point in the history
  • Loading branch information
Keldos-Li authored and RalXYZ committed Feb 16, 2023
1 parent b2b3e7c commit 1dc3042
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 31 deletions.
6 changes: 3 additions & 3 deletions src/scss/blockquote.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ blockquote {
font-family: var(--quote-font), var(--base-Latin-font), var(--base-Chinese-font), -apple-system, serif;
font-size: var(--quote-font-size);
/* 文字离左边框的距离 */
padding-left: 2rem;
padding-right: 2rem;
padding-left: 2em;
padding-right: 2em;
/* 左边框离页面边的距离 */
margin-left: 0rem;
margin-left: 0;
}

blockquote p:first-child {
Expand Down
7 changes: 4 additions & 3 deletions src/scss/footnote.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// 参考文献块
/* 参考文献(脚注)块 */
.footnotes {
font-size: 0.95em;
}
.footnotes-area {
.footnote-line {
// 把参考资料块的文字大小和文字颜色与正文统一
color: var(--text-color);
font-size: var(--base-font-size);
}

// 默认情况下,Typora 会给参考文献块顶部加一条横线,这里把它隐藏掉
Expand Down
10 changes: 5 additions & 5 deletions src/scss/heading.scss
Original file line number Diff line number Diff line change
Expand Up @@ -106,30 +106,30 @@ h6.md-focus.md-heading:before {
%h2-with-count {
counter-increment: h2;
content: counter(h2);
margin-right: 2rem;
margin-right: 1.2em;
}

%h3-with-count {
counter-increment: h3;
content: counter(h2) "." counter(h3);
margin-right: 2rem;
margin-right: 1.2em;
}

%h4-with-count {
counter-increment: h4;
content: counter(h2) "." counter(h3) "." counter(h4);
margin-right: 2rem;
margin-right: 1.2em;
}

%h5-with-count {
counter-increment: h5;
content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5);
margin-right: 2rem;
margin-right: 1.2em;
}

%h6-with-count {
counter-increment: h6;
content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) "."
counter(h6);
margin-right: 2rem;
margin-right: 1.2em;
}
21 changes: 12 additions & 9 deletions src/scss/settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@
/* 引言字体 */
--quote-font: "Latin Modern Roman", "Latin Modern Roman 10", Times,
"Times New Roman", "华文仿宋";
/* 这里字体用了10pt,比正文字体稍大 */
--quote-font-size: 10pt;
/* em单位为一个正文字符(--base-font-size)大小,
例如,如果您设置 --base-font-size 为 9.5pt,那么 1.05em = 1.05*9.5pt ≈ 10pt。下面的标题字体等设置也遵循该规则。
这样,您就可以仅通过调整基准字体大小,而动态对其他元素大小做出调整。
当然,您也可以直接设置以pt或px为单位的数值,将元素的大小固定下来,如 --quote-font-size: 10pt; */
--quote-font-size: 1.05em;

/* 代码字体(代码中的中文会调用 ui-font) */
--code-font: "Latin Modern Mono", "Latin Modern Mono 10", "Courier New";
Expand Down Expand Up @@ -74,29 +77,29 @@
/* 标题字体分别设置 */
/* 大标题(h1)字体 */
--title-Chinese-font: "#{$heading-Chinese-font}";
--title-font-size: 18pt;
--title-font-size: 1.9em;
/* h2字体 */
--h2-Chinese-font: "#{$chapter-Chinese-font}";
--h2-font-size: 14pt;
--h2-font-size: 1.5em;
/* h3字体 */
--h3-Chinese-font: "#{$chapter-Chinese-font}";
--h3-font-size: 12pt;
--h3-font-size: 1.25em;
/* h4字体 */
--h4-Chinese-font: "#{$sub-chapter-Chinese-font}";
--h4-font-size: 10pt;
--h4-font-size: 1.15em;
/* h5字体 */
--h5-Chinese-font: "#{$sub-sub-chapter-Chinese-font}";
--h5-font-size: 10pt;
--h5-font-size: 1.10em;
/* h6字体 */
--h6-Chinese-font: "#{$sub-sub-chapter-Chinese-font}";
--h6-font-size: 9.5pt;
--h6-font-size: 1.05em;

/* 粗体样式设置 */
/* 加粗风格时使用的字重;400等同于 normal,700等同于 bold,900等同于 heavy */
--strong-weight: 900;

/* 基础行距 */
--base-line-height: 16pt;
--base-line-height: 1.618em;

/* == 页面设置 == */
/* 打印页边距 */
Expand Down
9 changes: 8 additions & 1 deletion src/scss/text.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
body {
padding: 0 !important;
margin: 0 !important;
line-height: var(--base-line-height);
// line-height: var(--base-line-height);
/* counter-reset: tableHead 0 imgHead 0; */
@if $theme == "dark" {
color: #dddddd;
Expand Down Expand Up @@ -34,8 +34,15 @@ body {
display: inline-block; */
/* 这里可以试分栏的,但确实不适合实现 */

.md-math-block,
.md-rawblock,
p {
margin-top: 1em;
margin-bottom: 1em;
}
p {
text-align: left;
line-height: var(--base-line-height);
}

// 超链接
Expand Down
21 changes: 12 additions & 9 deletions src/scss/toc.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/* 目录 */
.md-toc {
font-size: var(--toc-font-size);
}
.md-toc-content {
margin-left: 2em;
/* 修复缺失上级标题时无法递增 */
Expand Down Expand Up @@ -56,33 +59,33 @@
.md-toc-h2:before {
counter-increment: toc-h2;
content: counter(toc-h2);
margin-right: 1rem;
margin-right: 1em;
font-weight: var(--strong-weight);
}
.md-toc-h3:before {
counter-increment: toc-h3;
content: counter(toc-h2) "." counter(toc-h3);
margin-left: 1.5rem;
margin-right: 0.5rem;
margin-left: 1.5em;
margin-right: 0.5em;
}
.md-toc-h4:before {
counter-increment: toc-h4;
content: counter(toc-h2) "." counter(toc-h3) "." counter(toc-h4);
margin-left: 3.5rem;
margin-right: 0.5rem;
margin-left: 3.5em;
margin-right: 0.5em;
}
.md-toc-h5:before {
counter-increment: toc-h5;
content: counter(toc-h2) "." counter(toc-h3) "." counter(toc-h4) "."
counter(toc-h5);
margin-left: 5.5rem;
margin-right: 0.5rem;
margin-left: 5.5em;
margin-right: 0.5em;
}
.md-toc-h6:before {
counter-increment: toc-h6;
content: counter(toc-h2) "." counter(toc-h3) "." counter(toc-h4) "."
counter(toc-h5) "." counter(toc-h6);
margin-left: 7.5rem;
margin-right: 0.5rem;
margin-left: 7.5em;
margin-right: 0.5em;
}
}
3 changes: 2 additions & 1 deletion src/scss/typora.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
}
font-family: var(--sourceMode-font), var(--code-font), var(--ui-font),
monospace;
line-height: 2rem;
line-height: 2em;
}

/* 侧边大纲标题 */
Expand Down Expand Up @@ -87,6 +87,7 @@ pre.md-meta-block {
}
padding: 1.4em;
font-family: var(--code-font), var(--ui-font), monospace;
font-size: 0.8em;
}

// override the default style for focused headings
Expand Down

0 comments on commit 1dc3042

Please sign in to comment.