Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(toc): add toc to api page #291

Merged
merged 3 commits into from
Oct 30, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about?

1px solid mat-color($foreground, divider);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's a little more in line with intention

}
}
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep the comment?

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);
}
}