loppo-theme-doc 1.0.0

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.
Files changed (69) hide show
  1. package/README.md +1 -0
  2. package/favicon.ico +0 -0
  3. package/index.js +3 -0
  4. package/package.json +39 -0
  5. package/postcss.config.js +22 -0
  6. package/sass/generic.scss +140 -0
  7. package/sass/highlight.sass +198 -0
  8. package/sass/highlight.sass.vs2015 +91 -0
  9. package/sass/social.scss +144 -0
  10. package/sass/wangdoc.sass +197 -0
  11. package/scripts/goTop.js +25 -0
  12. package/scripts/hashChange.js +10 -0
  13. package/scripts/index.js +38 -0
  14. package/scripts/insertArticleToc.js +15 -0
  15. package/scripts/menuHandler.js +67 -0
  16. package/scripts/navbarHandler.js +25 -0
  17. package/scripts/setMinHeight.js +31 -0
  18. package/scripts/social-share.js +1110 -0
  19. package/scripts/support.js +13 -0
  20. package/scripts/tocHide.js +19 -0
  21. package/theme/assets/css/app.css +22407 -0
  22. package/theme/assets/css/app.css.map +1 -0
  23. package/theme/assets/css/app.min.css +3 -0
  24. package/theme/assets/css/app.min.css.map +1 -0
  25. package/theme/assets/fonts/iconfont.eot +0 -0
  26. package/theme/assets/fonts/iconfont.svg +88 -0
  27. package/theme/assets/fonts/iconfont.ttf +0 -0
  28. package/theme/assets/fonts/iconfont.woff +0 -0
  29. package/theme/assets/icons/android-icon-144x144.png +0 -0
  30. package/theme/assets/icons/android-icon-192x192.png +0 -0
  31. package/theme/assets/icons/android-icon-36x36.png +0 -0
  32. package/theme/assets/icons/android-icon-48x48.png +0 -0
  33. package/theme/assets/icons/android-icon-72x72.png +0 -0
  34. package/theme/assets/icons/android-icon-96x96.png +0 -0
  35. package/theme/assets/icons/apple-icon-114x114.png +0 -0
  36. package/theme/assets/icons/apple-icon-120x120.png +0 -0
  37. package/theme/assets/icons/apple-icon-144x144.png +0 -0
  38. package/theme/assets/icons/apple-icon-152x152.png +0 -0
  39. package/theme/assets/icons/apple-icon-180x180.png +0 -0
  40. package/theme/assets/icons/apple-icon-57x57.png +0 -0
  41. package/theme/assets/icons/apple-icon-60x60.png +0 -0
  42. package/theme/assets/icons/apple-icon-72x72.png +0 -0
  43. package/theme/assets/icons/apple-icon-76x76.png +0 -0
  44. package/theme/assets/icons/apple-icon-precomposed.png +0 -0
  45. package/theme/assets/icons/apple-icon.png +0 -0
  46. package/theme/assets/icons/browserconfig.xml +2 -0
  47. package/theme/assets/icons/favicon-16x16.png +0 -0
  48. package/theme/assets/icons/favicon-32x32.png +0 -0
  49. package/theme/assets/icons/favicon-96x96.png +0 -0
  50. package/theme/assets/icons/favicon.ico +0 -0
  51. package/theme/assets/icons/manifest.json +41 -0
  52. package/theme/assets/icons/ms-icon-144x144.png +0 -0
  53. package/theme/assets/icons/ms-icon-150x150.png +0 -0
  54. package/theme/assets/icons/ms-icon-310x310.png +0 -0
  55. package/theme/assets/icons/ms-icon-70x70.png +0 -0
  56. package/theme/assets/icons/origin.png +0 -0
  57. package/theme/assets/js/app.js +31 -0
  58. package/theme/assets/js/social-share.min.js +1 -0
  59. package/theme/breadcrumb.template +27 -0
  60. package/theme/chapters.template +43 -0
  61. package/theme/favicon.ico +0 -0
  62. package/theme/favicon.template +9 -0
  63. package/theme/foot.template +7 -0
  64. package/theme/hero.template +11 -0
  65. package/theme/main.template +30 -0
  66. package/theme/nav.template +12 -0
  67. package/theme/page.template +24 -0
  68. package/theme/pre-next.template +24 -0
  69. package/theme/script.template +7 -0
