This repository was archived by the owner on Oct 1, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 62
feat(operators): add support for vendor specific examples in operator docs #210
Open
btroncone
wants to merge
5
commits into
ReactiveX:master
Choose a base branch
from
btroncone:vendor-examples
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3560ebd
feat(operators): add support for vendor specific examples in operator…
btroncone bea6aff
fix(operators): remove unused property from template
btroncone 250cde0
fix(operators): fixed typo in operators template
btroncone b2cb3d8
Merge branch 'master' into vendor-examples
btroncone 6ce690f
style(material): added missing comma to material module
btroncone 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
This file contains 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 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 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
18 changes: 13 additions & 5 deletions
18
src/app/operators/components/operator-examples/operator-examples.component.html
This file contains 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,14 +1,22 @@ | ||
<h2> Examples </h2> | ||
<div class="code-example" *ngFor="let example of operatorExamples" appHighlightJs> | ||
<div class="code-example" | ||
*ngFor="let example of operatorExamples" | ||
appHighlightJs> | ||
<div class="code-block mat-elevation-z2"> | ||
<div class="example-header"> | ||
<div class="header-title" [innerHTML]="example.name"></div> | ||
<button mat-icon-button (click)="copyToClipboard.emit(example.code)" value="Copy" aria-label="Copy" matTooltip="Copy"> | ||
<div class="header-title" | ||
[innerHTML]="example.name"></div> | ||
<button mat-icon-button | ||
(click)="copyToClipboard.emit(example.code)" | ||
value="Copy" | ||
aria-label="Copy" | ||
matTooltip="Copy"> | ||
<mat-icon>content_copy</mat-icon> | ||
</button> | ||
</div> | ||
<div class="bin-wrapper"> | ||
<iframe [src]="example.externalLink.url | safeUrl" [title]="example.name"></iframe> | ||
<div class="frame-wrapper"> | ||
<iframe [src]="example.externalLink.url | safeUrl" | ||
[title]="example.name"></iframe> | ||
</div> | ||
</div> | ||
</div> |
This file contains 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
16 changes: 0 additions & 16 deletions
16
src/app/operators/components/operator-extras/operator-extras.component.scss
This file contains 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,17 +1 @@ | ||
.extra-tip { | ||
display: flex; | ||
} | ||
|
||
h3 { | ||
display: inline-block; | ||
vertical-align: middle; | ||
padding-left: 10px; | ||
} | ||
|
||
.tip-warning { | ||
color: rgb(244, 67, 54); | ||
} | ||
|
||
.tip-info { | ||
color: rgb(33, 150, 243); | ||
} |
34 changes: 34 additions & 0 deletions
34
src/app/operators/components/operator-general/operator-general.component.html
This file contains 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,34 @@ | ||
<section class="main-operator-container mat-typography"> | ||
<h3 class="short-description" | ||
[innerHTML]="operator?.shortDescription?.description"> | ||
</h3> | ||
<app-operator-extras class="margin-bottom-16" | ||
*ngIf="operator?.shortDescription" | ||
[operatorExtras]="operator?.shortDescription?.extras"> | ||
</app-operator-extras> | ||
<app-marble-diagram class="margin-bottom-32" | ||
[operatorName]="operator?.name" | ||
[useInteractiveMarbles]="operator?.useInteractiveMarbles" | ||
[url]="operator?.marbleUrl"> | ||
</app-marble-diagram> | ||
<app-operator-examples [operatorExamples]="operator?.examples" | ||
(copyToClipboard)="copyToClipboard($event)" | ||
class="margin-bottom-16"> | ||
</app-operator-examples> | ||
<app-operator-parameters [operatorParameters]="operator?.parameters" | ||
*ngIf="operator?.parameters?.length"> | ||
</app-operator-parameters> | ||
<app-operator-walkthrough class="margin-bottom-16" | ||
[operatorWalkthrough]="operator?.walkthrough?.description"> | ||
</app-operator-walkthrough> | ||
<app-operator-extras class="margin-bottom-16" | ||
*ngIf="operator?.walkthrough?.extras" | ||
[operatorExtras]="operator?.walkthrough?.extras"> | ||
</app-operator-extras> | ||
<app-related-operators [relatedOperators]="operator?.relatedOperators"> | ||
</app-related-operators> | ||
<app-additional-resources [additionalResources]="operator?.additionalResources" | ||
[sourceUrl]="sourceUrl" | ||
[specsUrl]="specsUrl"> | ||
</app-additional-resources> | ||
</section> |
1 change: 1 addition & 0 deletions
1
src/app/operators/components/operator-general/operator-general.component.scss
This file contains 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 @@ | ||
|
61 changes: 61 additions & 0 deletions
61
src/app/operators/components/operator-general/operator-general.component.ts
This file contains 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,61 @@ | ||
import { | ||
Component, | ||
Input, | ||
OnInit, | ||
OnDestroy, | ||
ViewEncapsulation | ||
} from '@angular/core'; | ||
import { OperatorDoc, ALL_OPERATORS } from '../../../../operator-docs'; | ||
import { CopierService } from '../../../core/services/copier.service'; | ||
import { MatSnackBar } from '@angular/material'; | ||
import { OperatorComponent } from '../operator/operator.component'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
import { takeUntil } from 'rxjs/operators/takeUntil'; | ||
import { Subject } from 'rxjs/Subject'; | ||
|
||
@Component({ | ||
selector: 'app-operator-general', | ||
templateUrl: './operator-general.component.html', | ||
styleUrls: ['./operator-general.component.scss'], | ||
encapsulation: ViewEncapsulation.None | ||
}) | ||
export class OperatorGeneralComponent implements OnInit, OnDestroy { | ||
public operator: OperatorDoc; | ||
private _onDestroy = new Subject(); | ||
private readonly baseSourceUrl = 'https://github.com/ReactiveX/rxjs/blob/master/src/operators/'; | ||
private readonly baseSpecUrl = 'http://reactivex.io/rxjs/test-file/spec-js/operators'; | ||
|
||
constructor( | ||
private _operatorComponent: OperatorComponent, | ||
private _activateRoute: ActivatedRoute, | ||
private _copierService: CopierService, | ||
private _snackBar: MatSnackBar | ||
) {} | ||
|
||
ngOnInit() { | ||
this._activateRoute.params.pipe(takeUntil(this._onDestroy)).subscribe(_ => { | ||
this.operator = this._operatorComponent.operator; | ||
}); | ||
} | ||
|
||
copyToClipboard(code: string) { | ||
this._copierService.copyText(code); | ||
this._snackBar.open( | ||
'The example has been copied to your clipboard!', | ||
null, | ||
{ duration: 3000 } | ||
); | ||
} | ||
|
||
get sourceUrl() { | ||
return `${this.baseSourceUrl}/${this.operator.name}.ts`; | ||
} | ||
|
||
get specsUrl() { | ||
return `${this.baseSpecUrl}/${this.operator.name}-spec.js.html`; | ||
} | ||
|
||
ngOnDestroy() { | ||
this._onDestroy.next(); | ||
} | ||
} |
6 changes: 1 addition & 5 deletions
6
src/app/operators/components/operator-header/operator-header.component.scss
This file contains 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
13 changes: 13 additions & 0 deletions
13
...app/operators/components/operator-vendor-examples/operator-vendor-examples.component.html
This file contains 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,13 @@ | ||
<section class="main-operator-container mat-typography margin-top-32"> | ||
<div class="code-example" | ||
*ngFor="let example of examples"> | ||
<h2> {{ example.name }} </h2> | ||
<p> {{ example.description }} </p> | ||
<div class="mat-elevation-z2"> | ||
<div class="frame-wrapper"> | ||
<iframe [src]="example.externalLink.url | safeUrl" | ||
[title]="example.name"></iframe> | ||
</div> | ||
</div> | ||
</div> | ||
</section> |
6 changes: 6 additions & 0 deletions
6
...app/operators/components/operator-vendor-examples/operator-vendor-examples.component.scss
This file contains 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,6 @@ | ||
$stackblitz-blue: #0077cf; | ||
$stackblitz-grey: #353535; | ||
|
||
.frame-wrapper { | ||
background-color: $stackblitz-blue; | ||
} |
35 changes: 35 additions & 0 deletions
35
src/app/operators/components/operator-vendor-examples/operator-vendor-examples.component.ts
This file contains 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,35 @@ | ||
import { Component, OnInit, OnDestroy, Input } from '@angular/core'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
import { OperatorComponent } from '../operator/operator.component'; | ||
import { Subject } from 'rxjs/Subject'; | ||
import { takeUntil } from 'rxjs/operators/takeUntil'; | ||
import { VendorExample } from '../../../../operator-docs'; | ||
|
||
@Component({ | ||
selector: 'app-operator-vendor-examples', | ||
templateUrl: './operator-vendor-examples.component.html', | ||
styleUrls: ['./operator-vendor-examples.component.scss'] | ||
}) | ||
export class OperatorVendorExamplesComponent implements OnInit, OnDestroy { | ||
public examples: VendorExample[] = []; | ||
private _onDestroy = new Subject(); | ||
|
||
constructor( | ||
private _operatorComponent: OperatorComponent, | ||
private _activedRoute: ActivatedRoute | ||
) {} | ||
|
||
ngOnInit() { | ||
this._activedRoute.params.pipe(takeUntil(this._onDestroy)).subscribe(p => { | ||
this.examples = this._operatorComponent.operator.vendorExamples.filter( | ||
e => { | ||
return e.vendorName === p['vendor']; | ||
} | ||
); | ||
}); | ||
} | ||
|
||
ngOnDestroy() { | ||
this._onDestroy.next(); | ||
} | ||
} |
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.
from a performance point of view it would be better to declare pipes for these transformations, to prevent unnecessary recalculation. Don't know if this will make a huge difference but it won't hurt really