diff --git a/src/app/app.component.ts b/src/app/app.component.ts index afe96506..0976e9d6 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -27,6 +27,11 @@ export class AppComponent implements OnInit { link: '/', options: { exact: true } }, + { + title: 'MENU.INSTALLATION', + link: '/installation', + options: { exact: true } + }, { title: 'MENU.OPERATORS', link: '/operators', diff --git a/src/app/rxjs/components/installation/installation.component.html b/src/app/rxjs/components/installation/installation.component.html new file mode 100644 index 00000000..87d7d714 --- /dev/null +++ b/src/app/rxjs/components/installation/installation.component.html @@ -0,0 +1,84 @@ +
+

{{'INSTALLATION.TITLE' | translate}}

+ +

{{'INSTALLATION.INTRO' | translate}}:

+ +

ES6 via npm

+ +
npm install rxjs
+ +

{{'INSTALLATION.IMPORT' | translate}}:

+ +

+import Rx from 'rxjs/Rx';
+
+Rx.Observable.of(1,2,3)
+    
+ +

{{'INSTALLATION.PATCHING' | translate}}:

+ +
import ❴ Observable ❵ from 'rxjs/Observable';
+import 'rxjs/add/observable/of';
+import 'rxjs/add/operator/map';
+      
+Observable.of(1,2,3).map(x => x + '!!!'); // etc
+ +

+ +

{{'INSTALLATION.NOTE' | translate}}

+ +
import ❴ Observable ❵ from 'rxjs/Observable';
+import ❴ of ❵ from 'rxjs/observable/of';
+import ❴ map ❵ from 'rxjs/operator/map';
+      
+Observable::of(1,2,3)::map(x => x + '!!!'); // etc
+ +

+ CommonJS via npm +

+ +

+
    +
  1. +

    +
    typings install es6-shim --ambient
    +
  2. +
  3. +

    +
  4. +
  5. +

    +
  6. +
+ +

+ {{'INSTALLATION.ALLMODULETYPES' | translate}} (CJS/ES6/AMD/TypeScript) via npm +

+ +

{{'INSTALLATION.VIAV3' | translate}}:

+ +
npm install @reactivex/rxjs
+ +

{{'INSTALLATION.VIAV2' | translate}}:

+ +
npm install @reactivex/rxjs@5.0.0-beta.1
+ +

+ CDN +

+ +

+ {{'INSTALLATION.FORCDN.PART1' | translate}} + unpkg. + {{'INSTALLATION.FORCDN.PART2' | translate}}: +

+

+ {{'INSTALLATION.FORBETA1' | translate}}: https://unpkg.com/@reactivex/rxjs@version/dist/global/Rx.umd.js +

+

+ {{'INSTALLATION.FORBETA12' | translate}}: https://unpkg.com/@reactivex/rxjs@version/dist/global/Rx.js +

+ +

{{'INSTALLATION.ADDITIONALRESOURCES' | translate}}

+

{{'INSTALLATION.OPERATORS' | translate}}

+
\ No newline at end of file diff --git a/src/app/rxjs/components/installation/installation.component.scss b/src/app/rxjs/components/installation/installation.component.scss new file mode 100644 index 00000000..ff439a52 --- /dev/null +++ b/src/app/rxjs/components/installation/installation.component.scss @@ -0,0 +1,26 @@ +@import '../../../../styles/_colors.scss'; + +.installation { + padding: 40px 20px; + .underlined { + padding-bottom: 20px; + padding-top: 20px; + border-bottom: 1px solid $border-color-lightgrey; + } + code { + color: $code-snippet-color; + display: block; + line-height: 1.5em; + margin: 22px 0; + padding: 10px; + border-radius: 3px; + font-size: 0.85em; + background-color: $code-snippet-background-color; + + &.inline { + display: inline; + background-color: inherit; + font-size: 90%; + } + } +} \ No newline at end of file diff --git a/src/app/rxjs/components/installation/installation.component.spec.ts b/src/app/rxjs/components/installation/installation.component.spec.ts new file mode 100644 index 00000000..22c941dc --- /dev/null +++ b/src/app/rxjs/components/installation/installation.component.spec.ts @@ -0,0 +1,63 @@ +import { + async, + ComponentFixture, + TestBed, + inject +} from '@angular/core/testing'; +import { + TranslateModule, + TranslateLoader, + TranslateService +} from '@ngx-translate/core'; +import { InstallationComponent } from './installation.component'; +import { Observable } from 'rxjs/Observable'; +import { of } from 'rxjs/observable/of'; + +const translations: any = { + INSTALLATION: { + TITLE: 'Installation instructions' + } +}; + +class FakeLoader implements TranslateLoader { + getTranslation(lang: string): Observable { + return of(translations); + } +} + +describe('InstallationComponent', () => { + let component: InstallationComponent; + let fixture: ComponentFixture; + + beforeEach( + async(() => { + TestBed.configureTestingModule({ + declarations: [InstallationComponent], + providers: [TranslateService], + imports: [ + TranslateModule.forRoot({ + loader: { provide: TranslateLoader, useClass: FakeLoader } + }) + ] + }).compileComponents(); + }) + ); + + beforeEach( + inject([TranslateService], (translateService: TranslateService) => { + fixture = TestBed.createComponent(InstallationComponent); + translateService.setDefaultLang('en'); + component = fixture.componentInstance; + fixture.detectChanges(); + }) + ); + + it('should create', () => { + expect(component).toBeTruthy(); + }); + + it('Should show the installation instructions', () => { + const header = fixture.nativeElement.querySelector('h2'); + expect(header.textContent).toMatch('Installation instructions'); + }); +}); diff --git a/src/app/rxjs/components/installation/installation.component.ts b/src/app/rxjs/components/installation/installation.component.ts new file mode 100644 index 00000000..bc40328b --- /dev/null +++ b/src/app/rxjs/components/installation/installation.component.ts @@ -0,0 +1,10 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-installation', + templateUrl: './installation.component.html', + styleUrls: ['./installation.component.scss'] +}) +export class InstallationComponent { + constructor() {} +} diff --git a/src/app/rxjs/rxjs-routing.module.ts b/src/app/rxjs/rxjs-routing.module.ts index d1851594..43f26030 100644 --- a/src/app/rxjs/rxjs-routing.module.ts +++ b/src/app/rxjs/rxjs-routing.module.ts @@ -1,12 +1,18 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { RxjsComponent } from './rxjs.component'; +import { InstallationComponent } from './components/installation/installation.component'; const routes: Routes = [ { path: '', component: RxjsComponent, data: { title: [], description: 'The complete RxJS documentation...' } + }, + { + path: 'installation', + component: InstallationComponent, + data: { title: [], description: 'Installation information...' } } ]; diff --git a/src/app/rxjs/rxjs.component.html b/src/app/rxjs/rxjs.component.html index 28a3c122..2e4607eb 100644 --- a/src/app/rxjs/rxjs.component.html +++ b/src/app/rxjs/rxjs.component.html @@ -1,3 +1,29 @@ -

- rxjs works! -

+
+ + + + + +
+
+

{{'HOME.TITLE' | translate}}

+ +

{{'HOME.DESCRIPTION' | translate}}

+
+ +
+
\ No newline at end of file diff --git a/src/app/rxjs/rxjs.component.scss b/src/app/rxjs/rxjs.component.scss index e69de29b..573a3d28 100644 --- a/src/app/rxjs/rxjs.component.scss +++ b/src/app/rxjs/rxjs.component.scss @@ -0,0 +1,50 @@ +$break-small: 760px; + +.container { + padding: 10px 0; + height: 100%; + + .banner { + margin-top: 20px; + width: 100%; + height: 80%; + text-align: center; + + .title { + font-size: 4rem; + } + + .rxjs { + margin-bottom: 50px; + } + } + + .tiles { + display: flex; + justify-content: center; + margin-top: 50px; + + .tile { + max-width: 30%; + margin-right: 50px; + + .link { + text-decoration: unset; + } + + p { + text-align: justify; + line-height: 1.5; + } + } + + @media screen and (max-width: $break-small) { + flex-direction: column; + align-items: center; + + .tile { + max-width: 80%; + } + } + } +} diff --git a/src/app/rxjs/rxjs.component.ts b/src/app/rxjs/rxjs.component.ts index 4036ae40..b22e3d98 100644 --- a/src/app/rxjs/rxjs.component.ts +++ b/src/app/rxjs/rxjs.component.ts @@ -1,4 +1,5 @@ import { Component } from '@angular/core'; +import { TranslateService } from '@ngx-translate/core'; @Component({ selector: 'app-rxjs', diff --git a/src/app/rxjs/rxjs.module.ts b/src/app/rxjs/rxjs.module.ts index 2cf40db1..345c571f 100644 --- a/src/app/rxjs/rxjs.module.ts +++ b/src/app/rxjs/rxjs.module.ts @@ -1,10 +1,22 @@ import { NgModule } from '@angular/core'; - +import { TranslateModule } from '@ngx-translate/core'; import { RxjsComponent } from './rxjs.component'; import { RxjsRoutingModule } from './rxjs-routing.module'; +import { + MatButtonModule, + MatCardModule, + MatExpansionModule +} from '@angular/material'; +import { InstallationComponent } from './components/installation/installation.component'; @NgModule({ - imports: [RxjsRoutingModule], - declarations: [RxjsComponent] + imports: [ + RxjsRoutingModule, + MatButtonModule, + MatCardModule, + MatExpansionModule, + TranslateModule + ], + declarations: [RxjsComponent, InstallationComponent] }) export class RxjsModule {} diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index 4ee7dd55..549237ee 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -1,6 +1,7 @@ { "MENU": { "HOME": "Home", + "INSTALLATION": "Installation", "OPERATORS": "Operators", "COMPANIES": "Companies", "TEAM": "Team" @@ -27,6 +28,43 @@ "WALKTHROUGH": { "TITLE": "Walkthrough" }, - "NO_TRANSLATION": "Translation not completed. See the description in English" + "NO_TRANSLATION": "Translation not completed. See the description in English" + }, + "HOME": { + "TITLE": "Reactive Extensions Library for JavaScript", + "GETSTARTED": "Get started", + "DESCRIPTION": "RxJS is a library for reactive programming using Observables, to make it easier to compose asynchronous or callback-based code. This project is a rewrite of Reactive-Extensions/RxJS with better performance, better modularity, better debuggable call stacks, while staying mostly backwards compatible, with some breaking changes that reduce the API surface", + "INSTALL": { + "TITLE": "Install it", + "DESCRIPTION": " Find information on how to install RxJs from different sources from npm to CDN" + }, + "LEARN": { + "TITLE": "Learn it", + "DESCRIPTION": "Read the full documentation on Observables, Observer, Subject, etc. In addition, View live examples alongside documentation with diagrams which helps you understand better in action" + } + }, + "INSTALLATION": { + "TITLE": "Installation instructions", + "VIA": "via", + "INTRO": "Here are different ways you can install RxJs", + "IMPORT": "To import the entire core set of functionality", + "PATCHING": "To import only what you need by patching (this is useful for size-sensitive bundling)", + "WITHBIND": "To import what you need and use it with proposed bind operator:", + "NOTE": "Note: This additional syntax requires transpiler support and this syntax may be completely withdrawn from TC39 without notice! Use at your own risk.", + "ERROR": "If you receive an error like error TS2304: Cannot find name 'Promise' or error TS2304: Cannot find name 'Iterable' when using RxJS you may need to install a supplemental set of typings.", + "TYPINGUSERS": "For typings users:", + "NOTINTERFACE": "If you're not using typings the interfaces can be copied from /es6-shim/es6-shim.d.ts.", + "ADDTYPE": "Add type definition file included in tsconfig.json or CLI argument.", + "ALLMODULETYPES": "All Module Types", + "VIAV3": "To install this library via npm version 3, use the following command", + "VIAV2": "If you are using npm version 2 before this library has achieved a stable version, you need to specify the library version explicitly", + "FORCDN": { + "PART1": "For CDN, you can use.", + "PART2": "Just replace version with the current version on the link below" + }, + "FORBETA1": "For RxJS 5.0.0-beta.1 through beta.11", + "FORBETA12": "For RxJS 5.0.0-beta.12 and higher", + "ADDITIONALRESOURCES": "Additional resources", + "OPERATORS": "Operators" } } diff --git a/src/assets/i18n/ru.json b/src/assets/i18n/ru.json index 116bbafa..41ee629c 100644 --- a/src/assets/i18n/ru.json +++ b/src/assets/i18n/ru.json @@ -1,7 +1,8 @@ { "MENU": { "HOME": "Главная", - "OPERATORS": "Операторы", + "INSTALLATION": "Монтаж", + "OPERATORS": "Операторы", "COMPANIES": "Компании", "TEAM": "Команда" }, @@ -28,5 +29,42 @@ "TITLE": "Описание" }, "NO_TRANSLATION": "Перевод не завершен. Смотрите описание на английском языке" + }, + "HOME": { + "TITLE": "Библиотека реактивных расширений для JavaScript", + "GETSTARTED": "Начать", + "DESCRIPTION": "RxJS - библиотека для реактивного программирования с использованием Observables, упростить составление асинхронного или обратного кода. Этот проект является переписью Reactive-Extensions/RxJS с лучшей производительностью, улучшенная модульность, лучшие отлаживаемые стеки вызовов, сохраняя в основном обратную совместимость, с некоторыми нарушениями, которые уменьшают поверхность API", + "INSTALL": { + "TITLE": "Установите его", + "DESCRIPTION": "Найдите информацию о том, как установить RxJs из разных источников из npm to CDN" + }, + "LEARN": { + "TITLE": "Узнать его", + "DESCRIPTION": "Прочтите полную документацию по Observables, Observer, Subject, etc. Кроме того, просмотр живых примеров вместе с документацией с диаграммами, которые помогут вам лучше понять в действии" + } + }, + "INSTALLATION": { + "TITLE": "Инструкция по установке", + "VIA": "с помощью", + "INTRO": "Вот несколько способов установки RxJs", + "IMPORT": "Чтобы импортировать весь основной набор функциональных возможностей", + "PATCHING": "Импортировать только то, что вам нужно, путем исправления (это полезно для сортировки с учетом размера)", + "WITHBIND": "Импортировать то, что вам нужно, и использовать его с bind оператор:", + "NOTE": "Примечание. Этот дополнительный синтаксис требует поддержки транспилеров, и этот синтаксис может быть полностью исключен из TC39 без уведомления! Используйте на свой риск.", + "ERROR": "Если вы получили сообщение об ошибке error TS2304: Cannot find name 'Promise' or error TS2304: Cannot find name 'Iterable' при использовании RxJS вам может потребоваться установить дополнительный набор титров.", + "TYPINGUSERS": "Для typings пользователи:", + "NOTINTERFACE": "Если вы не используете типизацию, интерфейсы могут быть скопированы из /es6-shim/es6-shim.d.ts.", + "ADDTYPE": "Добавить файл определения типа, включенный в tsconfig.json или CLI argument.", + "ALLMODULETYPES": "Все типы модулей", + "VIAV3": "Чтобы установить эту библиотеку через версию npm версии 3, используйте следующую команду", + "VIAV2": "Если вы используете версию npm версии 2 до того, как эта библиотека достигнет стабильной версии, вам необходимо явно указать версию библиотеки", + "FORCDN": { + "PART1": "Для CDN вы можете использовать.", + "PART2": "Просто замените версию текущей версией на ссылку ниже" + }, + "FORBETA1": "Для RxJS 5.0.0-beta.1 through beta.11", + "FORBETA12": "Для RxJS 5.0.0-beta.12 and higher", + "ADDITIONALRESOURCES": "Дополнительные ресурсы", + "OPERATORS": "операторы" } } diff --git a/src/styles/_colors.scss b/src/styles/_colors.scss index c962caad..20bf0e62 100644 --- a/src/styles/_colors.scss +++ b/src/styles/_colors.scss @@ -1,3 +1,7 @@ $icon-color-github: #6f066f; $icon-color-twitter: #4073d4; $icon-color-link: #d81b60; +$code-snippet-background-color: #f5f5f5; +$code-snippet-color: #4d4d4d; +$border-color-lightgrey: #ccc; + diff --git a/src/theme.scss b/src/theme.scss index 9849f6e5..49263760 100644 --- a/src/theme.scss +++ b/src/theme.scss @@ -10,6 +10,10 @@ $theme: mat-light-theme($primary, $accent); @include angular-material-theme($theme); @include operator-theme($theme); +.accent { + color: mat-color($accent); +} + mat-sidenav a.active .mat-list-item-content { color: mat-color($accent); }