Skip to content

Commit

Permalink
feat(toc): add toc to api page
Browse files Browse the repository at this point in the history
  • Loading branch information
amcdnl committed Oct 16, 2017
1 parent fd7d5d4 commit acebf51
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 31 deletions.
3 changes: 3 additions & 0 deletions src/app/pages/component-viewer/_component-viewer-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
.mat-tab-label:focus {
color: mat-color($foreground, text);
}
}

.docs-api-h3 {
border-bottom: 1px solid rgba(mat-color($foreground, secondary-text), 0.15);
}
}
6 changes: 5 additions & 1 deletion src/app/pages/component-viewer/component-api.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@
</span>
<doc-viewer
documentUrl="/assets/documents/api/{{componentViewer.componentDocItem.id}}.html"
class="docs-component-view-text-content"></doc-viewer>
class="docs-component-view-text-content docs-component-api"
(contentLoaded)="toc.updateScrollPosition()"></doc-viewer>
<table-of-contents #toc
headerSelectors=".docs-api-h3,.docs-api-h4"
container=".mat-drawer-content"></table-of-contents>
28 changes: 24 additions & 4 deletions src/app/pages/component-viewer/component-api.scss
Original file line number Diff line number Diff line change
@@ -1,17 +1,37 @@
.docs-api-class-name {
margin-top: 24px;
margin-top: 28px;
margin-bottom: 0;
display: inline-block;
display: block;
font-weight: bold;
font-size: 20px;
background: none;

code {
background: none;
}
}

.docs-api-h3 {
margin-bottom: 0;
font-weight: 300;
font-size: 24px;
line-height: 32px;
margin: 40px 0 20px;
padding-bottom: 3px;
}

.docs-api-method-name-cell,
.docs-api-method-header,
.docs-api-method-description-cell,
.docs-api-property-description,
.docs-api-class-export-label,
.docs-api-directive-selectors,
.docs-api-class-description,
.docs-api-class-export-name {
font-size: 15px;
}

.docs-api-class-description {
font-size: 14px;
line-height: 24px;
}

.docs-api-class-deprecated-marker {
Expand Down
3 changes: 2 additions & 1 deletion src/app/pages/component-viewer/component-viewer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@ app-component-viewer {
.docs-component-view-text-content {
display: inline-flex;
flex-grow: 1;
width: 100%;
}

.docs-component-api,
.docs-component-overview {
width: 80%;
margin-right: 20px;

@media (max-width: $small-breakpoint-width) {
width: 100%;
Expand Down
6 changes: 1 addition & 5 deletions src/app/shared/doc-viewer/doc-viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,8 @@ export class DocViewer implements OnDestroy {

Array.prototype.slice.call(exampleElements).forEach((element: Element) => {
let example = element.getAttribute(componentName);

let exampleContainer = document.createElement('div');
element.appendChild(exampleContainer);

let portalHost = new DomPortalHost(
exampleContainer, this._componentFactoryResolver, this._appRef, this._injector);
element, this._componentFactoryResolver, this._appRef, this._injector);
let examplePortal = new ComponentPortal(componentClass, this._viewContainerRef);
let exampleViewer = portalHost.attach(examplePortal);
exampleViewer.instance.example = example;
Expand Down
8 changes: 7 additions & 1 deletion src/app/shared/table-of-contents/table-of-contents.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
:host {
font-size: 13px;
width: 15%;
width: 19%;
position: sticky;
top: 0;
padding-left: 20px;
box-sizing: border-box;
}

.docs-toc-container {
padding: 5px 0 10px 12px;
width: 100%;
}

.docs-toc-heading {
Expand All @@ -22,6 +25,9 @@ a {
position: relative;
text-decoration: none;
display: block;
text-overflow: ellipsis;
width: 100%;
overflow: hidden;
}

.docs-level-h4 {
Expand Down
3 changes: 1 addition & 2 deletions src/styles/_api-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
$background: map-get($theme, background);
$foreground: map-get($theme, foreground);
$is-dark-theme: map-get($theme, is-dark);
$exportBackgroundOpacity: if($is-dark-theme, 0.06, 0.03);

.docs-api-method-name-cell {
color: mat-color($primary, 800);
Expand All @@ -34,6 +33,6 @@
.docs-api-module-import,
.docs-api-class-selector-name,
.docs-api-class-export-name {
background: rgba(mat-color($foreground, secondary-text), $exportBackgroundOpacity);
background: rgba(mat-color($foreground, secondary-text), 0.06);
}
}
2 changes: 1 addition & 1 deletion src/styles/_api.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@
font-size: 12px;
}

.docs-api-class-name,
.docs-api-module-import,
.docs-api-class-selector-name,
.docs-api-class-export-name {
font-family: 'Roboto Mono', monospace;
padding: 3px;
}
23 changes: 9 additions & 14 deletions src/styles/_markdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,18 @@ pre {
}

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

.material-icons {
display: none;
visibility: hidden;
}

&:hover {
.material-icons {
display: block;
position: absolute;
left: 0;
}
&:hover .material-icons {
visibility: visible;
}
}
5 changes: 3 additions & 2 deletions src/styles/_tables-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
$background: map-get($theme, background);
$foreground: map-get($theme, foreground);
$is-dark-theme: map-get($theme, is-dark);

$tableBorderOpacity: if($is-dark-theme, 0.08, 0.03);

.docs-api table,
.docs-markdown-table {
color: mat-color($foreground, text);
Expand All @@ -21,6 +22,6 @@

.docs-api td,
.docs-markdown-td {
border: 1px solid rgba(mat-color($foreground, secondary-text), .03);
border: 1px solid rgba(mat-color($foreground, secondary-text), $tableBorderOpacity);
}
}

0 comments on commit acebf51

Please sign in to comment.