@tdocs/tdocs 1.0.4 → 1.0.5
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/package.json +1 -1
- package/templates/layout.ejs +37 -14
- package/templates/style.css +27 -4
package/package.json
CHANGED
package/templates/layout.ejs
CHANGED
|
@@ -39,35 +39,58 @@
|
|
|
39
39
|
nodes.forEach(node => {
|
|
40
40
|
nodeMap[node.id] = node;
|
|
41
41
|
|
|
42
|
+
const wrapper = document.createElement('div');
|
|
43
|
+
wrapper.className = 'tdoc-nav-wrapper';
|
|
44
|
+
|
|
42
45
|
const div = document.createElement('div');
|
|
43
46
|
div.className = 'tdoc-nav-item';
|
|
44
47
|
div.setAttribute('data-level', node.level);
|
|
45
48
|
div.style.setProperty('--tdoc-indent', `${node.level * 15}px`);
|
|
46
49
|
|
|
50
|
+
div.textContent = node.title;
|
|
51
|
+
wrapper.appendChild(div);
|
|
52
|
+
|
|
47
53
|
if (node.children && node.children.length > 0) {
|
|
48
54
|
div.classList.add('tdoc-has-children');
|
|
49
|
-
|
|
55
|
+
|
|
56
|
+
const childrenDiv = document.createElement('div');
|
|
57
|
+
childrenDiv.className = 'tdoc-nav-children';
|
|
58
|
+
childrenDiv.style.display = 'none';
|
|
50
59
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
div.onclick = () => {
|
|
61
|
+
document.querySelectorAll('.tdoc-nav-item').forEach(el => el.classList.remove('tdoc-active'));
|
|
62
|
+
div.classList.add('tdoc-active');
|
|
63
|
+
contentArea.innerHTML = node.htmlContent;
|
|
64
|
+
|
|
65
|
+
if (div.classList.contains('tdoc-expanded')) {
|
|
66
|
+
div.classList.remove('tdoc-expanded');
|
|
67
|
+
childrenDiv.style.display = 'none';
|
|
68
|
+
} else {
|
|
69
|
+
div.classList.add('tdoc-expanded');
|
|
70
|
+
childrenDiv.style.display = 'block';
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
renderSidebar(node.children, childrenDiv);
|
|
75
|
+
wrapper.appendChild(childrenDiv);
|
|
76
|
+
} else {
|
|
77
|
+
div.onclick = () => {
|
|
78
|
+
document.querySelectorAll('.tdoc-nav-item').forEach(el => el.classList.remove('tdoc-active'));
|
|
79
|
+
div.classList.add('tdoc-active');
|
|
80
|
+
contentArea.innerHTML = node.htmlContent;
|
|
81
|
+
};
|
|
62
82
|
}
|
|
83
|
+
|
|
84
|
+
parentEl.appendChild(wrapper);
|
|
63
85
|
});
|
|
64
86
|
}
|
|
65
87
|
|
|
66
88
|
renderSidebar(tree, sidebar);
|
|
67
89
|
|
|
68
90
|
// Render the first item by default if exists
|
|
69
|
-
|
|
70
|
-
|
|
91
|
+
const firstItem = sidebar.querySelector('.tdoc-nav-item');
|
|
92
|
+
if (firstItem) {
|
|
93
|
+
firstItem.click();
|
|
71
94
|
}
|
|
72
95
|
</script>
|
|
73
96
|
</body>
|
package/templates/style.css
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
--bg-elevated: #1a1a20;
|
|
7
7
|
--bg-hover: #1e1e26;
|
|
8
8
|
--text-color: #e8e8f0;
|
|
9
|
-
--text-muted: #
|
|
10
|
-
--text-subtle: #
|
|
9
|
+
--text-muted: #a6a6ad;
|
|
10
|
+
--text-subtle: #d8d8d8;
|
|
11
11
|
--sidebar-bg: #111115;
|
|
12
12
|
--header-bg: #0a0a0d;
|
|
13
13
|
--header-text: #f0f0f8;
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
|
|
87
87
|
/* ── Sidebar ── */
|
|
88
88
|
.tdoc-sidebar {
|
|
89
|
-
width:
|
|
89
|
+
width: 330px;
|
|
90
90
|
flex-shrink: 0;
|
|
91
91
|
background-color: var(--sidebar-bg);
|
|
92
92
|
padding: 1.5rem 0.75rem;
|
|
@@ -97,6 +97,9 @@
|
|
|
97
97
|
overflow-y: auto;
|
|
98
98
|
scrollbar-width: thin;
|
|
99
99
|
scrollbar-color: var(--text-subtle) transparent;
|
|
100
|
+
display: flex;
|
|
101
|
+
flex-direction: column;
|
|
102
|
+
gap: 20px;
|
|
100
103
|
}
|
|
101
104
|
|
|
102
105
|
.tdoc-sidebar::-webkit-scrollbar {
|
|
@@ -112,7 +115,7 @@
|
|
|
112
115
|
|
|
113
116
|
/* ── Nav Items ── */
|
|
114
117
|
.tdoc-nav-item {
|
|
115
|
-
margin-left:
|
|
118
|
+
margin-left: 15px;
|
|
116
119
|
padding: 6px 10px;
|
|
117
120
|
cursor: pointer;
|
|
118
121
|
color: var(--text-muted);
|
|
@@ -140,6 +143,26 @@
|
|
|
140
143
|
margin-top: 0;
|
|
141
144
|
}
|
|
142
145
|
|
|
146
|
+
.tdoc-nav-item.tdoc-has-children {
|
|
147
|
+
padding-right: 24px;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.tdoc-nav-item.tdoc-has-children::after {
|
|
151
|
+
content: '›';
|
|
152
|
+
position: absolute;
|
|
153
|
+
right: 10px;
|
|
154
|
+
top: 50%;
|
|
155
|
+
transform: translateY(-50%);
|
|
156
|
+
font-size: 1.2rem;
|
|
157
|
+
line-height: 1;
|
|
158
|
+
color: var(--text-subtle);
|
|
159
|
+
transition: transform 0.2s ease;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.tdoc-nav-item.tdoc-has-children.tdoc-expanded::after {
|
|
163
|
+
transform: translateY(-50%) rotate(90deg);
|
|
164
|
+
}
|
|
165
|
+
|
|
143
166
|
.tdoc-nav-item[data-level="2"] {
|
|
144
167
|
font-size: 0.85rem;
|
|
145
168
|
font-weight: 400;
|