Skip to content
This repository was archived by the owner on Oct 1, 2018. It is now read-only.

Commit a8311b7

Browse files
committed
rx-marbles integration + responsive updates
1 parent 0e681a0 commit a8311b7

18 files changed

+345
-29
lines changed

src/app/operators/_operator-theme.scss

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,21 @@ $link-color: #2196F3;
99
$accent: mat-color(map-get($theme, accent));
1010
$operator-active-background: rgba($operator-active, .7);
1111

12+
rx-marbles > div {
13+
text-align: center;
14+
min-width: 840px;
15+
16+
circle {
17+
// temp fix: current broken on marble component
18+
filter: none !important;
19+
}
20+
}
21+
22+
app-operator a {
23+
text-decoration: none;
24+
color: $link-color;
25+
}
26+
1227
.operator-list {
1328
a {
1429
border-bottom: 1px solid $operator-border;
@@ -37,9 +52,4 @@ $link-color: #2196F3;
3752
}
3853
}
3954
}
40-
41-
app-operator a {
42-
text-decoration: none;
43-
color: $link-color;
44-
}
4555
}
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1-
<div class="marble-wrapper mat-elevation-z2">
1+
<div
2+
*ngIf="!useInteractiveMarbles"
3+
class="marble-wrapper mat-elevation-z2">
24
<img class="marble-diagram" [src]="url" *ngIf="url"/>
35
</div>
6+
<rx-marbles
7+
*ngIf="useInteractiveMarbles"
8+
[attr.key]="operatorName">
9+
</rx-marbles>

src/app/operators/components/marble-diagram/marble-diagram.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@ import { OperatorParameters } from '../../../../operator-docs';
77
styleUrls: ['./marble-diagram.component.scss']
88
})
99
export class MarbleDiagramComponent {
10+
@Input() operatorName: string;
11+
@Input() useInteractiveMarbles: boolean;
1012
@Input() url: string;
1113
}

src/app/operators/components/operator-examples/operator-examples.component.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
align-items: center;
2525
display: flex;
2626
justify-content: center;
27-
padding: 8px 18px;
27+
padding: 8px 6px 8px 18px;
2828
color: rgba(0, 0, 0, 0.692);
2929
background: #fafafa;
3030

src/app/operators/components/operator-header/operator-header.component.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
@import '../../operator-theme';
22

3+
:host {
4+
position: sticky;
5+
top: 0px;
6+
}
37
.operator-name {
48
font-size:30px;
59
}
@@ -13,3 +17,8 @@ mat-toolbar {
1317
color: rgba(255, 255, 255, 0.87);
1418
font-weight: normal;
1519
}
20+
21+
.operator-header {
22+
position: sticky;
23+
top: 0px;
24+
}

src/app/operators/components/operator/operator.component.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ <h3 class="short-description" [innerHTML]="shortDescription"></h3>
1313
</app-operator-extras>
1414
<app-marble-diagram
1515
class="margin-bottom-32"
16-
[url]="marbleUrl" >
16+
[operatorName]="operatorName"
17+
[useInteractiveMarbles]="useInteractiveMarbles"
18+
[url]="marbleUrl">
1719
</app-marble-diagram>
1820
<app-operator-examples
1921
[operatorExamples]="examples" class="margin-bottom-16">

src/app/operators/components/operator/operator.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ export class OperatorComponent {
2525
return this.operator.marbleUrl;
2626
}
2727

28+
get useInteractiveMarbles() {
29+
return this.operator.useInteractiveMarbles;
30+
}
31+
2832
get shortDescription() {
2933
return this.operator.shortDescription && this.operator.shortDescription.description;
3034
}
Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
<mat-sidenav-container
2-
class="operator-container"
3-
appOperatorScroll
4-
(activeOperator)="activeOperator = $event">
2+
class="operator-container">
53
<mat-sidenav
6-
mode="side"
7-
[opened]="true"
8-
[fixedTopGap]="64"
4+
[mode]="sidenavMode"
5+
[opened]="!smallScreen"
6+
[fixedTopGap]="operatorMenuGap"
97
[fixedInViewport]="true"
10-
class="operator-list-sidenav">
8+
class="operator-list-sidenav"
9+
#operatorSidenav>
1110
<mat-nav-list *ngFor="let category of categories" class="operator-list">
1211
<h3 mat-subheader class="category-subheader">{{ category }}</h3>
1312
<a mat-list-item
1413
*ngFor="let operator of groupedOperators[category]"
15-
[href]="'/operators#' + operator.name"
16-
[class.active-operator]="activeOperator === operator.name">
14+
[href]="'/operators#' + operator.name">
1715
{{ operator.name }}
1816
</a>
1917
</mat-nav-list>
@@ -23,3 +21,13 @@ <h3 mat-subheader class="category-subheader">{{ category }}</h3>
2321
[operator]="operator">
2422
</app-operator>
2523
</mat-sidenav-container>
24+
<button
25+
*ngIf="smallScreen"
26+
mat-mini-fab
27+
color="primary"
28+
class="sidenav-toggle"
29+
[@growInOut]="'in'"
30+
(click)="operatorSidenav.toggle()">
31+
<mat-icon>view_list</mat-icon>
32+
</button>
33+

