Skip to content

Commit bb6c36e

Browse files
authored
Merge pull request #492 from ember-learn/table-contents-styling
Move table of contents styling into concepts
2 parents 5328316 + 1a7cba5 commit bb6c36e

File tree

4 files changed

+106
-2
lines changed

4 files changed

+106
-2
lines changed

.stylelintrc.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ module.exports = {
1212
'color-hex-length': 'long',
1313
// Disallow ids
1414
'selector-max-id': 0,
15-
// Enforce alphabetical ordering of properties
16-
'order/properties-alphabetical-order': true,
1715
// Require that color, background-color, etc use variables for colors, instead of direct values
1816
'scale-unlimited/declaration-strict-value': [
1917
['/color/'] // We can enforce variables for font-size, margin, etc as well by adding here

addon/styles/addon.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
@import 'icon.css';
1515
@import 'sidebar-container.css';
1616
@import 'well.css';
17+
@import 'table-of-contents.css';
1718
@import 'header-anchor';
1819

1920
/* Helpers */

addon/styles/table-of-contents.css

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
.table-of-contents {
2+
list-style-type: none;
3+
padding-left: 0;
4+
font-size: var(--font-size-base);
5+
font-weight: var(--font-weight-3);
6+
}
7+
8+
.sub-table-of-contents {
9+
padding-left: var(--spacing-1);
10+
font-size: var(--font-size-base);
11+
font-weight: var(--font-weight-2);
12+
}
13+
14+
.sub-table-of-contents .sub-table-of-contents {
15+
padding-left: var(--spacing-3);
16+
margin-bottom: 0;
17+
}
18+
19+
.table-of-contents li.toc-heading {
20+
margin-top: var(--spacing-4);
21+
color: var(--color-gray-600);
22+
}
23+
24+
.table-of-contents li.toc-heading:first-child {
25+
margin-top: 0;
26+
}
27+
28+
.table-of-contents li {
29+
margin: 3px 0;
30+
list-style-type: none;
31+
}
32+
33+
.table-of-contents a:link {
34+
background: none;
35+
}
36+
37+
.sub-table-of-contents .toc-item a {
38+
display: block;
39+
padding: var(--spacing-1);
40+
border-radius: var(--radius);
41+
line-height: var(--line-height-xs);
42+
color: var(--color-gray-700);
43+
border-left: 0 solid transparent;
44+
transition: border-width 0.3s;
45+
}
46+
47+
.sub-table-of-contents .toc-item a:hover {
48+
border-left: 4px solid var(--color-gray-400);
49+
border-radius: 0;
50+
}
51+
52+
.sub-table-of-contents .toc-item.selected > a,
53+
.sub-table-of-contents .toc-item > a.active {
54+
border-left: 4px solid var(--color-brand-hc-dark);
55+
border-radius: 0;
56+
}
57+
58+
@media (max-width: 844px) {
59+
.table-of-contents {
60+
font-size: var(--font-size-lg);
61+
}
62+
}

docs/concepts/table-of-contents.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Table of Contents
2+
3+
Instead of providing a component we provide this concept for our table of contents. You can see the concept below.
4+
Every item in the list is either a `toc-heading`, giving it heading styling, or an `toc-item`. The `anchor`-tags wrapped in a `toc-item` will get specific styling. On the main level, not wrapped in a `sub-table-of-contents`, they will be the brand-color. When they are wrapped in a `sub-table-of-contents`, they will have an "active" indicator and a hover state, this will also indent them from the main level.
5+
6+
```html
7+
<ul class="table-of-contents">
8+
<li class="toc-heading">Introduction</li>
9+
<li class="toc-item">
10+
<a href="#">Getting Started</a>
11+
</li>
12+
<li class="toc-item">
13+
<a href="#">Tutorial</a>
14+
</li>
15+
<li class="toc-heading">Core Concepts</li>
16+
<li class="toc-item">
17+
<a href="#">Components</a>
18+
</li>
19+
<li class="toc-item">
20+
<a href="#"> Routing </a>
21+
<ul class="table-of-contents sub-table-of-contents">
22+
<li class="toc-item">
23+
<a href="#">Introduction</a>
24+
</li>
25+
<li class="toc-item">
26+
<a href="#">Defining Your Routes</a>
27+
</li>
28+
<li class="toc-item selected">
29+
<a href="#">Linking Between Routes</a>
30+
</li>
31+
</ul>
32+
</li>
33+
<li class="toc-item">
34+
<a href="#">Services</a>
35+
</li>
36+
<li class="toc-item">
37+
<a href="#">EmberData</a>
38+
</li>
39+
<li class="toc-item">
40+
<a href="#">In-Depth Topics</a>
41+
</li>
42+
</ul>
43+
```

0 commit comments

Comments
 (0)