feat: support auto dark mode

feat: support auto dark mode
feat: update site component
docs: update README
This commit is contained in:
Sivan 2020-05-04 23:36:08 +08:00 committed by GitHub
commit 133572c8d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 898 additions and 360 deletions

View file

@ -13,6 +13,7 @@
- 预置多种排版样式(行间注、多栏、竖排等); - 预置多种排版样式(行间注、多栏、竖排等);
- 多种预设字体族(仅限桌面端); - 多种预设字体族(仅限桌面端);
- 简/繁体中文支持; - 简/繁体中文支持;
- 自适应黑暗模式;
- 中西文混排美化,不再手敲空格👏(基于 JavaScript 脚本); - 中西文混排美化,不再手敲空格👏(基于 JavaScript 脚本);
- 兼容 *normalize.css*、*CSS Reset* 等常见样式重置; - 兼容 *normalize.css*、*CSS Reset* 等常见样式重置;
- 移动端支持; - 移动端支持;
@ -46,7 +47,7 @@
## WIP ## WIP
- [ ] 自适应黑暗模式 - [x] 自适应黑暗模式
- [x] 标点挤压 - [x] 标点挤压
- [x] 中、西文混排 - [x] 中、西文混排
- [x] 繁体中文支持 - [x] 繁体中文支持

View file

