Skip to content

Commit 09489c7

Browse files
author
Chasen Le Hara
committed
Add the bit-toc component
Right now it’s removed and re-added to the DOM every time a new page is loaded. Waiting for bit-docs/bit-docs-html-toc#26 to be implemented. Part of canjs/canjs#4744
1 parent 9647048 commit 09489c7

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

make-example.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ var siteConfig = {
2828
// we get an error without this, here, though
2929
"steal-stache": "^4.0.1",
3030
"steal-conditional": "^0.3.6",
31-
"bit-docs-html-codepen-link": "^1.0.0"
31+
"bit-docs-html-codepen-link": "^1.0.0",
32+
"bit-docs-html-toc": "^1.1.1"
3233
},
3334
staticDist: [
3435
path.join(__dirname, "dist", "static")

static/canjs.js

+12
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,18 @@ function init() {
156156
sidebarViewModel.selectedPageName = window.docObject.name;
157157
}
158158

159+
// Set up the client-side TOC
160+
var tocContainer = document.querySelector("#toc-sidebar");
161+
var oldToc = document.querySelector("bit-toc");
162+
if (oldToc) {
163+
tocContainer.removeChild(oldToc);
164+
}
165+
var newToc = document.createElement("bit-toc");
166+
newToc.depth = window.docObject.outline;
167+
newToc.headingContainerSelector = "#right > article";
168+
newToc.scrollSelector = "#toc-sidebar";
169+
tocContainer.appendChild(newToc);
170+
159171
hasShownSearch = true;
160172
}
161173

static/layout.less

+7-4
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
transition: padding-bottom @transition-speed ease;
66
display:-ms-grid;
77
display: grid;
8-
-ms-grid-columns: 300px 1fr;
9-
grid-template-columns: max-content 1fr;
10-
grid-template-areas: "header header" "left-nav content";
8+
-ms-grid-columns: 300px 1fr 300px;
9+
grid-template-columns: max-content 1fr max-content;
10+
grid-template-areas: "header header header" "nav-sidebar content toc-sidebar";
1111
}
1212
#left {
1313
-ms-grid-row: 2;
1414
-ms-grid-column: 1;
1515
-ms-grid-column-span: 1;
16-
grid-area: left-nav;
16+
grid-area: nav-sidebar;
1717
height: calc(~"100vh - " @brand-height);// 53px header
1818
overflow-y: scroll;
1919
position: fixed;
@@ -40,6 +40,9 @@
4040
.transition-left;
4141
flex-grow: 1;
4242
}
43+
#toc-sidebar {
44+
grid-area: toc-sidebar;
45+
}
4346
.column {
4447
height: 100%;
4548
overflow-y: auto;

templates/content.mustache

+2
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@
2222
{{/with}}
2323

2424
</div>
25+
<div class="column" id="toc-sidebar">
26+
</div>
2527
</div>

0 commit comments

Comments
 (0)