@@ -0,0 +1,197 @@
1
+ // 1. Import the initial variables
2
+ @use "bulma/sass"
3
+ @use "./generic.scss"
4
+ @use "./highlight.sass"
5
+
6
+ /* social-share */
7
+ @use "./social.scss"
8
+
9
+ /*
10
+ * main titles
11
+ */
12
+ .main
13
+ h1
14
+ font-size: sass.$size-1
15
+ h2
16
+ font-size: sass.$size-2
17
+ h3
18
+ font-size: sass.$size-3
19
+
20
+ /*
21
+ * navbar
22
+ */
23
+ .navbar-brand .title
24
+ margin-bottom: 0
25
+
26
+
27
+ /*
28
+ * article font
29
+ */
30
+ .article
31
+ line-height: 1.6
32
+ letter-spacing: 0.04rem
33
+
34
+
35
+ /*
36
+ * article title counter
37
+ */
38
+ .article .content
39
+ counter-reset: firstLevelTitle
40
+
41
+ .article .content > h2::before
42
+ counter-increment: firstLevelTitle
43
+ content: counter(firstLevelTitle) '. '
44
+
45
+ .article .content > h2:only-of-type::before
46
+ content: ''
47
+
48
+ .article .content > h2
49
+ counter-reset: secondLevelTitle
50
+
51
+ .article .content > h3::before
52
+ counter-increment: secondLevelTitle
53
+ content: counter(firstLevelTitle) '.' counter(secondLevelTitle) ' '
54
+
55
+ .article .content .first-level-collapse
56
+ display: none
57
+
58
+ /*
59
+ * article-title
60
+ */
61
+
62
+ article.content h2 a,
63
+ article.content h3 a
64
+ display: none
65
+
66
+ article.content h2:hover a,
67
+ article.content h3:hover a
68
+ display: inline
69
+
70
+ article .page-meta
71
+ margin: 1em auto
72
+ p
73
+ color: var(--bulma-grey-light)
74
+ text-align: right
75
+ font-size: 85%
76
+ a,
77
+ a:hover
78
+ color: var(--bulma-grey-light)
79
+ cursor: default
80
+
81
+ /* page info */
82
+ .page-info
83
+ border-top: 1px solid var(--bulma-grey-light)
84
+ padding-top: 1em
85
+ p
86
+ color: var(--bulma-grey-light)
87
+ line-height: 2
88
+
89
+ /*
90
+ * breadcrumb icon
91
+ */
92
+
93
+ .breadcrumb .icon:last-child,
94
+ .breadcrumb .icon:first-child
95
+ margin-left: 0px
96
+ margin-right: 0px
97
+
98
+ /*
99
+ * previous-next nav
100
+ */
101
+ .level-previous-next
102
+ padding: 1em
103
+ background: var(--bulma-light)
104
+ .level-left, .level-right
105
+ width: 48%
106
+ overflow: hidden
107
+ text-overflow: ellipsis
108
+
109
+ /*
110
+ * article-toc
111
+ */
112
+ .article-toc
113
+ border: 1px solid #aaa
114
+ background-color: #f9f9f9
115
+ display: table
116
+ padding: 1rem
117
+
118
+ .article-toc ul
119
+ margin-left: 0.5rem
120
+ margin-right: 0.5rem
121
+
122
+ .article-toc > ul
123
+ counter-reset: articleTOCFirstLevel
124
+
125
+ .article-toc > ul > li
126
+ list-style-type: none
127
+ counter-reset: articleTOCSecondLevel
128
+
129
+ .article-toc > ul > li::before
130
+ counter-increment: articleTOCFirstLevel
131
+ content: counter(articleTOCFirstLevel) '. '
132
+
133
+ .article-toc > ul > li > ul > li
134
+ list-style-type: none
135
+
136
+ .article-toc > ul > li > ul > li::before
137
+ counter-increment: articleTOCSecondLevel
138
+ content: counter(articleTOCFirstLevel) '.' counter(articleTOCSecondLevel) ' '
139
+
140
+ .toc-controller
141
+ font-size: 80%
142
+ a
143
+ display: inline-block!important
144
+
145
+ .markdownIt-TOC
146
+ animation: fadein 1s
147
+
148
+ @keyframes fadein
149
+ from
150
+ opacity: 0
151
+ to
152
+ opacity: 1
153
+
154
+ /* comments */
155
+ #disqus_thread
156
+ border-top: 1px solid sass.$grey-light
157
+ padding-top: 1em
158
+
159
+ /* menu */
160
+ .panel-menu .panel-block,
161
+ .panel-info .panel-block
162
+ padding: 0.5em 0.75em 0.5em 0em
163
+ padding-left: 0em
164
+ .menu
165
+ font-size: 95%
166
+ width: 100%
167
+ .menu-list
168
+ a
169
+ padding-left: 0em
170
+ display: flex
171
+ word-break: break-all
172
+ .menu-list-title
173
+ width: calc(100% - 1.5rem - 14px - 8px)
174
+ a.is-active
175
+ color: sass.$grey-dark
176
+ background-color: sass.$white-ter
177
+ li
178
+ .icon
179
+ margin-top: -4px
180
+
181
+ /* menu counter */
182
+ .menu-list
183
+ counter-reset: chapter section
184
+ > li
185
+ counter-increment: chapter
186
+ > a .menu-list-title:before
187
+ font-weight: 700
188
+ content: ' ' counter(chapter) '. '
189
+ > ul
190
+ counter-reset: section
191
+ > li
192
+ counter-increment: section
193
+ > a .menu-list-title:before
194
+ font-weight: 700
195
+ content: ' ' counter(chapter) '.' counter(section) ' '
196
+
197
+
@@ -0,0 +1,25 @@
1
+ function addTopElement(title) {
2
+ const text = document.createTextNode(' ');
3
+ title.appendChild(text);
4
+
5
+ const fa = document.createElement('i');
6
+ fa.setAttribute('class', 'fa fa-angle-up');
7
+ const icon = document.createElement('span');
8
+ icon.setAttribute('class', 'icon');
9
+ icon.appendChild(fa);
10
+ const link = document.createElement('a');
11
+ link.setAttribute('href', '#navbar');
12
+ link.appendChild(icon);
13
+
14
+ title.appendChild(link);
15
+ }
16
+
17
+ function goTop() {
18
+ const article = document.querySelector('article.content');
19
+ const h2s = article.querySelectorAll('h2');
20
+ const h3s = article.querySelectorAll('h3');
21
+ h2s.forEach(addTopElement);
22
+ h3s.forEach(addTopElement);
23
+ }
24
+
25
+ module.exports = goTop;
@@ -0,0 +1,10 @@
1
+ /* hashchange handler */
2
+ function hashChange() {
3
+ var hash = location.hash;
4
+ if (!hash) return;
5
+ var nav = document.querySelector('.navbar');
6
+ var navHeight = nav.getBoundingClientRect().height;
7
+ window.scrollBy(0, -1 * navHeight);
8
+ };
9
+
10
+ module.exports = hashChange;
@@ -0,0 +1,38 @@
1
+ var setMinHeight = require('./setMinHeight');
2
+ var insertArticleToc = require('./insertArticleToc');
3
+ var hashChange = require('./hashChange');
4
+ var navbarHandler = require('./navbarHandler');
5
+ var menuHandler = require('./menuHandler');
6
+ var goTop = require('./goTop');
7
+ var support = require('./support');
8
+
9
+ /* set content's min-height */
10
+ setMinHeight();
11
+
12
+ /* add goTop */
13
+ goTop();
14
+
15
+ /* insert article's toc */
16
+ insertArticleToc();
17
+
18
+ /* hashchange handler */
19
+ window.onhashchange = hashChange;
20
+
21
+ /* navabar handler */
22
+ navbarHandler();
23
+
24
+ /* menu handler */
25
+ menuHandler();
26
+
27
+ /* toc controller */
28
+ require('./tocHide');
29
+
30
+ /* social share utilities */
31
+ require('./social-share');
32
+
33
+ /* loading support script */
34
+ support();
35
+
36
+ // 重要!
37
+ // 每次更新此脚本,可以打开或关闭下面这行注释,使得脚本长度发生变化
38
+ // console.log();
@@ -0,0 +1,15 @@
1
+ /* insert article's toc */
2
+ function insertArticleToc() {
3
+ var article = document.querySelector('article.content');
4
+ var firstH2Title = article.querySelector('h2');
5
+ var h2TitleNumber = article.querySelectorAll('h2');
6
+
7
+ if (firstH2Title && LOPPO.article_toc && h2TitleNumber.length >= 2) {
8
+ var toc_div = document.createElement('div');
9
+ toc_div.setAttribute('class', 'article-toc');
10
+ toc_div.innerHTML = '<h5>目录 [<span class="toc-controller toc-controller-show"><a>隐藏</a></span>]</h5>' + LOPPO.article_toc;
11
+ article.insertBefore(toc_div, firstH2Title);
12
+ }
13
+ }
14
+
15
+ module.exports = insertArticleToc;
@@ -0,0 +1,67 @@
1
+ function menuHandler(e) {
2
+ // menu initializing
3
+ const items = [].slice.call(document.querySelectorAll('.menu-list li'));
4
+ const firstLevel = [].slice.call(document.querySelectorAll('.menu-list > li'));
5
+ items.forEach(i => {
6
+ if (i.querySelector('ul')) {
7
+ i.querySelector('ul').style.display = 'none';
8
+ i.querySelector('.icon i').classList.remove('fa-caret-down');
9
+ i.querySelector('.icon i').classList.add('fa-caret-right');
10
+ }
11
+ });
12
+
13
+ let active = null;
14
+ for (let i = 0; i < items.length; i++) {
15
+ const item = items[i];
16
+ if (item.querySelector('a').classList.contains('is-active')) {
17
+ active = item;
18
+ break;
19
+ }
20
+ }
21
+
22
+ if (active) {
23
+ let activeLi = active;
24
+ while (activeLi) {
25
+ if (activeLi.querySelector('ul')) {
26
+ activeLi.querySelector('.icon i').classList.remove('fa-caret-right');
27
+ activeLi.querySelector('.icon i').classList.add('fa-caret-down');
28
+ activeLi.querySelector('.folder').classList.remove('fa-folder-o');
29
+ activeLi.querySelector('.folder').classList.add('fa-folder-open-o');
30
+ activeLi.querySelector('ul').style.display = 'block';
31
+ }
32
+ if (firstLevel.indexOf(activeLi) < 0) {
33
+ activeLi = activeLi.parentNode.parentNode;
34
+ } else {
35
+ break;
36
+ }
37
+ }
38
+ }
39
+
40
+ // icon listener
41
+ const icons = [].slice.call(document.querySelectorAll('.menu li a .icon i'));
42
+ for (let i = 0; i < icons.length; i++) {
43
+ let icon = icons[i];
44
+ const icon_container = icon.parentNode;
45
+ icon_container.addEventListener('click', (e) => {
46
+ e.preventDefault();
47
+ const icon = e.target.querySelector('i') || e.target;
48
+ const childList = icon.parentNode.parentNode.nextElementSibling;
49
+ const folderIcon = icon.parentNode.nextElementSibling;
50
+ if (icon.classList.contains('fa-caret-right')) {
51
+ icon.classList.remove('fa-caret-right');
52
+ icon.classList.add('fa-caret-down');
53
+ folderIcon.classList.remove('fa-folder-o');
54
+ folderIcon.classList.add('fa-folder-open-o');
55
+ childList.style.display = 'block';
56
+ } else {
57
+ icon.classList.add('fa-caret-right');
58
+ icon.classList.remove('fa-caret-down');
59
+ folderIcon.classList.remove('fa-folder-open-o');
60
+ folderIcon.classList.add('fa-folder-o');
61
+ childList.style.display = 'none';
62
+ }
63
+ }, true);
64
+ }
65
+ }
66
+
67
+ module.exports = menuHandler;
@@ -0,0 +1,25 @@
1
+ function navbarHandler() {
2
+ // Get all "navbar-burger" elements
3
+ const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
4
+
5
+ // Check if there are any navbar burgers
6
+ if ($navbarBurgers.length > 0) {
7
+
8
+ // Add a click event on each of them
9
+ $navbarBurgers.forEach( el => {
10
+ el.addEventListener('click', () => {
11
+
12
+ // Get the target from the "data-target" attribute
13
+ const target = el.dataset.target;
14
+ const $target = document.getElementById(target);
15
+
16
+ // Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
17
+ el.classList.toggle('is-active');
18
+ $target.classList.toggle('is-active');
19
+
20
+ });
21
+ });
22
+ }
23
+ }
24
+
25
+ module.exports = navbarHandler;
@@ -0,0 +1,31 @@
1
+ /* set content's min-height */
2
+ function setMinHeight() {
3
+ var content = document.querySelector('.article');
4
+ if (!content) {
5
+ content = document.querySelector('.homepage');
6
+ }
7
+
8
+ var navbarHeight =
9
+ window.getComputedStyle(document.querySelector('.navbar'))
10
+ .getPropertyValue('height');
11
+
12
+ var heroHeight = 0;
13
+ if (document.querySelector('.hero')) {
14
+ var heroHeight =
15
+ window.getComputedStyle(document.querySelector('.hero'))
16
+ .getPropertyValue('height');
17
+ }
18
+
19
+ var footHeight =
20
+ window.getComputedStyle(document.querySelector('.footer'))
21
+ .getPropertyValue('height');
22
+
23
+ var minHeight = document.documentElement.clientHeight
24
+ - parseInt(navbarHeight)
25
+ - parseInt(heroHeight)
26
+ - parseInt(footHeight);
27
+
28
+ content.style.minHeight = minHeight + 'px';
29
+ }
30
+
31
+ module.exports = setMinHeight;