@ -1,322 +0,0 @@
/**
* Author: Sivan [sun.sivan@gmail.com]
*/
/** 测试用代码段 开始 **/
/* 简单模拟 css reset */
* {
margin: 0;
padding: 0;
}
ul,
ol {
list-style: none;
}
/* 模拟不知道哪里流传出来的垃圾代码 */
ul,
li {
list-style: none;
}
/** 测试用代码段 结束 **/
/** 基础样式 **/
body {
background-color: #fff;
}
a {
color: #4285f4;
text-decoration: none;
}
.container {
box-sizing: border-box;
padding-block-start: 12px;
padding-block-end: 72px;
padding-inline-start: 12px;
padding-inline-end: 12px;
}
/** 首页样式 **/
.article {
margin-inline-start: auto;
margin-inline-end: auto;
outline: 1px solid transparent;
}
.article[data-bg-grid="grid-24"] {
background-size: 100% 24px;
background-image:
linear-gradient(to right, rgba(255, 255, 255, 0) 31px, #eee 1px, rgba(255, 255, 255, 0) 33px),
linear-gradient(rgba(255, 255, 255, 0) 23px, #eee 1px);
outline-color: #eee;
}
.article[data-bg-grid="grid-24"] .heti--vertical {
background-size: 24px 100%;
background-image: linear-gradient(to left, rgba(255, 255, 255, 0) 23px, #eee 1px);
outline: 1px solid #eee;
}
.article[data-bg-grid="grid-12"] {
background-size: 100% 12px;
background-image:
linear-gradient(to right, rgba(255, 255, 255, 0) 31px, #eee 1px, rgba(255, 255, 255, 0) 33px),
linear-gradient(rgba(255, 255, 255, 0) 11px, #eee 12px);
outline-color: #eee;
}
.article[data-bg-grid="grid-12"] .heti--vertical {
background-size: 12px 100%;
background-image: linear-gradient(to left, transparent 11px, #eee 1px);
outline: 1px solid #eee;
}
.anchor {
margin-inline-start: 0.25em;
}
/** 导航样式 **/
.article .article__toc ol {
margin-block-start: 24px;
margin-block-end: 24px;
}
/** 控制栏样式 **/
.panel {
position: fixed;
z-index: 2;
right: 12px;
top: 12px;
display: flex;
text-align: right;
}
.switch-list {
display: inline-flex;
margin: 0;
padding: 0;
margin-inline-start: 12px;
list-style-type: none;
}
.switch-list li {
margin-inline-end: -1px;
}
.switch-list input {
display: none;
}
.switch-list label {
position: relative;
display: block;
box-sizing: border-box;
height: 24px;
padding: 0;
padding-inline-start: 10px;
padding-inline-end: 10px;
border: 1px solid #c2c2c2;
border-block-start-color: #c9c9c9;
border-block-end-color: #a6a6a6;
font-size: 14px;
line-height: 22px;
text-align: center;
background-color: #fff;
color: #000;
user-select: none;
}
.switch-list label:active {
background-color: #f0f0f0;
}
.switch-list li:first-child label {
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
.switch-list li:last-child label {
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
.switch-list input:checked + label {
z-index: 1;
border-color: #98989e;
border-block-start-color: #a5a5ab;
border-block-end-color: #7e7e84;
background-image: linear-gradient(to bottom, #b1b1b6, #929297);
color: rgba(255, 255, 255, 1);
}
.switch-list input:checked + label:active {
border-color: #65656b;
border-block-start-color: #808086;
border-block-end-color: #414147;
background-image: linear-gradient(to bottom, #919196, #57575c);
color: rgba(255, 255, 255, 0.95);
}
/** 演示卡片 **/
.card {
position: relative;
left: -12px;
width: 100%;
margin-block-start: 24px;
margin-block-end: 48px;
padding-block-start: 12px;
padding-block-end: 12px;
padding-inline-start: 12px;
padding-inline-end: 12px;
border-radius: 2px;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
background-color: #fff;
}
.article .card {
text-align: left;
}
.article .card > figcaption {
display: inline-block;
margin-block-start: 16px;
padding-block-start: 4px;
padding-block-end: 3px;
padding-inline-start: 0;
padding-inline-end: 72px;
line-height: 24px;
border-block-start: 1px solid #eee;
}
.card__vertical-container {
box-sizing: border-box;
width: 100%;
height: 30em;
border: 1px solid #eee;
overflow: auto;
writing-mode: vertical-rl;
}
/** 演示区块 **/
.demo {
margin-block-start: 24px;
margin-block-end: 24px;
}
.section {
width: 100%;
max-height: 85vh;
margin-block-start: 12px;
margin-block-end: 12px;
overflow: auto;
}
@media screen and (min-width: 640px) {
body {
min-width: 900px;
background-color: #eee;
}
.container {
box-sizing: border-box;
width: 75%;
min-width: 720px;
max-width: 880px;
margin-block-start: 48px;
margin-block-end: 72px;
margin-inline-start: auto;
margin-inline-end: auto;
padding-block-start: 48px;
padding-block-end: 48px;
padding-inline-start: 48px;
padding-inline-end: 48px;
border-radius: 2px;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.32);
background-color: #fff;
}
.article h1,
.article h2,
.article h3,
.article h4,
.article h5,
.article h6 {
position: relative;
}
.article h1:hover .anchor,
.article h2:hover .anchor,
.article h3:hover .anchor,
.article h4:hover .anchor,
.article h5:hover .anchor,
.article h6:hover .anchor {
opacity: 1;
}
.article .anchor {
position: absolute;
left: -1em;
width: 1em;
margin-inline-start: 0;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-weight: 400;
line-height: inherit;
text-align: center;
opacity: 0;
transition: opacity 0.2s linear;
}
.article .anchor:hover {
text-decoration: none;
border: 0;
}
.card {
box-sizing: border-box;
left: -20%;
width: 140%;
padding-block-start: 24px;
padding-block-end: 24px;
padding-inline-start: 32px;
padding-inline-end: 32px;
}
.section {
max-height: none;
overflow: visible;
}
}
@media screen and (min-width: 900px) {
.article__toc {
position: relative;
z-index: 1;
float: right;
width: 192px;
margin-block-start: -1px;
margin-block-end: 12px;
margin-inline-start: 32px;
margin-inline-end: -16px;
padding-block-start: 12px;
padding-block-end: 12px;
padding-inline-start: 8px;
padding-inline-end: 8px;
border: 1px solid #eee;
border-radius: 2px;
background-color: #fff;
}
.article .article__toc ol {
margin-block-start: 12px;
margin-block-end: 0;
}
.article .article__toc ol ol {
margin-block-start: 0;
}
}

View file

@ -656,7 +656,7 @@
const hasOwn = {}.hasOwnProperty; const hasOwn = {}.hasOwnProperty;
const HETI_NON_CONTIGUOUS_ELEMENTS = Object.assign({}, findAndReplaceDOMText.NON_CONTIGUOUS_PROSE_ELEMENTS, { const HETI_NON_CONTIGUOUS_ELEMENTS = Object.assign({}, findAndReplaceDOMText.NON_CONTIGUOUS_PROSE_ELEMENTS, {
ins: 1, del: 1, s: 1, ins: 1, del: 1, s: 1, a: 1,
}); });
const HETI_SKIPPED_ELEMENTS = Object.assign({}, findAndReplaceDOMText.NON_PROSE_ELEMENTS, { const HETI_SKIPPED_ELEMENTS = Object.assign({}, findAndReplaceDOMText.NON_PROSE_ELEMENTS, {
pre: 1, code: 1, sup: 1, sub: 1, 'heti-spacing': 1, 'heti-close': 1, pre: 1, code: 1, sup: 1, sub: 1, 'heti-spacing': 1, 'heti-close': 1,

View file

@ -111,6 +111,12 @@
background-color: rgba(0, 0, 0, 0.054); background-color: rgba(0, 0, 0, 0.054);
} }
@media (prefers-color-scheme: dark) {
.heti blockquote {
background-color: rgba(255, 255, 255, 0.054);
}
}
.heti figure { .heti figure {
display: block; display: block;
text-align: center; text-align: center;
@ -130,7 +136,13 @@
margin-inline-start: auto; margin-inline-start: auto;
margin-inline-end: auto; margin-inline-end: auto;
border: 0; border: 0;
background-color: #ddd; background-color: #cccccc;
}
@media (prefers-color-scheme: dark) {
.heti hr {
background-color: #404040;
}
} }
.heti p { .heti p {
@ -156,8 +168,14 @@
font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
white-space: pre; white-space: pre;
word-wrap: normal; word-wrap: normal;
background-color: rgba(0, 0, 0, 0.054);
border-radius: 4px; border-radius: 4px;
background-color: rgba(0, 0, 0, 0.054);
}
@media (prefers-color-scheme: dark) {
.heti pre {
background-color: rgba(255, 255, 255, 0.054);
}
} }
.heti pre code { .heti pre code {
@ -282,22 +300,39 @@
.heti table { .heti table {
box-sizing: border-box; box-sizing: border-box;
table-layout: fixed; table-layout: fixed;
border-collapse: collapse;
border: 1px solid #ccc;
margin-block-start: 12px; margin-block-start: 12px;
margin-block-end: 24px; margin-block-end: 24px;
margin-inline-start: auto; margin-inline-start: auto;
margin-inline-end: auto; margin-inline-end: auto;
border-collapse: collapse;
border-width: 1px;
border-style: solid;
border-color: #cccccc;
word-break: break-word; word-break: break-word;
} }
@media (prefers-color-scheme: dark) {
.heti table {
border-color: #404040;
}
}
.heti th, .heti th,
.heti td { .heti td {
border: 1px solid #ccc;
padding-block-start: 6px; padding-block-start: 6px;
padding-block-end: 6px; padding-block-end: 6px;
padding-inline-start: 8px; padding-inline-start: 8px;
padding-inline-end: 8px; padding-inline-end: 8px;
border-width: 1px;
border-style: solid;
border-color: #cccccc;
}
@media (prefers-color-scheme: dark) {
.heti th,
.heti td {
border-color: #404040;
}
} }
.heti caption { .heti caption {
@ -375,6 +410,13 @@
margin-inline-start: 1px; margin-inline-start: 1px;
margin-inline-end: 1px; margin-inline-end: 1px;
background-color: rgba(255, 247, 0, 0.88); background-color: rgba(255, 247, 0, 0.88);
color: inherit;
}
@media (prefers-color-scheme: dark) {
.heti mark {
background-color: rgba(77, 74, 0, 0.88);
}
} }
.heti q { .heti q {
@ -421,7 +463,14 @@
.heti sup:target, .heti sup:target,
.heti sup a:target { .heti sup a:target {
background-color: #def; background-color: #dbedff;
}
@media (prefers-color-scheme: dark) {
.heti sup:target,
.heti sup a:target {
background-color: #3a6188;
}
} }
.heti summary { .heti summary {
@ -437,9 +486,15 @@
.heti u[title] { .heti u[title] {
cursor: help; cursor: help;
border-block-end-color: rgba(0, 0, 0, 0.54);
border-block-end-width: 3px; border-block-end-width: 3px;
border-block-end-style: double; border-block-end-style: double;
border-block-end-color: rgba(0, 0, 0, 0.54);
}
@media (prefers-color-scheme: dark) {
.heti u[title] {
border-block-end-color: rgba(255, 255, 255, 0.54);
}
} }
.heti address, .heti address,
@ -745,19 +800,32 @@
.heti .heti-fn { .heti .heti-fn {
margin-block-start: 59px; margin-block-start: 59px;
border-block-start: 1px solid #ccc; border-block-start: 1px solid;
border-block-start-color: #cccccc;
font-size: 14px; font-size: 14px;
font-family: "Helvetica Neue", Helvetica, Arial, "Heti Hei", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-family: "Helvetica Neue", Helvetica, Arial, "Heti Hei", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
line-height: 24px; line-height: 24px;
} }
@media (prefers-color-scheme: dark) {
.heti .heti-fn {
border-block-start-color: #404040;
}
}
.heti .heti-fn ol { .heti .heti-fn ol {
margin-block-start: 12px; margin-block-start: 12px;
margin-block-end: 0; margin-block-end: 0;
} }
.heti .heti-fn li:target { .heti .heti-fn li:target {
background-color: #def; background-color: #dbedff;
}
@media (prefers-color-scheme: dark) {
.heti .heti-fn li:target {
background-color: #3a6188;
}
} }
.heti .heti-hang { .heti .heti-hang {

217
_site/index.css Normal file
View file

@ -0,0 +1,217 @@
@charset "UTF-8";
/* Project: Heti homepage URL: https://github.com/sivan/heti Author: Sivan [sun.sivan@gmail.com] */
/* normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
/* Document ========================================================================== */
/** 1. Correct the line height in all browsers. 2. Prevent adjustments of font size after orientation changes in iOS. */
html { line-height: 1.15; /* 1 */ -webkit-text-size-adjust: 100%; /* 2 */ }
/* Sections ========================================================================== */
/** Remove the margin in all browsers. */
body { margin: 0; }
/** Render the `main` element consistently in IE. */
main { display: block; }
/** Correct the font size and margin on `h1` elements within `section` and `article` contexts in Chrome, Firefox, and Safari. */
h1 { font-size: 2em; margin: 0.67em 0; }
/* Grouping content ========================================================================== */
/** 1. Add the correct box sizing in Firefox. 2. Show the overflow in Edge and IE. */
hr { box-sizing: content-box; /* 1 */ height: 0; /* 1 */ overflow: visible; /* 2 */ }
/** 1. Correct the inheritance and scaling of font size in all browsers. 2. Correct the odd `em` font sizing in all browsers. */
pre { font-family: monospace, monospace; /* 1 */ font-size: 1em; /* 2 */ }
/* Text-level semantics ========================================================================== */
/** Remove the gray background on active links in IE 10. */
a { background-color: transparent; }
/** 1. Remove the bottom border in Chrome 57- 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari. */
abbr[title] { border-bottom: none; /* 1 */ text-decoration: underline; /* 2 */ text-decoration: underline dotted; /* 2 */ }
/** Add the correct font weight in Chrome, Edge, and Safari. */
b, strong { font-weight: bolder; }
/** 1. Correct the inheritance and scaling of font size in all browsers. 2. Correct the odd `em` font sizing in all browsers. */
code, kbd, samp { font-family: monospace, monospace; /* 1 */ font-size: 1em; /* 2 */ }
/** Add the correct font size in all browsers. */
small { font-size: 80%; }
/** Prevent `sub` and `sup` elements from affecting the line height in all browsers. */
sub, sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; }
sub { bottom: -0.25em; }
sup { top: -0.5em; }
/* Embedded content ========================================================================== */
/** Remove the border on images inside links in IE 10. */
img { border-style: none; }
/* Forms ========================================================================== */
/** 1. Change the font styles in all browsers. 2. Remove the margin in Firefox and Safari. */
button, input, optgroup, select, textarea { font-family: inherit; /* 1 */ font-size: 100%; /* 1 */ line-height: 1.15; /* 1 */ margin: 0; /* 2 */ }
/** Show the overflow in IE. 1. Show the overflow in Edge. */
button, input { /* 1 */ overflow: visible; }
/** Remove the inheritance of text transform in Edge, Firefox, and IE. 1. Remove the inheritance of text transform in Firefox. */
button, select { /* 1 */ text-transform: none; }
/** Correct the inability to style clickable types in iOS and Safari. */
button, [type="button"], [type="reset"], [type="submit"] { -webkit-appearance: button; }
/** Remove the inner border and padding in Firefox. */
button::-moz-focus-inner, [type="button"]::-moz-focus-inner, [type="reset"]::-moz-focus-inner, [type="submit"]::-moz-focus-inner { border-style: none; padding: 0; }
/** Restore the focus styles unset by the previous rule. */
button:-moz-focusring, [type="button"]:-moz-focusring, [type="reset"]:-moz-focusring, [type="submit"]:-moz-focusring { outline: 1px dotted ButtonText; }
/** Correct the padding in Firefox. */
fieldset { padding: 0.35em 0.75em 0.625em; }
/** 1. Correct the text wrapping in Edge and IE. 2. Correct the color inheritance from `fieldset` elements in IE. 3. Remove the padding so developers are not caught out when they zero out `fieldset` elements in all browsers. */
legend { box-sizing: border-box; /* 1 */ color: inherit; /* 2 */ display: table; /* 1 */ max-width: 100%; /* 1 */ padding: 0; /* 3 */ white-space: normal; /* 1 */ }
/** Add the correct vertical alignment in Chrome, Firefox, and Opera. */
progress { vertical-align: baseline; }
/** Remove the default vertical scrollbar in IE 10+. */
textarea { overflow: auto; }
/** 1. Add the correct box sizing in IE 10. 2. Remove the padding in IE 10. */
[type="checkbox"], [type="radio"] { box-sizing: border-box; /* 1 */ padding: 0; /* 2 */ }
/** Correct the cursor style of increment and decrement buttons in Chrome. */
[type="number"]::-webkit-inner-spin-button, [type="number"]::-webkit-outer-spin-button { height: auto; }
/** 1. Correct the odd appearance in Chrome and Safari. 2. Correct the outline style in Safari. */
[type="search"] { -webkit-appearance: textfield; /* 1 */ outline-offset: -2px; /* 2 */ }
/** Remove the inner padding in Chrome and Safari on macOS. */
[type="search"]::-webkit-search-decoration { -webkit-appearance: none; }
/** 1. Correct the inability to style clickable types in iOS and Safari. 2. Change font properties to `inherit` in Safari. */
::-webkit-file-upload-button { -webkit-appearance: button; /* 1 */ font: inherit; /* 2 */ }
/* Interactive ========================================================================== */
/* Add the correct display in Edge, IE 10+, and Firefox. */
details { display: block; }
/* Add the correct display in all browsers. */
summary { display: list-item; }
/* Misc ========================================================================== */
/** Add the correct display in IE 10+. */
template { display: none; }
/** Add the correct display in IE 10. */
[hidden] { display: none; }
/* 简单模拟 css reset */
* { margin: 0; padding: 0; }
ul, ol { list-style: none; }
/* 模拟不知道哪里流传出来的垃圾代码 */
ul, li { list-style: none; }
.container[data-bg-grid="grid-12"] { background-size: 100% 12px; background-image: linear-gradient(transparent 11px, #ededed 1px), linear-gradient(to left, transparent 12px, #ededed, transparent 13px), linear-gradient(to right, transparent 12px, #ededed, transparent 13px); }
.container[data-bg-grid="grid-12"] .heti--vertical { outline: 1px solid #ededed; background-size: 12px 100%; background-image: linear-gradient(to left, transparent 11px, #ededed 1px); }
.container[data-bg-grid="grid-24"] { background-size: 100% 24px; background-image: linear-gradient(transparent 23px, #ededed 1px), linear-gradient(to left, transparent 12px, #ededed, transparent 13px), linear-gradient(to right, transparent 12px, #ededed, transparent 13px); }
.container[data-bg-grid="grid-24"] .heti--vertical { outline: 1px solid #ededed; background-size: 24px 100%; background-image: linear-gradient(to left, transparent 23px, #ededed 1px); }
@media (prefers-color-scheme: dark) { .container[data-bg-grid="grid-12"] { background-image: linear-gradient(transparent 11px, #333333 1px), linear-gradient(to left, transparent 12px, #333333, transparent 13px), linear-gradient(to right, transparent 12px, #333333, transparent 13px); }
.container[data-bg-grid="grid-12"] .heti--vertical { background-size: 12px 100%; background-image: linear-gradient(to left, transparent 11px, #333333 1px); }
.container[data-bg-grid="grid-24"] { background-image: linear-gradient(transparent 23px, #333333 1px), linear-gradient(to left, transparent 12px, #333333, transparent 13px), linear-gradient(to right, transparent 12px, #333333, transparent 13px); }
.container[data-bg-grid="grid-24"] .heti--vertical { background-size: 24px 100%; background-image: linear-gradient(to left, transparent 23px, #333333 1px); } }
@media screen and (min-width: 640px) { .container[data-bg-grid="grid-12"] { background-image: linear-gradient(transparent 11px, #ededed 1px), linear-gradient(to left, transparent 48px, #ededed, transparent 49px), linear-gradient(to right, transparent 48px, rgba(255, 0, 0, 0.4), transparent 49px); }
.container[data-bg-grid="grid-24"] { background-image: linear-gradient(transparent 23px, #ededed 1px), linear-gradient(to left, transparent 48px, #ededed, transparent 49px), linear-gradient(to right, transparent 48px, rgba(255, 0, 0, 0.4), transparent 49px); } }
@media screen and (min-width: 640px) and (prefers-color-scheme: dark) { .container[data-bg-grid="grid-12"] { background-image: linear-gradient(transparent 11px, #333333 1px), linear-gradient(to left, transparent 48px, #333333, transparent 49px), linear-gradient(to right, transparent 48px, rgba(255, 77, 77, 0.4), transparent 49px); }
.container[data-bg-grid="grid-24"] { background-image: linear-gradient(transparent 23px, #333333 1px), linear-gradient(to left, transparent 48px, #333333, transparent 49px), linear-gradient(to right, transparent 48px, rgba(255, 77, 77, 0.4), transparent 49px); } }
.panel-list { --bg-color: hsl(240, 100%, 100%); --bg-tap-color: hsl(300, 3%, 94%); --border-color: hsla(0, 0%, 76%, 0.88); --border-inline-start-color: hsl(0, 0%, 76%); --border-inline-end-color: hsl(0, 0%, 76%); --border-block-start-color: hsl(0, 0%, 79%); --border-block-end-color: hsl(0, 0%, 65%); --text-color: hsl(60, 1%, 16%); --box-shadow-color: hsla(0, 0%, 86%, 0.54); --bg-highlight-color-start: hsl(216, 87%, 70%); --bg-highlight-color-end: hsl(215, 93%, 52%); --bg-highlight-tap-color-start: hsl(216, 92%, 65%); --bg-highlight-tap-color-end: hsl(215, 95%, 44%); --border-highlight-color: hsla(216, 90%, 57%, 0.88); --border-highlight-tap-color: hsla(216, 85%, 52%, 0.88); --border-inline-start-highlight-color: hsl(216, 90%, 57%); --border-inline-end-highlight-color: hsl(216, 90%, 57%); --border-inline-start-highlight-tap-color: hsl(216, 85%, 52%); --border-inline-end-highlight-tap-color: hsl(216, 85%, 52%); --border-block-start-highlight-color: hsl(216, 87%, 63%); --border-block-end-highlight-color: hsl(215, 99%, 49%); --border-block-start-highlight-tap-color: hsl(216, 93%, 57%); --border-block-end-highlight-tap-color: hsl(216, 100%, 42%); --text-highlight-color: hsl(0, 0%, 100%); display: inline-flex; margin: 0; padding: 0; list-style-type: none; margin-inline-start: 16px; }
.panel-list--gray { --bg-color: hsl(180, 100%, 100%); --bg-tap-color: hsl(0, 0%, 94%); --border-color: hsla(0, 0%, 72%, 0.88); --border-inline-start-color: hsl(0, 0%, 76%); --border-inline-end-color: hsl(0, 0%, 76%); --border-block-start-color: hsl(0, 0%, 79%); --border-block-end-color: hsl(0, 0%, 65%); --text-color: hsl(0, 0%, 16%); --box-shadow-color: hsla(0, 0%, 86%, 0.54); --bg-highlight-color-start: hsl(225, 3%, 70%); --bg-highlight-color-end: hsl(228, 2%, 58%); --bg-highlight-tap-color-start: hsl(228, 2%, 58%); --bg-highlight-tap-color-end: hsl(240, 3%, 35%); --border-highlight-color: hsla(225, 2%, 64%, 0.88); --border-highlight-tap-color: hsla(228, 2%, 47%, 0.88); --border-inline-start-highlight-color: hsl(240, 3%, 59%); --border-inline-end-highlight-color: hsl(228, 2%, 54%); --border-inline-start-highlight-tap-color: hsl(240, 3%, 39%); --border-inline-end-highlight-tap-color: hsl(228, 3%, 39%); --border-block-start-highlight-color: hsl(240, 3%, 66%); --border-block-end-highlight-color: hsl(228, 2%, 50%); --border-block-start-highlight-tap-color: hsl(228, 2%, 51%); --border-block-end-highlight-tap-color: hsl(228, 4%, 26%); --text-highlight-color: hsl(0, 0%, 92%); }
@media (prefers-color-scheme: dark) { .panel-list { --bg-color: hsl(225, 2%, 40%); --bg-tap-color: hsl(210, 2%, 49%); --border-color: hsla(210, 2%, 33%, 0.88); --border-inline-start-color: hsl(210, 2%, 33%); --border-inline-end-color: hsl(210, 2%, 33%); --border-block-start-color: hsl(225, 2%, 45%); --border-block-end-color: hsl(210, 2%, 40%); --text-color: hsl(0, 0%, 91%); --box-shadow-color: hsla(225, 4%, 21%, 0.54); --bg-highlight-color-start: hsl(216, 77%, 49%); --bg-highlight-color-end: hsl(216, 76%, 45%); --bg-highlight-tap-color-start: hsl(214, 83%, 55%); --bg-highlight-tap-color-end: hsl(215, 74%, 51%); --border-highlight-color: hsla(215, 77%, 47%, 0.88); --border-highlight-tap-color: hsla(215, 79%, 54%, 0.88); --border-inline-start-highlight-color: hsl(215, 77%, 47%); --border-inline-end-highlight-color: hsl(215, 77%, 47%); --border-inline-start-highlight-tap-color: hsl(215, 79%, 54%); --border-inline-end-highlight-tap-color: hsl(215, 79%, 54%); --border-block-start-highlight-color: hsl(216, 76%, 55%); --border-block-end-highlight-color: hsl(216, 76%, 44%); --border-block-start-highlight-tap-color: hsl(215, 84%, 60%); --border-block-end-highlight-tap-color: hsl(215, 74%, 51%); --text-highlight-color: hsl(0, 0%, 100%); }
.panel-list--gray { --bg-color: hsl(0, 0%, 40%); --bg-tap-color: hsl(0, 0%, 49%); --border-color: hsla(120, 1%, 34%, 0.88); --border-inline-start-color: hsl(0, 0%, 40%); --border-inline-end-color: hsl(360, 0%, 40%); --border-block-start-color: hsl(0, 0%, 46%); --border-block-end-color: hsl(120, 0%, 40%); --text-color: hsl(0, 0%, 91%); --box-shadow-color: hsla(0, 0%, 17%, 0.54); --bg-highlight-color-start: hsl(0, 0%, 60%); --bg-highlight-color-end: hsl(0, 0%, 60%); --bg-highlight-tap-color-start: hsl(0, 0%, 69%); --bg-highlight-tap-color-end: hsl(0, 0%, 69%); --border-highlight-color: hsla(0, 0%, 60%, 0.88); --border-highlight-tap-color: hsla(0, 0%, 69%, 0.88); --border-inline-start-highlight-color: hsl(0, 0%, 60%); --border-inline-end-highlight-color: hsl(0, 0%, 60%); --border-inline-start-highlight-tap-color: hsl(0, 0%, 69%); --border-inline-end-highlight-tap-color: hsl(0, 0%, 69%); --border-block-start-highlight-color: hsl(0, 0%, 64%); --border-block-end-highlight-color: hsl(0, 0%, 60%); --border-block-start-highlight-tap-color: hsl(0, 0%, 73%); --border-block-end-highlight-tap-color: hsl(0, 0%, 69%); --text-highlight-color: hsl(0, 0%, 15%); } }
.panel-list + .panel-list { margin-inline-start: 12px; }
.panel-list li { margin-inline-end: -1px; }
.panel-list li:first-child label { border-top-left-radius: 4px; border-bottom-left-radius: 4px; border-inline-start-color: var(--border-inline-start-color); }
.panel-list li:last-child label { border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-inline-end-color: var(--border-inline-end-color); }
.panel-list label { position: relative; display: block; box-sizing: border-box; height: 20px; padding: 0; padding-inline-start: 12px; padding-inline-end: 12px; border: 1px solid; font-size: 12px; line-height: 18px; text-align: center; user-select: none; background-color: var(--bg-color); border-color: var(--border-color); border-block-start-color: var(--border-block-start-color); border-block-end-color: var(--border-block-end-color); color: var(--text-color); box-shadow: 0 1px 0 var(--box-shadow-color); }
.panel-list label:active { background-color: var(--bg-tap-color); }
.panel-list input { display: none; }
.panel-list input:checked + label { z-index: 1; background-image: linear-gradient(to bottom, var(--bg-highlight-color-start), var(--bg-highlight-color-end)); border-color: var(--border-highlight-color); border-block-start-color: var(--border-block-start-highlight-color); border-block-end-color: var(--border-block-end-highlight-color); color: var(--text-highlight-color); }
.panel-list input:checked + label:active { background-image: linear-gradient(to bottom, var(--bg-highlight-tap-color-start), var(--bg-highlight-tap-color-end)); border-color: var(--border-highlight-tap-color); border-block-start-color: var(--border-block-start-highlight-tap-color); border-block-end-color: var(--border-block-end-highlight-tap-color); }
.anchor { margin-inline-start: 0.25em; }
@media screen and (min-width: 640px) { .article .anchor { position: absolute; left: -1em; width: 1em; margin-inline-start: 0; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-weight: 400; line-height: inherit; text-align: center; opacity: 0; transition: opacity 0.2s linear; }
.article .anchor:hover { text-decoration: none; border: 0; }
.article h1, .article h2, .article h3, .article h4, .article h5, .article h6 { position: relative; }
.article h1:hover .anchor, .article h2:hover .anchor, .article h3:hover .anchor, .article h4:hover .anchor, .article h5:hover .anchor, .article h6:hover .anchor { opacity: 1; } }
.card { position: relative; left: -12px; width: 100%; margin-block-start: 24px; margin-block-end: 48px; padding-block-start: 12px; padding-block-end: 12px; padding-inline-start: 12px; padding-inline-end: 12px; border-radius: 2px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16); background-color: white; }
.article .card { text-align: left; }
.card > figcaption { display: inline-block; margin-block-start: 16px; padding-block-start: 4px; padding-block-end: 3px; padding-inline-start: 0; padding-inline-end: 72px; line-height: 24px; border-block-start: 1px solid #ededed; }
.card__vertical-container { box-sizing: border-box; width: 100%; height: 30em; border: 1px solid #ededed; overflow: auto; writing-mode: vertical-rl; }
@media screen and (min-width: 640px) { .card { box-sizing: border-box; left: -20%; width: 140%; padding-block-start: 24px; padding-block-end: 24px; padding-inline-start: 32px; padding-inline-end: 32px; } }
@media (prefers-color-scheme: dark) { .card { background-color: #292929; }
.card > figcaption { border-block-start: 1px solid #333333; }
.card__vertical-container { border-color: #333333; } }
/** 基础样式 **/
body { background-color: white; }
a { color: #4387f4; text-decoration: none; }
.container { box-sizing: border-box; padding-block-start: 12px; padding-block-end: 72px; padding-inline-start: 12px; padding-inline-end: 12px; }
/** 首页样式 **/
.article { margin-inline-start: auto; margin-inline-end: auto; }
.article__nav ol { margin-block-start: 24px; margin-block-end: 24px; }
/** 控制栏样式 **/
.panel { position: fixed; z-index: 2; right: 12px; top: 12px; display: flex; text-align: right; }
/** 演示区块 **/
.demo { margin-block-start: 24px; margin-block-end: 24px; }
.section { width: 100%; max-height: 85vh; margin-block-start: 12px; margin-block-end: 12px; overflow: auto; }
@media screen and (min-width: 640px) { body { min-width: 640px; background-color: #ededed; }
.container { box-sizing: border-box; width: 80%; min-width: 640px; max-width: 880px; margin-block-start: 48px; margin-block-end: 72px; margin-inline-start: auto; margin-inline-end: auto; padding-block-start: 48px; padding-block-end: 48px; padding-inline-start: 48px; padding-inline-end: 48px; border-radius: 2px; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.32); background-color: white; }
.section { max-height: none; overflow: visible; } }
@media screen and (min-width: 900px) { .article__nav { position: relative; z-index: 1; float: right; width: 192px; margin-block-start: -1px; margin-block-end: 12px; margin-inline-start: 32px; margin-inline-end: -16px; padding-block-start: 12px; padding-block-end: 12px; padding-inline-start: 8px; padding-inline-end: 8px; border: 1px solid #ededed; border-radius: 2px; }
.article__nav ol { margin-block-start: 12px; margin-block-end: 0; }
.article__nav ol ol { margin-block-start: 0; } }
@media (prefers-color-scheme: dark) { body { background-color: #3d3d3d; }
a { color: #6b90cc; }
a:visited { color: #2f5189; }
.container { background-color: #292929; color: #a3a3a3; }
.article__nav { border-color: #333333; } }

View file

@ -4,18 +4,17 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>赫蹏 - 一个简约又简单的网页中文排版增强</title> <title>赫蹏 - 一个简约又简单的网页中文排版增强</title>
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="./assets/normalize.css">
<link rel="stylesheet" href="./assets/index.css">
<link rel="stylesheet" href="./heti.css"> <link rel="stylesheet" href="./heti.css">
<link rel="stylesheet" href="./index.css">
<link rel="icon" href="./favicon.svg"> <link rel="icon" href="./favicon.svg">
</head> </head>
<body> <body>
<main class="container"> <main class="container">
<article class="article heti heti--classic"> <article class="article heti heti--classic">
<h1>赫蹏</h1> <h1 class="article__title">赫蹏</h1>
<blockquote>古代称用以书写的小幅绢帛。后亦以借指纸。《汉书·外戚传下·孝成赵皇后》:「武(籍武 )发篋中,有裹药二枚,赫蹏书。」<u>颜师古</u>注:「<u>邓展</u>曰:『赫音兄弟鬩墙之鬩。』<u>应劭</u>曰:『赫蹏,薄小纸也。』」<u></u><u>赵彦卫</u> 《云麓漫钞》卷七:「《赵后传》所谓『赫蹏』者,注云『薄小纸』,然其寔亦縑帛。」</blockquote> <blockquote>古代称用以书写的小幅绢帛。后亦以借指纸。《汉书·外戚传下·孝成赵皇后》:「武(籍武 )发篋中,有裹药二枚,赫蹏书。」<u>颜师古</u>注:「<u>邓展</u>曰:『赫音兄弟鬩墙之鬩。』<u>应劭</u>曰:『赫蹏,薄小纸也。』」<u></u><u>赵彦卫</u> 《云麓漫钞》卷七:「《赵后传》所谓『赫蹏』者,注云『薄小纸』,然其寔亦縑帛。」</blockquote>
<nav class="article__toc heti-skip"> <nav class="article__nav heti-skip">
<details open> <details open>
<summary>目录</summary> <summary>目录</summary>
<ol> <ol>
@ -55,6 +54,7 @@
<li>预置多种排版样式(行间注、多栏、竖排等);</li> <li>预置多种排版样式(行间注、多栏、竖排等);</li>
<li>多种预设字体族(仅限桌面端);</li> <li>多种预设字体族(仅限桌面端);</li>
<li>简/繁体中文支持;</li> <li>简/繁体中文支持;</li>
<li>自适应黑暗模式;</li>
<li>中西文混排美化,不再手敲空格(基于JavaScript脚本);</li> <li>中西文混排美化,不再手敲空格(基于JavaScript脚本);</li>
<li>标点挤压(基于JavaScript脚本);</li> <li>标点挤压(基于JavaScript脚本);</li>
<li>兼容<i>normalize.css</i><i>CSS Reset<sup><a id="ref-01" href="#fn-01">[1]</a></sup></i>等常见样式重置;</li> <li>兼容<i>normalize.css</i><i>CSS Reset<sup><a id="ref-01" href="#fn-01">[1]</a></sup></i>等常见样式重置;</li>
@ -557,7 +557,7 @@
<h2 id="wip">待开发功能<a class="anchor" href="#wip">#</a></h2> <h2 id="wip">待开发功能<a class="anchor" href="#wip">#</a></h2>
<ul> <ul>
<li> 自适应黑暗模式</li> <li> 自适应黑暗模式</li>
<li>✅ 标点挤压</li> <li>✅ 标点挤压</li>
<li>✅ 中、西文混排</li> <li>✅ 中、西文混排</li>
<li>✅ 诗词版式</li> <li>✅ 诗词版式</li>
@ -583,12 +583,12 @@
</main> </main>
<aside class="panel"> <aside class="panel">
<ul class="switch-list"> <ul class="panel-list panel-list--gray">
<li><input type="radio" class="J_fontStack" value="heti--classic" name="font" id="font-classic" checked><label for="font-classic">传统</label></li> <li><input type="radio" class="J_fontStack" value="heti--classic" name="font" id="font-classic" checked><label for="font-classic">传统</label></li>
<li><input type="radio" class="J_fontStack" value="heti--sans" name="font" id="font-sans"><label for="font-sans">黑体</label></li> <li><input type="radio" class="J_fontStack" value="heti--sans" name="font" id="font-sans"><label for="font-sans">黑体</label></li>
<li><input type="radio" class="J_fontStack" value="heti--serif" name="font" id="font-serif"><label for="font-serif">宋体</label></li> <li><input type="radio" class="J_fontStack" value="heti--serif" name="font" id="font-serif"><label for="font-serif">宋体</label></li>
</ul> </ul>
<ul class="switch-list"> <ul class="panel-list panel-list--gray">
<li><input type="radio" class="J_radioGrid" value="" name="grid" id="grid-disable" checked><label for="grid-disable">网格:关</label></li> <li><input type="radio" class="J_radioGrid" value="" name="grid" id="grid-disable" checked><label for="grid-disable">网格:关</label></li>
<li><input type="radio" class="J_radioGrid" value="grid-24" name="grid" id="grid-24"><label for="grid-24"></label></li> <li><input type="radio" class="J_radioGrid" value="grid-24" name="grid" id="grid-24"><label for="grid-24"></label></li>
<li><input type="radio" class="J_radioGrid" value="grid-12" name="grid" id="grid-12"><label for="grid-12"></label></li> <li><input type="radio" class="J_radioGrid" value="grid-12" name="grid" id="grid-12"><label for="grid-12"></label></li>
@ -597,7 +597,8 @@
<script src="./heti-addon.js"></script> <script src="./heti-addon.js"></script>
<script> <script>
const $$root = document.getElementsByTagName('article')[0] const $$root = document.getElementsByTagName('main')[0]
const $$article = document.getElementsByTagName('article')[0]
function addEventListeners(nodeList, event, fn) { function addEventListeners(nodeList, event, fn) {
[].forEach.call(nodeList, function(elm) { [].forEach.call(nodeList, function(elm) {
@ -605,14 +606,14 @@
}, false) }, false)
} }
addEventListeners(document.getElementsByClassName('J_fontStack'), 'change', function (e) {
$$root.className = ['article', 'heti', e.target.value].join(' ')
})
addEventListeners(document.getElementsByClassName('J_radioGrid'), 'change', function (e) { addEventListeners(document.getElementsByClassName('J_radioGrid'), 'change', function (e) {
$$root.setAttribute('data-bg-grid', e.target.value) $$root.setAttribute('data-bg-grid', e.target.value)
}) })
addEventListeners(document.getElementsByClassName('J_fontStack'), 'change', function (e) {
$$article.className = ['article', 'heti', e.target.value].join(' ')
})
const heti = new Heti() const heti = new Heti()
heti.autoSpacing() heti.autoSpacing()
</script> </script>

View file

@ -0,0 +1,43 @@
// Author: Sivan [sun.sivan@gmail.com]
// Description: anchor.
.anchor {
margin-inline-start: 0.25em;
}
@media screen and (min-width: 640px) {
.article {
.anchor {
position: absolute;
left: -1em;
width: 1em;
margin-inline-start: 0;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-weight: 400;
line-height: inherit;
text-align: center;
opacity: 0;
transition: opacity 0.2s linear;
&:hover {
text-decoration: none;
border: 0;
}
}
h1,
h2,
h3,
h4,
h5,
h6 {
position: relative;
&:hover {
.anchor {
opacity: 1;
}
}
}
}
}

View file

@ -0,0 +1,68 @@
// Author: Sivan [sun.sivan@gmail.com]
// Description: card.
.card {
position: relative;
left: -12px;
width: 100%;
margin-block-start: 24px;
margin-block-end: 48px;
padding-block-start: 12px;
padding-block-end: 12px;
padding-inline-start: 12px;
padding-inline-end: 12px;
border-radius: 2px;
box-shadow: 0 4px 16px hsla(0, 0%, 0%, 0.16);
background-color: hsl(0, 0%, 100%);
// 内容居左覆盖 .heti figure
.article & {
text-align: left;
}
> figcaption {
display: inline-block;
margin-block-start: 16px;
padding-block-start: 4px;
padding-block-end: 3px;
padding-inline-start: 0;
padding-inline-end: 72px;
line-height: 24px;
border-block-start: 1px solid hsl(0, 0%, 93%);
}
}
.card__vertical-container {
box-sizing: border-box;
width: 100%;
height: 30em;
border: 1px solid hsl(0, 0%, 93%);
overflow: auto;
writing-mode: vertical-rl;
}
@media screen and (min-width: 640px) {
.card {
box-sizing: border-box;
left: -20%;
width: 140%;
padding-block-start: 24px;
padding-block-end: 24px;
padding-inline-start: 32px;
padding-inline-end: 32px;
}
}
@media (prefers-color-scheme: dark) {
.card {
background-color: hsl(0, 0%, 16%);
> figcaption {
border-block-start: 1px solid hsl(0, 0%, 20%);
}
}
.card__vertical-container {
border-color: hsl(0, 0%, 20%);
}
}

View file

@ -0,0 +1,66 @@
// Author: Sivan [sun.sivan@gmail.com]
// Description: grid container.
$grid-sizes: (
"12": 12px,
"24": 24px
);
$padding-mobile: 12px;
$padding-desktop: 48px;
@mixin grid-image-horizontal($grid-width, $padding-width, $grid-color: hsl(0, 0%, 93%), $margin-color: $grid-color) {
background-image:
linear-gradient(transparent ($grid-width - 1px), $grid-color 1px),
linear-gradient(to left, transparent $padding-width, $grid-color, transparent ($padding-width + 1px)),
linear-gradient(to right, transparent $padding-width, $margin-color, transparent ($padding-width + 1px));
}
@mixin grid-image-vertical($grid-width, $grid-color: hsl(0, 0%, 93%)) {
background-size: $grid-width 100%;
background-image: linear-gradient(to left, transparent ($grid-width - 1px), $grid-color 1px);
}
.container {
@each $size, $width in $grid-sizes {
&[data-bg-grid="grid-#{$size}"] {
background-size: 100% $width;
@include grid-image-horizontal($width, $padding-mobile);
.heti--vertical {
outline: 1px solid hsl(0, 0%, 93%);
@include grid-image-vertical($width);
}
}
}
@media (prefers-color-scheme: dark) {
@each $size, $width in $grid-sizes {
&[data-bg-grid="grid-#{$size}"] {
@include grid-image-horizontal($width, $padding-mobile, hsl(0, 0%, 20%));
.heti--vertical {
@include grid-image-vertical($width, hsl(0, 0%, 20%));
}
}
}
}
@media screen and (min-width: 640px) {
@each $size, $width in $grid-sizes {
&[data-bg-grid="grid-#{$size}"] {
// 桌面端增加缩进修改边距线为红色
@include grid-image-horizontal($width, $padding-desktop, hsl(0, 0%, 93%), hsla(360, 100%, 50%, 0.4));
}
}
@media (prefers-color-scheme: dark) {
@each $size, $width in $grid-sizes {
&[data-bg-grid="grid-#{$size}"] {
@include grid-image-horizontal($width, $padding-desktop, hsl(0, 0%, 20%), hsla(360, 100%, 65%, 0.4));
}
}
}
}
}

View file

@ -0,0 +1,181 @@
// Author: Sivan [sun.sivan@gmail.com]
// Description: panel list.
.panel-list {
--bg-color: hsl(240, 100%, 100%);
--bg-tap-color: hsl(300, 3%, 94%);
--border-color: hsla(0, 0%, 76%, 0.88);
--border-inline-start-color: hsl(0, 0%, 76%);
--border-inline-end-color: hsl(0, 0%, 76%);
--border-block-start-color: hsl(0, 0%, 79%);
--border-block-end-color: hsl(0, 0%, 65%);
--text-color: hsl(60, 1%, 16%);
--box-shadow-color: hsla(0, 0%, 86%, 0.54);
--bg-highlight-color-start: hsl(216, 87%, 70%);
--bg-highlight-color-end: hsl(215, 93%, 52%);
--bg-highlight-tap-color-start: hsl(216, 92%, 65%);
--bg-highlight-tap-color-end: hsl(215, 95%, 44%);
--border-highlight-color: hsla(216, 90%, 57%, 0.88);
--border-highlight-tap-color: hsla(216, 85%, 52%, 0.88);
--border-inline-start-highlight-color: hsl(216, 90%, 57%);
--border-inline-end-highlight-color: hsl(216, 90%, 57%);
--border-inline-start-highlight-tap-color: hsl(216, 85%, 52%);
--border-inline-end-highlight-tap-color: hsl(216, 85%, 52%);
--border-block-start-highlight-color: hsl(216, 87%, 63%);
--border-block-end-highlight-color: hsl(215, 99%, 49%);
--border-block-start-highlight-tap-color: hsl(216, 93%, 57%);
--border-block-end-highlight-tap-color: hsl(216, 100%, 42%);
--text-highlight-color: hsl(0, 0%, 100%);
&--gray {
--bg-color: hsl(180, 100%, 100%);
--bg-tap-color: hsl(0, 0%, 94%);
--border-color: hsla(0, 0%, 72%, 0.88);
--border-inline-start-color: hsl(0, 0%, 76%);
--border-inline-end-color: hsl(0, 0%, 76%);
--border-block-start-color: hsl(0, 0%, 79%);
--border-block-end-color: hsl(0, 0%, 65%);
--text-color: hsl(0, 0%, 16%);
--box-shadow-color: hsla(0, 0%, 86%, 0.54);
--bg-highlight-color-start: hsl(225, 3%, 70%);
--bg-highlight-color-end: hsl(228, 2%, 58%);
--bg-highlight-tap-color-start: hsl(228, 2%, 58%);
--bg-highlight-tap-color-end: hsl(240, 3%, 35%);
--border-highlight-color: hsla(225, 2%, 64%, 0.88);
--border-highlight-tap-color: hsla(228, 2%, 47%, 0.88);
--border-inline-start-highlight-color: hsl(240, 3%, 59%);
--border-inline-end-highlight-color: hsl(228, 2%, 54%);
--border-inline-start-highlight-tap-color: hsl(240, 3%, 39%);
--border-inline-end-highlight-tap-color: hsl(228, 3%, 39%);
--border-block-start-highlight-color: hsl(240, 3%, 66%);
--border-block-end-highlight-color: hsl(228, 2%, 50%);
--border-block-start-highlight-tap-color: hsl(228, 2%, 51%);
--border-block-end-highlight-tap-color: hsl(228, 4%, 26%);
--text-highlight-color: hsl(0, 0%, 92%);
}
@media (prefers-color-scheme: dark) {
--bg-color: hsl(225, 2%, 40%);
--bg-tap-color: hsl(210, 2%, 49%);
--border-color: hsla(210, 2%, 33%, 0.88);
--border-inline-start-color: hsl(210, 2%, 33%);
--border-inline-end-color: hsl(210, 2%, 33%);
--border-block-start-color: hsl(225, 2%, 45%);
--border-block-end-color: hsl(210, 2%, 40%);
--text-color: hsl(0, 0%, 91%);
--box-shadow-color: hsla(225, 4%, 21%, 0.54);
--bg-highlight-color-start: hsl(216, 77%, 49%);
--bg-highlight-color-end: hsl(216, 76%, 45%);
--bg-highlight-tap-color-start: hsl(214, 83%, 55%);
--bg-highlight-tap-color-end: hsl(215, 74%, 51%);
--border-highlight-color: hsla(215, 77%, 47%, 0.88);
--border-highlight-tap-color: hsla(215, 79%, 54%, 0.88);
--border-inline-start-highlight-color: hsl(215, 77%, 47%);
--border-inline-end-highlight-color: hsl(215, 77%, 47%);
--border-inline-start-highlight-tap-color: hsl(215, 79%, 54%);
--border-inline-end-highlight-tap-color: hsl(215, 79%, 54%);
--border-block-start-highlight-color: hsl(216, 76%, 55%);
--border-block-end-highlight-color: hsl(216, 76%, 44%);
--border-block-start-highlight-tap-color: hsl(215, 84%, 60%);
--border-block-end-highlight-tap-color: hsl(215, 74%, 51%);
--text-highlight-color: hsl(0, 0%, 100%);
&--gray {
--bg-color: hsl(0, 0%, 40%);
--bg-tap-color: hsl(0, 0%, 49%);
--border-color: hsla(120, 1%, 34%, 0.88);
--border-inline-start-color: hsl(0, 0%, 40%);
--border-inline-end-color: hsl(360, 0%, 40%);
--border-block-start-color: hsl(0, 0%, 46%);
--border-block-end-color: hsl(120, 0%, 40%);
--text-color: hsl(0, 0%, 91%);
--box-shadow-color: hsla(0, 0%, 17%, 0.54);
--bg-highlight-color-start: hsl(0, 0%, 60%);
--bg-highlight-color-end: hsl(0, 0%, 60%);
--bg-highlight-tap-color-start: hsl(0, 0%, 69%);
--bg-highlight-tap-color-end: hsl(0, 0%, 69%);
--border-highlight-color: hsla(0, 0%, 60%, 0.88);
--border-highlight-tap-color: hsla(0, 0%, 69%, 0.88);
--border-inline-start-highlight-color: hsl(0, 0%, 60%);
--border-inline-end-highlight-color: hsl(0, 0%, 60%);
--border-inline-start-highlight-tap-color: hsl(0, 0%, 69%);
--border-inline-end-highlight-tap-color: hsl(0, 0%, 69%);
--border-block-start-highlight-color: hsl(0, 0%, 64%);
--border-block-end-highlight-color: hsl(0, 0%, 60%);
--border-block-start-highlight-tap-color: hsl(0, 0%, 73%);
--border-block-end-highlight-tap-color: hsl(0, 0%, 69%);
--text-highlight-color: hsl(0, 0%, 15%);
}
}
display: inline-flex;
margin: 0;
padding: 0;
list-style-type: none;
margin-inline-start: 16px;
& + & {
margin-inline-start: 12px;
}
label {
position: relative;
display: block;
box-sizing: border-box;
height: 20px;
padding: 0;
padding-inline-start: 12px;
padding-inline-end: 12px;
border: 1px solid;
font-size: 12px;
line-height: 18px;
text-align: center;
user-select: none;
background-color: var(--bg-color);
border-color: var(--border-color);
border-block-start-color: var(--border-block-start-color);
border-block-end-color: var(--border-block-end-color);
color: var(--text-color);
box-shadow: 0 1px 0 var(--box-shadow-color);
&:active {
background-color: var(--bg-tap-color);
}
}
li {
margin-inline-end: -1px;
&:first-child label {
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
border-inline-start-color: var(--border-inline-start-color);
}
&:last-child label {
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
border-inline-end-color: var(--border-inline-end-color);
}
}
input {
display: none;
&:checked + label {
z-index: 1;
background-image: linear-gradient(to bottom, var(--bg-highlight-color-start), var(--bg-highlight-color-end));
border-color: var(--border-highlight-color);
border-block-start-color: var(--border-block-start-highlight-color);
border-block-end-color: var(--border-block-end-highlight-color);
color: var(--text-highlight-color);
&:active {
background-image: linear-gradient(to bottom, var(--bg-highlight-tap-color-start), var(--bg-highlight-tap-color-end));
border-color: var(--border-highlight-tap-color);
border-block-start-color: var(--border-block-start-highlight-tap-color);
border-block-end-color: var(--border-block-end-highlight-tap-color);
}
}
}
}

152
_site/scss/index.scss Normal file
View file

@ -0,0 +1,152 @@
/*
* Project: Heti homepage
* URL: https://github.com/sivan/heti
* Author: Sivan [sun.sivan@gmail.com]
*/
@import "lib/normalize";
@import "lib/reset";
@import "components/grid-container";
@import "components/panel-list";
@import "components/anchor";
@import "components/card";
/** 基础样式 **/
body {
background-color: hsl(0, 0%, 100%);
}
a {
color: hsl(217, 89%, 61%);
text-decoration: none;
}
.container {
box-sizing: border-box;
padding-block-start: 12px;
padding-block-end: 72px;
padding-inline-start: 12px;
padding-inline-end: 12px;
}
/** 首页样式 **/
.article {
margin-inline-start: auto;
margin-inline-end: auto;
// 导航样式
&__nav {
ol {
margin-block-start: 24px;
margin-block-end: 24px;
}
}
}
/** 控制栏样式 **/
.panel {
position: fixed;
z-index: 2;
right: 12px;
top: 12px;
display: flex;
text-align: right;
}
/** 演示区块 **/
.demo {
margin-block-start: 24px;
margin-block-end: 24px;
}
.section {
width: 100%;
max-height: 85vh;
margin-block-start: 12px;
margin-block-end: 12px;
overflow: auto;
}
@media screen and (min-width: 640px) {
body {
min-width: 640px;
background-color: hsl(0, 0%, 93%);
}
.container {
box-sizing: border-box;
width: 80%;
min-width: 640px;
max-width: 880px;
margin-block-start: 48px;
margin-block-end: 72px;
margin-inline-start: auto;
margin-inline-end: auto;
padding-block-start: 48px;
padding-block-end: 48px;
padding-inline-start: 48px;
padding-inline-end: 48px;
border-radius: 2px;
box-shadow: 0 8px 32px hsla(0, 0%, 0%, 0.32);
background-color: hsl(0, 0%, 100%);
}
.section {
max-height: none;
overflow: visible;
}
}
@media screen and (min-width: 900px) {
.article {
&__nav {
position: relative;
z-index: 1;
float: right;
width: 192px;
margin-block-start: -1px;
margin-block-end: 12px;
margin-inline-start: 32px;
margin-inline-end: -16px;
padding-block-start: 12px;
padding-block-end: 12px;
padding-inline-start: 8px;
padding-inline-end: 8px;
border: 1px solid hsl(0, 0%, 93%);
border-radius: 2px;
ol {
margin-block-start: 12px;
margin-block-end: 0;
ol {
margin-block-start: 0;
}
}
}
}
}
@media (prefers-color-scheme: dark) {
body {
background-color: hsl(0, 0%, 24%);
}
a {
color: hsl(217, 49%, 61%);
&:visited {
color: hsl(217, 49%, 36%);
}
}
.container {
background-color: hsl(0, 0%, 16%);
color: hsl(0, 0%, 64%);
}
.article {
&__nav {
border-color: hsl(0, 0%, 20%);
}
}
}

View file

@ -1,4 +1,4 @@
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */ /* normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
/* Document /* Document
========================================================================== */ ========================================================================== */

View file

@ -0,0 +1,16 @@
/* 简单模拟 css reset */
* {
margin: 0;
padding: 0;
}
ul,
ol {
list-style: none;
}
/* 模拟不知道哪里流传出来的垃圾代码 */
ul,
li {
list-style: none;
}

View file

@ -7,7 +7,7 @@ import Finder from 'heti-findandreplacedomtext'
const hasOwn = {}.hasOwnProperty const hasOwn = {}.hasOwnProperty
const HETI_NON_CONTIGUOUS_ELEMENTS = Object.assign({}, Finder.NON_CONTIGUOUS_PROSE_ELEMENTS, { const HETI_NON_CONTIGUOUS_ELEMENTS = Object.assign({}, Finder.NON_CONTIGUOUS_PROSE_ELEMENTS, {
ins: 1, del: 1, s: 1, ins: 1, del: 1, s: 1, a: 1,
}) })
const HETI_SKIPPED_ELEMENTS = Object.assign({}, Finder.NON_PROSE_ELEMENTS, { const HETI_SKIPPED_ELEMENTS = Object.assign({}, Finder.NON_PROSE_ELEMENTS, {
pre: 1, code: 1, sup: 1, sub: 1, 'heti-spacing': 1, 'heti-close': 1, pre: 1, code: 1, sup: 1, sub: 1, 'heti-spacing': 1, 'heti-close': 1,

View file

@ -29,8 +29,12 @@
padding-block-end: $std-block-unit / 2; padding-block-end: $std-block-unit / 2;
padding-inline-start: $std-inline-unit; padding-inline-start: $std-inline-unit;
padding-inline-end: $std-inline-unit; padding-inline-end: $std-inline-unit;
background-color: rgba(0, 0, 0, 0.054);
//border-radius: 4px; //border-radius: 4px;
background-color: hsla(0, 0%, 0%, 0.054);
@media (prefers-color-scheme: dark) {
background-color: hsla(0, 0%, 100%, 0.054);
}
} }
figure { figure {
@ -52,7 +56,11 @@
margin-inline-start: auto; margin-inline-start: auto;
margin-inline-end: auto; margin-inline-end: auto;
border: 0; border: 0;
background-color: #ddd; background-color: hsl(0, 0%, 80%);
@media (prefers-color-scheme: dark) {
background-color: hsl(0, 0%, 25%);
}
} }
p { p {
@ -78,8 +86,12 @@
font-family: $font-family-mono; font-family: $font-family-mono;
white-space: pre; white-space: pre;
word-wrap: normal; word-wrap: normal;
background-color: rgba(0, 0, 0, 0.054);
border-radius: 4px; border-radius: 4px;
background-color: hsla(0, 0%, 0%, 0.054);
@media (prefers-color-scheme: dark) {
background-color: hsla(0, 0%, 100%, 0.054);
}
code { code {
margin: 0; margin: 0;

View file

@ -72,7 +72,12 @@
padding-inline-end: 1px; padding-inline-end: 1px;
margin-inline-start: 1px; margin-inline-start: 1px;
margin-inline-end: 1px; margin-inline-end: 1px;
background-color: rgba(255, 247, 0, 0.88); background-color: hsla(58, 100%, 50%, 0.88);
color: inherit;
@media (prefers-color-scheme: dark) {
background-color: hsla(58, 100%, 15%, 0.88);
}
} }
// 设置引用文本为中文引号 // 设置引用文本为中文引号
@ -125,7 +130,11 @@
&:target, &:target,
a:target { a:target {
background-color: #def; background-color: hsl(210, 100%, 93%);
@media (prefers-color-scheme: dark) {
background-color: hsl(210, 40%, 38%);
}
} }
} }
@ -142,9 +151,13 @@
u[title] { u[title] {
cursor: help; cursor: help;
border-block-end-color: rgba(0, 0, 0, 0.54);
border-block-end-width: 3px; border-block-end-width: 3px;
border-block-end-style: double; border-block-end-style: double;
border-block-end-color: hsla(0, 0%, 0%, 0.54);
@media (prefers-color-scheme: dark) {
border-block-end-color: hsla(0, 0%, 100%, 0.54);
}
} }
// 默认禁用中文斜体 https://www.zhihu.com/question/20120243 // 默认禁用中文斜体 https://www.zhihu.com/question/20120243

View file

@ -6,22 +6,34 @@
table { table {
box-sizing: border-box; box-sizing: border-box;
table-layout: fixed; table-layout: fixed;
border-collapse: collapse;
border: 1px solid #ccc;
margin-block-start: $std-block-unit / 2; margin-block-start: $std-block-unit / 2;
margin-block-end: $std-block-unit; margin-block-end: $std-block-unit;
margin-inline-start: auto; margin-inline-start: auto;
margin-inline-end: auto; margin-inline-end: auto;
border-collapse: collapse;
border-width: 1px;
border-style: solid;
border-color: hsl(0, 0%, 80%);
word-break: break-word; word-break: break-word;
@media (prefers-color-scheme: dark) {
border-color: hsl(0, 0%, 25%);
}
} }
th, th,
td { td {
border: 1px solid #ccc;
padding-block-start: $std-block-unit / 4; padding-block-start: $std-block-unit / 4;
padding-block-end: $std-block-unit / 4; padding-block-end: $std-block-unit / 4;
padding-inline-start: $std-inline-unit / 2; padding-inline-start: $std-inline-unit / 2;
padding-inline-end: $std-inline-unit / 2; padding-inline-end: $std-inline-unit / 2;
border-width: 1px;
border-style: solid;
border-color: hsl(0, 0%, 80%);
@media (prefers-color-scheme: dark) {
border-color: hsl(0, 0%, 25%);
}
} }
caption { caption {

View file

@ -70,11 +70,16 @@
// 页脚 // 页脚
#{$root-selector}-fn { #{$root-selector}-fn {
margin-block-start: 59px; margin-block-start: 59px;
border-block-start: 1px solid #ccc; border-block-start: 1px solid;
border-block-start-color: hsl(0, 0%, 80%);
font-size: $font-size-small; font-size: $font-size-small;
font-family: $font-family-hei; font-family: $font-family-hei;
line-height: $line-height-size-normal; line-height: $line-height-size-normal;
@media (prefers-color-scheme: dark) {
border-block-start-color: hsl(0, 0%, 25%);
}
ol { ol {
margin-block-start: $std-block-unit / 2; margin-block-start: $std-block-unit / 2;
margin-block-end: 0; margin-block-end: 0;
@ -82,7 +87,11 @@
li { li {
&:target { &:target {
background-color: #def; background-color: hsl(210, 100%, 93%);
@media (prefers-color-scheme: dark) {
background-color: hsl(210, 40%, 38%);
}
} }
} }
} }

View file

@ -1,6 +1,6 @@
{ {
"name": "heti", "name": "heti",
"version": "0.6.0", "version": "0.7.0",
"description": "赫蹏是专为中文内容展示设计的排版样式增强。它基于通行的中文排版规范而来,可以为网站的读者带来更好的文章阅读体验。", "description": "赫蹏是专为中文内容展示设计的排版样式增强。它基于通行的中文排版规范而来,可以为网站的读者带来更好的文章阅读体验。",
"main": "lib/heti.scss", "main": "lib/heti.scss",
"files": [ "files": [
@ -11,9 +11,10 @@
"scripts": { "scripts": {
"start": "node-sass -w --output-style=expanded lib/heti.scss _site/heti.css", "start": "node-sass -w --output-style=expanded lib/heti.scss _site/heti.css",
"compile": "rollup -c -w", "compile": "rollup -c -w",
"build:site": "node-sass _site/scss/index.scss _site/index.css --output-style=compact",
"build:style": "node-sass lib/heti.scss umd/heti.min.css --output-style=compressed", "build:style": "node-sass lib/heti.scss umd/heti.min.css --output-style=compressed",
"build:script": "rollup -c", "build:script": "rollup -c",
"build": "npm run build:style && npm run build:script", "build": "npm run build:style && npm run build:style && npm run build:script",
"test": "npx stylelint --config package.json 'lib/**/*.scss'" "test": "npx stylelint --config package.json 'lib/**/*.scss'"
}, },
"repository": { "repository": {