@tdocs/tdocs 1.0.3 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tdocs/tdocs",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Custom Static Site Generator for rapid documentation prototyping",
5
5
  "main": "./build/index.js",
6
6
  "bin": {
@@ -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
- div.textContent = node.title;
52
- div.onclick = () => {
53
- document.querySelectorAll('.tdoc-nav-item').forEach(el => el.classList.remove('tdoc-active'));
54
- div.classList.add('tdoc-active');
55
- contentArea.innerHTML = node.htmlContent;
56
- };
57
-
58
- parentEl.appendChild(div);
59
-
60
- if (node.children && node.children.length > 0) {
61
- renderSidebar(node.children, parentEl);
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
- if (tree.length > 0) {
70
- sidebar.firstChild.click();
91
+ const firstItem = sidebar.querySelector('.tdoc-nav-item');
92
+ if (firstItem) {
93
+ firstItem.click();
71
94
  }
72
95
  </script>
73
96
  </body>
@@ -6,8 +6,8 @@
6
6
  --bg-elevated: #1a1a20;
7
7
  --bg-hover: #1e1e26;
8
8
  --text-color: #e8e8f0;
9
- --text-muted: #888899;
10
- --text-subtle: #555566;
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: 260px;
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: var(--tdoc-indent, 0px);
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;