Skip to content

Commit dc23581

Browse files
amcdnljelbourn
authored andcommittedOct 30, 2017
feat(api): add table-of-contents to api page (#291)
1 parent 07e7826 commit dc23581

File tree

10 files changed

+57
-31
lines changed

10 files changed

+57
-31
lines changed
 

‎material.angular.io/src/app/pages/component-viewer/_component-viewer-theme.scss

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
.mat-tab-label:focus {
1515
color: mat-color($foreground, text);
1616
}
17+
}
1718

19+
.docs-api-h3 {
20+
border-bottom: 1px solid mat-color($foreground, divider);
1821
}
1922
}

‎material.angular.io/src/app/pages/component-viewer/component-api.html

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,8 @@
33
</span>
44
<doc-viewer
55
documentUrl="/assets/documents/api/{{componentViewer.componentDocItem.id}}.html"
6-
class="docs-component-view-text-content"></doc-viewer>
6+
class="docs-component-view-text-content docs-component-api"
7+
(contentLoaded)="toc.updateScrollPosition()"></doc-viewer>
8+
<table-of-contents #toc
9+
headerSelectors=".docs-api-h3,.docs-api-h4"
10+
container=".mat-drawer-content"></table-of-contents>

‎material.angular.io/src/app/pages/component-viewer/component-api.scss

+24-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,37 @@
11
.docs-api-class-name {
2-
margin-top: 24px;
2+
margin-top: 28px;
33
margin-bottom: 0;
4-
display: inline-block;
4+
display: block;
5+
font-weight: bold;
6+
font-size: 20px;
7+
background: none;
8+
9+
code {
10+
background: none;
11+
}
512
}
613

714
.docs-api-h3 {
8-
margin-bottom: 0;
15+
font-weight: 300;
16+
font-size: 24px;
17+
line-height: 32px;
18+
margin: 40px 0 20px;
19+
padding-bottom: 3px;
920
}
1021

22+
.docs-api-method-name-cell,
23+
.docs-api-method-header,
24+
.docs-api-method-description-cell,
25+
.docs-api-property-description,
1126
.docs-api-class-export-label,
1227
.docs-api-directive-selectors,
28+
.docs-api-class-description,
29+
.docs-api-class-export-name {
30+
font-size: 15px;
31+
}
32+
1333
.docs-api-class-description {
14-
font-size: 14px;
34+
line-height: 24px;
1535
}
1636

1737
.docs-api-class-deprecated-marker {

‎material.angular.io/src/app/pages/component-viewer/component-viewer.scss

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,12 @@ app-component-viewer {
4040

4141
.docs-component-view-text-content {
4242
flex-grow: 1;
43+
width: 100%;
4344
}
4445

46+
.docs-component-api,
4547
.docs-component-overview {
4648
width: 80%;
47-
margin-right: 20px;
4849

4950
@media (max-width: $small-breakpoint-width) {
5051
width: 100%;

‎material.angular.io/src/app/shared/doc-viewer/doc-viewer.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,8 @@ export class DocViewer implements OnDestroy {
8585

8686
Array.prototype.slice.call(exampleElements).forEach((element: Element) => {
8787
let example = element.getAttribute(componentName);
88-
89-
let exampleContainer = document.createElement('div');
90-
element.appendChild(exampleContainer);
91-
9288
let portalHost = new DomPortalHost(
93-
exampleContainer, this._componentFactoryResolver, this._appRef, this._injector);
89+
element, this._componentFactoryResolver, this._appRef, this._injector);
9490
let examplePortal = new ComponentPortal(componentClass, this._viewContainerRef);
9591
let exampleViewer = portalHost.attach(examplePortal);
9692
exampleViewer.instance.example = example;

‎material.angular.io/src/app/shared/table-of-contents/table-of-contents.scss

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
:host {
22
font-size: 13px;
3-
width: 15%;
3+
width: 19%;
44
position: sticky;
55
top: 0;
6+
padding-left: 20px;
7+
box-sizing: border-box;
68
}
79

810
.docs-toc-container {
911
padding: 5px 0 10px 12px;
12+
width: 100%;
1013
}
1114

1215
.docs-toc-heading {
@@ -22,6 +25,9 @@ a {
2225
position: relative;
2326
text-decoration: none;
2427
display: block;
28+
text-overflow: ellipsis;
29+
width: 100%;
30+
overflow: hidden;
2531
}
2632

2733
.docs-level-h4 {

‎material.angular.io/src/styles/_api-theme.scss

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
$background: map-get($theme, background);
99
$foreground: map-get($theme, foreground);
1010
$is-dark-theme: map-get($theme, is-dark);
11-
$exportBackgroundOpacity: if($is-dark-theme, 0.06, 0.03);
1211

1312
.docs-api-method-name-cell {
1413
color: mat-color($primary, 800);
@@ -34,6 +33,6 @@
3433
.docs-api-module-import,
3534
.docs-api-class-selector-name,
3635
.docs-api-class-export-name {
37-
background: rgba(mat-color($foreground, secondary-text), $exportBackgroundOpacity);
36+
background: rgba(mat-color($foreground, secondary-text), 0.06);
3837
}
3938
}

‎material.angular.io/src/styles/_api.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@
6161
font-size: 12px;
6262
}
6363

64-
.docs-api-class-name,
6564
.docs-api-module-import,
6665
.docs-api-class-selector-name,
6766
.docs-api-class-export-name {
67+
font-family: 'Roboto Mono', monospace;
6868
padding: 3px;
6969
}

‎material.angular.io/src/styles/_markdown.scss

+10-14
Original file line numberDiff line numberDiff line change
@@ -64,23 +64,19 @@ pre {
6464
}
6565

6666
.docs-header-link {
67-
// deduct -30px so the anchor icon will be positioned outside
68-
// the content and pad it 30px so the header will set inline
69-
// with the content displayed, absolute position will make
70-
// it where you can't hover the header
71-
padding-left: 30px;
72-
margin-left: -30px;
73-
position: relative;
67+
a {
68+
text-decoration: none;
69+
// deduct -30px so the anchor icon will be positioned outside the content
70+
margin-left: -30px;
71+
display: inline-block;
72+
vertical-align: middle;
73+
}
7474

7575
.material-icons {
76-
display: none;
76+
visibility: hidden;
7777
}
7878

79-
&:hover {
80-
.material-icons {
81-
display: block;
82-
position: absolute;
83-
left: 0;
84-
}
79+
&:hover .material-icons {
80+
visibility: visible;
8581
}
8682
}

‎material.angular.io/src/styles/_tables-theme.scss

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
$background: map-get($theme, background);
99
$foreground: map-get($theme, foreground);
1010
$is-dark-theme: map-get($theme, is-dark);
11-
11+
$tableBorderOpacity: if($is-dark-theme, 0.08, 0.03);
12+
1213
.docs-api table,
1314
.docs-markdown-table {
1415
color: mat-color($foreground, text);
@@ -21,6 +22,6 @@
2122

2223
.docs-api td,
2324
.docs-markdown-td {
24-
border: 1px solid rgba(mat-color($foreground, secondary-text), .03);
25+
border: 1px solid rgba(mat-color($foreground, secondary-text), $tableBorderOpacity);
2526
}
2627
}

0 commit comments

Comments
 (0)
Please sign in to comment.