This repository was archived by the owner on Dec 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 395
feat(toc): add table of contents to overview and guides #230
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d301182
feat(toc): add table of contents to overview and guides
amcdnl d4fe59d
Squashed commit of the following:
amcdnl 0d5d263
Merge branch 'master' into toc
amcdnl 4e68acc
feat(toc): address feedback #167
amcdnl a33fd9d
chore(*): address feedback items
amcdnl db25f6f
Merge branch 'master' into toc
amcdnl 32b431b
feat(toc): address PR feedback
amcdnl 3368cdf
chore(*): remove mutation obvs
amcdnl fef4b11
chore(*): fix lint
amcdnl 5c01747
feat(toc): nit
amcdnl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
<doc-viewer | ||
documentUrl="/assets/documents/overview/{{componentViewer.componentDocItem.id}}.html" | ||
class="docs-component-view-text-content"></doc-viewer> | ||
class="docs-component-view-text-content docs-component-overview" | ||
(contentLoaded)="toc.updateScrollPosition()"> | ||
</doc-viewer> | ||
<table-of-contents #toc container=".mat-sidenav-content"></table-of-contents> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import {Component, Input, OnInit} from '@angular/core'; | ||
import {Router} from '@angular/router'; | ||
|
||
/** | ||
* Header link is a component that handles normalizing | ||
* the anchor jump tags with the current route url. | ||
* | ||
* For example: | ||
* | ||
* <a href="#foo">Foo</a> | ||
* | ||
* would result in the wrong url, this component | ||
* combines the current route with that jump link: | ||
* | ||
* <a href="/guide#foo">Foo</a> | ||
*/ | ||
@Component({ | ||
selector: 'header-link', | ||
template: ` | ||
<a | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this anchor would also benefit from an |
||
title="Link to this heading" | ||
[attr.aria-describedby]="example" | ||
class="docs-markdown-a docs-header-link" | ||
aria-label="Link to this heading" | ||
[href]="url"> | ||
<md-icon>link</md-icon> | ||
</a> | ||
` | ||
}) | ||
export class HeaderLink implements OnInit { | ||
|
||
@Input() example: string; | ||
|
||
url: string; | ||
private _rootUrl: string; | ||
|
||
constructor(router: Router) { | ||
this._rootUrl = router.url.split('#')[0]; | ||
} | ||
|
||
ngOnInit(): void { | ||
this.url = `${this._rootUrl}#${this.example}`; | ||
} | ||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/app/shared/table-of-contents/_table-of-contents-theme.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
@mixin table-of-contents-theme($theme) { | ||
$primary: map-get($theme, primary); | ||
$accent: map-get($theme, accent); | ||
$warn: map-get($theme, warn); | ||
$background: map-get($theme, background); | ||
$foreground: map-get($theme, foreground); | ||
|
||
.docs-toc-container { | ||
border-left: solid 4px mat-color($primary); | ||
|
||
.docs-link { | ||
color: mat-color($foreground, secondary-text); | ||
|
||
&:hover, | ||
&.docs-active { | ||
color: mat-color($primary); | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<div *ngIf="links?.length" class="docs-toc-container"> | ||
<div class="docs-toc-heading">Contents</div> | ||
<nav> | ||
<a [href]="_rootUrl + '#' + link.id" | ||
*ngFor="let link of links; let i = index" | ||
class="docs-level-{{link.type}} docs-link" | ||
[class.docs-active]="link.active"> | ||
{{link.name}} | ||
</a> | ||
</nav> | ||
</div> |
12 changes: 12 additions & 0 deletions
12
src/app/shared/table-of-contents/table-of-contents.module.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {CommonModule} from '@angular/common'; | ||
import {NgModule} from '@angular/core'; | ||
import {TableOfContents} from './table-of-contents'; | ||
import {RouterModule} from '@angular/router'; | ||
|
||
@NgModule({ | ||
imports: [CommonModule, RouterModule], | ||
declarations: [TableOfContents], | ||
exports: [TableOfContents], | ||
entryComponents: [TableOfContents], | ||
}) | ||
export class TableOfContentsModule { } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be nested? Nesting for organization should be avoided
https://github.com/angular/material2/blob/master/CODING_STANDARDS.md#use-lowest-specificity-possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it needs to override the host
top
position.