src/app/operators/operators.component.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,10 @@ $subheader-color: #333;
2020
.operator-list-sidenav {
2121
width: 300px;
2222
}
23+
24+
.sidenav-toggle {
25+
position: fixed;
26+
right: 20px;
27+
bottom: 10px;
28+
z-index: 4;
29+
}

src/app/operators/operators.component.ts

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,52 @@
11
import { Component, OnInit, AfterViewInit, ChangeDetectionStrategy } from '@angular/core';
2+
import { trigger, state, style, animate, transition } from '@angular/animations';
23
import { Router, ActivatedRoute } from '@angular/router';
4+
import { BreakpointObserver } from '@angular/cdk/layout';
35
import { Subscription } from 'rxjs/Subscription';
46
import { Observable } from 'rxjs/Observable';
57
import { ALL_OPERATORS } from '../../operator-docs';
68
import { OperatorDoc } from '../../operator-docs/operator.model';
79

10+
const OPERATOR_MENU_GAP_LARGE = 64;
11+
const OPERATOR_MENU_GAP_SMALL = 54;
12+
813
@Component({
914
selector: 'app-operators',
1015
templateUrl: './operators.component.html',
1116
styleUrls: ['./operators.component.scss'],
12-
changeDetection: ChangeDetectionStrategy.OnPush
17+
animations: [
18+
trigger('growInOut', [
19+
state('in', style({opacity: 1})),
20+
transition('void => *', [
21+
style({
22+
opacity: 0,
23+
transform: 'scale3d(.3, .3, .3)'
24+
}),
25+
animate(`150ms ease-in`)
26+
]),
27+
transition('* => void', [
28+
animate(`150ms ease-out`, style({
29+
opacity: 0,
30+
transform: 'scale3d(.3, .3, .3)'
31+
}))
32+
])
33+
])
34+
]
1335
})
1436
export class OperatorsComponent implements OnInit, AfterViewInit {
1537
public operators = ALL_OPERATORS;
1638
public groupedOperators = groupOperatorsByType(ALL_OPERATORS);
1739
public categories = Object.keys(this.groupedOperators);
18-
public activeOperator: string;
1940

2041
private _subscription: Subscription;
2142

2243
constructor(
44+
private _breakpointObserver: BreakpointObserver,
2345
private _router: Router,
2446
private _activatedRoute: ActivatedRoute
2547
) { }
2648

2749
ngOnInit() {
28-
this.activeOperator = this._activatedRoute.snapshot.fragment || this.operators[0].name;
29-
3050
this._subscription = this._activatedRoute
3151
.fragment
3252
.subscribe(name => this.scrollToOperator(name));
@@ -37,8 +57,8 @@ export class OperatorsComponent implements OnInit, AfterViewInit {
3757
const name = this._activatedRoute.snapshot.fragment;
3858

3959
if (name) {
40-
// wait a tick for scroll to be accurate
41-
Promise.resolve().then(_ => this.scrollToOperator(name));
60+
// slight delay for scroll to be accurate
61+
setTimeout(() => this.scrollToOperator(name), 100);
4262
}
4363
}
4464

@@ -53,6 +73,23 @@ export class OperatorsComponent implements OnInit, AfterViewInit {
5373
element.scrollIntoView();
5474
}
5575
}
76+
77+
get extraSmallScreen() {
78+
return this._breakpointObserver.isMatched('(max-width: 601px)');
79+
}
80+
81+
get smallScreen() {
82+
return this._breakpointObserver.isMatched('(max-width: 901px)');
83+
}
84+
85+
get operatorMenuGap() {
86+
return this.extraSmallScreen ? OPERATOR_MENU_GAP_SMALL : OPERATOR_MENU_GAP_LARGE;
87+
}
88+
89+
get sidenavMode() {
90+
return this.smallScreen ? 'over' : 'side';
91+
}
92+
5693
}
5794

5895
export function groupOperatorsByType(operators: OperatorDoc[]) {

0 commit comments

Comments
 (0)