@xiee/utils 1.11.5 → 1.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/css/article.css CHANGED
@@ -9,6 +9,7 @@ body, blockquote, .side, .menu { background: #fafafa; }
9
9
  .article-meta .terms, .appendix, .footnotes, main .side > *, .body .side, figcaption, .caption { font-size: .9em; }
10
10
  .single .appendix, .body ~ .appendix, .frontmatter { background: none; }
11
11
  .appendix h2 { border-bottom: 1px dashed #666; }
12
+ a { color: steelblue; }
12
13
  #TOC { top: 0; }
13
14
  #TOC ul { list-style-position: inside; }
14
15
  #TOC > ul {
@@ -17,6 +18,23 @@ body, blockquote, .side, .menu { background: #fafafa; }
17
18
  }
18
19
  #TOC li > ul { padding-left: 1em; }
19
20
  #TOC .numbered { list-style: none; }
21
+ #TOC a {
22
+ text-decoration: none;
23
+ }
24
+ #TOC ul ul {
25
+ border-left: 1px solid lightsteelblue;
26
+ }
27
+ #TOC .active {
28
+ color: limegreen;
29
+ }
30
+ #TOC li li .active {
31
+ border-left: 3px solid;
32
+ margin-left: calc(-1em - 3px);
33
+ padding-left: 1em;
34
+ }
35
+ #TOC li:not(.open) ul {
36
+ display: none;
37
+ }
20
38
  .bg-number {
21
39
  padding: 1px 5px;
22
40
  border-radius: 5px;
@@ -1 +1 @@
1
- .menu,.side,blockquote,body{background:#fafafa}.article-list,.body,.body~.appendix,.embed-left,.embed-right,.frontmatter,.fullwidth,.single .appendix,.single main{margin-top:2em;padding:1em;box-shadow:0 0 8px #ccc;background:#fff}.article-meta{background:#f8f8f8}.appendix,.article-meta .terms,.body .side,.caption,.footnotes,figcaption,main .side>*{font-size:.9em}.body~.appendix,.frontmatter,.single .appendix{background:0 0}.appendix h2{border-bottom:1px dashed #666}#TOC{top:0}#TOC ul{list-style-position:inside}#TOC>ul{padding:0;margin:0}#TOC li>ul{padding-left:1em}#TOC .numbered{list-style:none}.bg-number{padding:1px 5px;border-radius:5px;background:#778899;color:#fff}.side{width:200px;margin:0 auto}.side-left{float:left;clear:left;margin-left:calc(-200px - 2em);position:sticky}.side-right{float:right;clear:right;margin-right:calc(-200px - 2em)}.quote-left,.quote-right{width:45%}.embed-left,.embed-right{margin-top:auto;padding:0}.embed-left,.quote-left{float:left;margin-right:1em}.embed-right,.quote-right{float:right;margin-left:1em}.embed-left{margin-left:calc(-200px - 2em)}.embed-right{margin-right:calc(-200px - 2em)}.embed-left>:first-child,.embed-right>:first-child,.side>:first-child{margin-top:0}.embed-left>:last-child,.embed-right>:last-child{margin-bottom:0}.quote-left>:first-child,.quote-right>:first-child{padding-top:.1px}.quote-left>:last-child,.quote-right>:last-child{padding-bottom:.1px}.fullwidth,.fullwidth *{margin:auto 0}.fullwidth *{max-width:calc(100vw - 4em)}.fullscroll *{max-width:initial}.fullwidth{max-width:calc(100vw - 2em);margin:1em 0 1em 50%;transform:translateX(-50%);float:left;min-width:100%;background:#fff}.fullscroll,.fullscroll .figure,.fullscroll figure{overflow-x:auto}.fullwidth .caption,.fullwidth figcaption{margin-left:calc(50% - 400px);width:800px;padding:1em 1em 0}@media (min-width:1280.02px){.appendix,.article,.body{position:relative}.note-ref{cursor:pointer}.note-ref:hover+.side{display:inline-block;background-color:#f8f8f8;position:absolute;margin-left:1em;padding:.5em;box-sizing:content-box}}@media (max-width:1280px){#TOC{border:1px solid #eee;border-radius:5px;padding:1em;position:initial}.side{width:100%}.body .side,main .side{padding:0 2em;color:#2f4f4f}.side-left,.side-right{clear:both;margin:1em auto;background:0 0}:not(.note-ref)+.side{float:none}.side>:last-child{margin-bottom:0}.embed-left,.embed-right{float:inherit;margin:auto;padding:1em}}@media (max-width:800px){body{padding:initial}.body,main{padding:0 .5em 0}.quote-left,.quote-right{width:inherit;float:inherit;margin:auto}.fullwidth:not(.fullscroll) *{max-width:100%}.fullwidth{margin:initial;transform:initial;float:none;min-width:initial;background:0 0;border:none}.fullwidth .caption,.fullwidth figcaption{margin:initial;padding:initial}}
1
+ .menu,.side,blockquote,body{background:#fafafa}.article-list,.body,.body~.appendix,.embed-left,.embed-right,.frontmatter,.fullwidth,.single .appendix,.single main{margin-top:2em;padding:1em;box-shadow:0 0 8px #ccc;background:#fff}.article-meta{background:#f8f8f8}.appendix,.article-meta .terms,.body .side,.caption,.footnotes,figcaption,main .side>*{font-size:.9em}.body~.appendix,.frontmatter,.single .appendix{background:0 0}.appendix h2{border-bottom:1px dashed #666}a{color:#4682b4}#TOC{top:0}#TOC ul{list-style-position:inside}#TOC>ul{padding:0;margin:0}#TOC li>ul{padding-left:1em}#TOC .numbered{list-style:none}#TOC a{text-decoration:none}#TOC ul ul{border-left:1px solid #b0c4de}#TOC .active{color:#32cd32}#TOC li li .active{border-left:3px solid;margin-left:calc(-1em - 3px);padding-left:1em}#TOC li:not(.open) ul{display:none}.bg-number{padding:1px 5px;border-radius:5px;background:#778899;color:#fff}.side{width:200px;margin:0 auto}.side-left{float:left;clear:left;margin-left:calc(-200px - 2em);position:sticky}.side-right{float:right;clear:right;margin-right:calc(-200px - 2em)}.quote-left,.quote-right{width:45%}.embed-left,.embed-right{margin-top:auto;padding:0}.embed-left,.quote-left{float:left;margin-right:1em}.embed-right,.quote-right{float:right;margin-left:1em}.embed-left{margin-left:calc(-200px - 2em)}.embed-right{margin-right:calc(-200px - 2em)}.embed-left>:first-child,.embed-right>:first-child,.side>:first-child{margin-top:0}.embed-left>:last-child,.embed-right>:last-child{margin-bottom:0}.quote-left>:first-child,.quote-right>:first-child{padding-top:.1px}.quote-left>:last-child,.quote-right>:last-child{padding-bottom:.1px}.fullwidth,.fullwidth *{margin:auto 0}.fullwidth *{max-width:calc(100vw - 4em)}.fullscroll *{max-width:initial}.fullwidth{max-width:calc(100vw - 2em);margin:1em 0 1em 50%;transform:translateX(-50%);float:left;min-width:100%;background:#fff}.fullscroll,.fullscroll .figure,.fullscroll figure{overflow-x:auto}.fullwidth .caption,.fullwidth figcaption{margin-left:calc(50% - 400px);width:800px;padding:1em 1em 0}@media (min-width:1280.02px){.appendix,.article,.body{position:relative}.note-ref{cursor:pointer}.note-ref:hover+.side{display:inline-block;background-color:#f8f8f8;position:absolute;margin-left:1em;padding:.5em;box-sizing:content-box}}@media (max-width:1280px){#TOC{border:1px solid #eee;border-radius:5px;padding:1em;position:initial}.side{width:100%}.body .side,main .side{padding:0 2em;color:#2f4f4f}.side-left,.side-right{clear:both;margin:1em auto;background:0 0}:not(.note-ref)+.side{float:none}.side>:last-child{margin-bottom:0}.embed-left,.embed-right{float:inherit;margin:auto;padding:1em}}@media (max-width:800px){body{padding:initial}.body,main{padding:0 .5em 0}.quote-left,.quote-right{width:inherit;float:inherit;margin:auto}.fullwidth:not(.fullscroll) *{max-width:100%}.fullwidth{margin:initial;transform:initial;float:none;min-width:initial;background:0 0;border:none}.fullwidth .caption,.fullwidth figcaption{margin:initial;padding:initial}}
package/css/book.css ADDED
@@ -0,0 +1,26 @@
1
+ body {
2
+ font-size: 1em;
3
+ font-family: Palatino, Georgia, serif;
4
+ }
5
+ .footnotes, code, .side, .body .side {
6
+ font-size: .85em;
7
+ }
8
+ .frontmatter, .chapter {
9
+ min-height: calc(100vh - 1em);
10
+ }
11
+ .frontmatter {
12
+ background-image: radial-gradient(#b6cee2 1px, #fff 1px);
13
+ background-size: 2em 2em;
14
+ background-color: #fff;
15
+ padding-bottom: 0;
16
+ }
17
+ .frontmatter > div {
18
+ margin: 0 -1em;
19
+ background-color: #ebf6f9;
20
+ padding: 1em;
21
+ }
22
+ .frontmatter .title {
23
+ padding: 20vh 1em 1em;
24
+ margin-top: -1em;
25
+ }
26
+ /* TODO: style for h1.part and printing */
@@ -0,0 +1 @@
1
+ body{font-size:1em;font-family:Palatino,Georgia,serif}.body .side,.footnotes,.side,code{font-size:.85em}.chapter,.frontmatter{min-height:calc(100vh - 1em)}.frontmatter{background-image:radial-gradient(#b6cee2 1px,#fff 1px);background-size:2em 2em;background-color:#fff;padding-bottom:0}.frontmatter>div{margin:0 -1em;background-color:#ebf6f9;padding:1em}.frontmatter .title{padding:20vh 1em 1em;margin-top:-1em}
@@ -5,17 +5,27 @@
5
5
  if (!toc) return;
6
6
  const links = toc.querySelectorAll('a');
7
7
  if (!links.length) return;
8
+ const lis = toc.querySelectorAll('li');
8
9
 
10
+ // record which elements are currently in the viewport
11
+ const ids = [];
9
12
  // create a new Intersection Observer instance
10
13
  const observer = new IntersectionObserver(els => els.forEach(el => {
11
- const id = el.target.id;
12
- id && el.isIntersecting && links.forEach(a => {
13
- a.classList[(a.getAttribute('href') === '#' + id) ? 'add' : 'remove']('active');
14
+ const id = el.target.id, i = ids.indexOf(id);
15
+ el.isIntersecting ? ids.push(id) : (i > -1 && ids.splice(i, 1));
16
+ const n = ids.length;
17
+ if (!n) return;
18
+ links.forEach(a => {
19
+ const action = (a.getAttribute('href') === '#' + ids[n - 1]) ? 'add' : 'remove';
20
+ a.classList[action]('active');
21
+ });
22
+ lis.forEach(li => {
23
+ li.classList[li.querySelector('.active') ? 'add' : 'remove']('open');
14
24
  });
15
25
  }));
16
26
 
17
27
  // observe all section headings
18
28
  d.querySelectorAll('h1,h2,h3,h4,h5,h6').forEach(h => {
19
- h.nodeType === 1 && observer.observe(h);
29
+ h.nodeType === 1 && h.id && observer.observe(h);
20
30
  });
21
31
  })(document);
@@ -1 +1 @@
1
- (e=>{const t=e.querySelector("#TableOfContents, #TOC");if(!t)return;const r=t.querySelectorAll("a");if(!r.length)return;const n=new IntersectionObserver((e=>e.forEach((e=>{const t=e.target.id;t&&e.isIntersecting&&r.forEach((e=>{e.classList[e.getAttribute("href")==="#"+t?"add":"remove"]("active")}))}))));e.querySelectorAll("h1,h2,h3,h4,h5,h6").forEach((e=>{1===e.nodeType&&n.observe(e)}))})(document);
1
+ (e=>{const t=e.querySelector("#TableOfContents, #TOC");if(!t)return;const r=t.querySelectorAll("a");if(!r.length)return;const c=t.querySelectorAll("li"),o=[],n=new IntersectionObserver((e=>e.forEach((e=>{const t=e.target.id,n=o.indexOf(t);e.isIntersecting?o.push(t):n>-1&&o.splice(n,1);const s=o.length;s&&(r.forEach((e=>{const t=e.getAttribute("href")==="#"+o[s-1]?"add":"remove";e.classList[t]("active")})),c.forEach((e=>{e.classList[e.querySelector(".active")?"add":"remove"]("open")})))}))));e.querySelectorAll("h1,h2,h3,h4,h5,h6").forEach((e=>{1===e.nodeType&&e.id&&n.observe(e)}))})(document);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiee/utils",
3
- "version": "1.11.5",
3
+ "version": "1.12.1",
4
4
  "description": "Miscellaneous tools and utilities to manipulate HTML pages",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"