From c9310f17ec7a8a52fa1527bb466f0c908d9438b3 Mon Sep 17 00:00:00 2001 From: Oren Farhi Date: Sun, 29 Apr 2018 19:50:41 +0200 Subject: [PATCH] [RELEASE 3.9.8]: performance and styles (#42)* perf(extractThumb): improved performance by using pipe to extract thumb * perf(parseTracks): now parsing only once * perf(isInQueueuPipe): new pipe for checking media in queue * refactor * updates * updates utils * new menu animations & css utils * version bump --- .angular-cli.json | 6 +- .editorconfig | 13 - CHANGELOG.md | 8 + package.json | 23 +- src/app/app.component.scss | 14 +- src/app/app.component.ts | 8 +- .../app-navbar-menu.component.scss | 53 +- .../app-navbar-menu.component.spec.ts | 15 +- .../app-navbar-menu.component.ts | 38 +- .../app-search/app-search.component.ts | 16 +- .../app-search/app-search.routing.ts | 7 +- src/app/containers/app-search/index.ts | 19 +- .../app-search/player-search/index.ts | 1 + .../player-search.component.ts | 39 +- .../{ => player-search}/player-search.scss | 0 .../app-search/youtube-playlists/index.ts | 1 + .../youtube-playlists.component.ts | 14 +- .../app-search/youtube-videos/index.ts | 1 + .../youtube-videos.component.ts | 4 +- .../{ => youtube-videos}/youtube-videos.scss | 0 .../playlist-view/playlist-view.component.ts | 10 +- .../playlist-view/playlist-view.proxy.ts | 26 +- src/app/core/api/app-player.api.ts | 6 +- src/app/core/api/app.api.ts | 8 +- .../now-playlist-track.component.ts | 55 +- src/app/core/effects/analytics.effects.ts | 22 +- src/app/core/effects/app-player.effects.ts | 56 +- src/app/core/effects/app-settings.effects.ts | 12 +- src/app/core/effects/now-playlist.effects.ts | 106 ++-- src/app/core/effects/player-search.effects.ts | 191 +++--- src/app/core/effects/router.effects.ts | 29 +- src/app/core/effects/user-profile.effects.ts | 35 +- src/app/core/resolvers/playlist.resolver.ts | 14 +- src/app/core/services/analytics.service.ts | 29 +- .../core/services/authorization.service.ts | 99 +-- src/app/core/services/gapi-loader.service.ts | 33 +- src/app/core/services/now-playlist.service.ts | 21 +- src/app/core/services/user-profile.service.ts | 86 +-- .../core/services/version-checker.service.ts | 25 +- src/app/core/services/youtube-api.service.ts | 18 +- .../core/services/youtube-player.service.ts | 11 +- .../services/youtube-videos-info.service.ts | 28 +- src/app/core/services/youtube.search.ts | 12 +- .../now-playlist/now-playlist.selectors.ts | 19 +- .../player-search/player-search.reducer.ts | 11 +- .../user-profile/user-profile.actions.ts | 9 + .../shared/animations/fade-in.animation.ts | 21 + .../components/youtube-list/youtube-list.ts | 14 +- .../youtube-media/youtube-media.html | 32 +- .../youtube-media/youtube-media.scss | 507 ++++++++-------- .../components/youtube-media/youtube-media.ts | 30 +- .../youtube-playlist/youtube-playlist.html | 14 +- .../youtube-playlist/youtube-playlist.scss | 264 ++++---- .../youtube-playlist/youtube-playlist.ts | 19 +- src/app/shared/pipes/index.ts | 8 +- src/app/shared/pipes/isInQueue.pipe.ts | 8 + src/app/shared/pipes/parseTracks.pipe.ts | 13 + .../shared/pipes/toFriendlyDuration.pipe.ts | 41 +- src/app/shared/pipes/videoToThumb.pipe.ts | 12 + src/css/core/animations.scss | 42 ++ src/css/core/responsive.scss | 24 + src/css/core/utils.scss | 146 +++-- src/css/echoes-variables.scss | 570 +++++++++--------- src/css/layout/navbar.scss | 99 ++- src/css/style.scss | 12 +- src/css/themes/arctic.theme.scss | 4 +- src/css/themes/bumblebee.theme.scss | 12 +- src/css/themes/halloween.theme.scss | 18 +- src/index.html | 4 +- src/tsconfig.app.json | 53 +- tslint.json | 2 +- 71 files changed, 1755 insertions(+), 1465 deletions(-) delete mode 100644 .editorconfig create mode 100644 src/app/containers/app-search/player-search/index.ts rename src/app/containers/app-search/{ => player-search}/player-search.component.ts (71%) rename src/app/containers/app-search/{ => player-search}/player-search.scss (100%) create mode 100644 src/app/containers/app-search/youtube-playlists/index.ts rename src/app/containers/app-search/{ => youtube-playlists}/youtube-playlists.component.ts (86%) create mode 100644 src/app/containers/app-search/youtube-videos/index.ts rename src/app/containers/app-search/{ => youtube-videos}/youtube-videos.component.ts (93%) rename src/app/containers/app-search/{ => youtube-videos}/youtube-videos.scss (100%) create mode 100644 src/app/shared/pipes/isInQueue.pipe.ts create mode 100644 src/app/shared/pipes/parseTracks.pipe.ts create mode 100644 src/app/shared/pipes/videoToThumb.pipe.ts create mode 100644 src/css/core/animations.scss create mode 100644 src/css/core/responsive.scss diff --git a/.angular-cli.json b/.angular-cli.json index 024a10c2..d614eecc 100644 --- a/.angular-cli.json +++ b/.angular-cli.json @@ -7,10 +7,7 @@ { "root": "src", "outDir": "dist", - "assets": [ - "assets", - "favicon.ico" - ], + "assets": ["assets", "favicon.ico"], "index": "index.html", "main": "main.ts", "polyfills": "polyfills.ts", @@ -19,6 +16,7 @@ "testTsconfig": "tsconfig.spec.json", "prefix": "app", "styles": [ + "../node_modules/font-awesome/scss/font-awesome.scss", "css/style.scss" ], "scripts": [], diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 6e87a003..00000000 --- a/.editorconfig +++ /dev/null @@ -1,13 +0,0 @@ -# Editor configuration, see http://editorconfig.org -root = true - -[*] -charset = utf-8 -indent_style = space -indent_size = 2 -insert_final_newline = true -trim_trailing_whitespace = true - -[*.md] -max_line_length = off -trim_trailing_whitespace = false diff --git a/CHANGELOG.md b/CHANGELOG.md index 332105d5..cf3737a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## v 3.9.8 (2018/04/29) (codename: Adi) + +* [PERF] - performance optimization using pipes with function utils +* [NEW] - cards videos & playlists rounded styles +* [UPGRADE] - app menu with animation in/out +* [REFACTOR] - using now more css utils to reduce css code +* [REFACTOR] - app-search component restructure + ## v 3.9.7 (2018/03/17) * [NEW] - added "Developed With YouTube" badge diff --git a/package.json b/package.json index fad50da4..00c71948 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "echoes-player", - "version": "3.9.7", + "version": "3.9.8", "license": "MIT", "scripts": { "ng": "ng", @@ -33,15 +33,17 @@ "@angular/platform-browser": "5.2.7", "@angular/platform-browser-dynamic": "5.2.7", "@angular/router": "5.2.7", - "@ngrx/router": "1.0.0-beta.2", "core-js": "^2.4.1", "http-server": "0.10.0", + "memo-decorator": "1.0.1", + "node-sass": "4.7.2", "replace": "0.3.0", "rxjs": "^5.5.2", + "sass-loader": "7.0.1", "zone.js": "^0.8.14" }, "devDependencies": { - "@angular/cli": "^1.6.6", + "@angular/cli": "1.7.4", "@angular/compiler-cli": "5.2.7", "@angular/language-service": "5.2.7", "@ngrx/effects": "5.2.0", @@ -51,17 +53,16 @@ "@types/gapi": "0.0.35", "@types/gapi.auth2": "0.0.46", "@types/gapi.youtube": "3.0.34", - "@types/jasmine": "~2.5.53", + "@types/jasmine": "~2.8.3", "@types/jasminewd2": "~2.0.2", "@types/youtube": "0.0.31", "bootstrap-sass": "3.3.7", "codelyzer": "^4.0.1", "font-awesome": "4.7.0", - "jasmine-core": "~2.6.2", + "jasmine-core": "~2.8.0", "jasmine-spec-reporter": "~4.2.1", - "karma": "~1.7.1", - "karma-chrome-launcher": "~2.1.1", - "karma-cli": "~1.0.1", + "karma": "~2.0.0", + "karma-chrome-launcher": "~2.2.0", "karma-coverage-istanbul-reporter": "^1.2.1", "karma-jasmine": "~1.1.0", "karma-jasmine-html-reporter": "^0.2.2", @@ -70,14 +71,14 @@ "ngrx-store-localstorage": "0.2.4", "ngx-infinite-scroll": "^0.8.2", "ngx-tooltip": "0.0.9", - "ngx-typeahead": "0.1.0", + "ngx-typeahead": "0.2.1", "ngx-youtube-player": "0.1.0", "prettier": "1.11.1", "protractor": "~5.1.2", "rimraf": "2.6.1", "shx": "0.2.2", "ts-node": "~3.2.0", - "tslint": "~5.7.0", - "typescript": "~2.4.2" + "tslint": "~5.9.1", + "typescript": "~2.5.3" } } diff --git a/src/app/app.component.scss b/src/app/app.component.scss index d7aa82d7..b2138190 100644 --- a/src/app/app.component.scss +++ b/src/app/app.component.scss @@ -2,24 +2,18 @@ :host { // DEFAULT THEME - 'arctic' - + background-color: var(--app-bg-color); display: block; height: 100%; - + .container-main { height: 100vh; display: block; - transition: margin .3s ease-out; + transition: margin 0.3s ease-out; margin-left: 0; } } -@media (min-width: 320px) { - :host .container-fluid.container-main { - padding-right: 0; - padding-left: 0; - } -} @media (min-width: 768px) { :host .closed + .container-main { margin-left: $sidebar-closed-width; @@ -29,4 +23,4 @@ :host .container-main { margin-left: $drawer-width; } -} \ No newline at end of file +} diff --git a/src/app/app.component.ts b/src/app/app.component.ts index b15b29d5..95e307ad 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -3,6 +3,7 @@ import { VersionCheckerService } from './core/services/version-checker.service'; import { Component, HostBinding, OnInit } from '@angular/core'; import { EchoesState } from '@store/reducers'; import { getSidebarCollapsed, getAppTheme } from '@store/app-layout'; +import { AppApi } from '@core/api/app.api'; @Component({ selector: 'body', @@ -15,8 +16,13 @@ export class AppComponent implements OnInit { @HostBinding('class') style = 'arctic'; - constructor(private store: Store, private versionCheckerService: VersionCheckerService) { + constructor( + private store: Store, + private versionCheckerService: VersionCheckerService, + private appApi: AppApi + ) { versionCheckerService.start(); + appApi.checkUserAuth(); } ngOnInit() { diff --git a/src/app/containers/app-navbar/app-navbar-menu/app-navbar-menu.component.scss b/src/app/containers/app-navbar/app-navbar-menu/app-navbar-menu.component.scss index 36103e0f..ca4c1d03 100644 --- a/src/app/containers/app-navbar/app-navbar-menu/app-navbar-menu.component.scss +++ b/src/app/containers/app-navbar/app-navbar-menu/app-navbar-menu.component.scss @@ -2,36 +2,6 @@ @media (min-width: 320px) { :host { - @keyframes pulse { - 0% { - transform: scale(0); - opacity: 1; - } - 50% { - transform: scale(1); - opacity: 0.5; - } - 100% { - transform: scale(1.5); - opacity: 0; - } - } - - @keyframes slideInDown { - 0% { - transform: scale(0.4); - opacity: 0; - } - - 100% { - transform: scale(1); - opacity: 1; - } - } - .pulse { - animation: pulse 2s infinite; - } - .btn-toggle { padding: 1rem 1.5rem; font-size: 2rem; @@ -46,22 +16,31 @@ .menu-dropdown { position: absolute; right: 0; - top: -35rem; min-width: 250px; z-index: $zindex-navbar-fixed; + transform-origin: top right; + + &.end-animation { + top: -35rem; + } &.slideInDown { animation: slideInDown 0.5s 1; top: 5rem; transform-origin: top right; } - .menu-backdrop { - position: fixed; - top: 0; - bottom: 0; - right: 0; - left: 0; + &.slideOutDown { + animation: slideOutDown 0.8s 1 forwards; + top: 5rem; + transform-origin: top right; } } + .menu-backdrop { + position: fixed; + top: 0; + bottom: 0; + right: 0; + left: 0; + } } } diff --git a/src/app/containers/app-navbar/app-navbar-menu/app-navbar-menu.component.spec.ts b/src/app/containers/app-navbar/app-navbar-menu/app-navbar-menu.component.spec.ts index ded9179a..8af977b0 100644 --- a/src/app/containers/app-navbar/app-navbar-menu/app-navbar-menu.component.spec.ts +++ b/src/app/containers/app-navbar/app-navbar-menu/app-navbar-menu.component.spec.ts @@ -2,18 +2,21 @@ import { NO_ERRORS_SCHEMA } from '@angular/core'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { AppNavbarMenuComponent } from './app-navbar-menu.component'; +import { NoopAnimationsModule } from '@angular/platform-browser/animations'; describe('AppNavbarMenuComponent', () => { let component: AppNavbarMenuComponent; let fixture: ComponentFixture; - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [AppNavbarMenuComponent], - schemas: [NO_ERRORS_SCHEMA] + beforeEach( + async(() => { + TestBed.configureTestingModule({ + declarations: [AppNavbarMenuComponent], + schemas: [NO_ERRORS_SCHEMA], + imports: [NoopAnimationsModule] + }).compileComponents(); }) - .compileComponents(); - })); + ); beforeEach(() => { fixture = TestBed.createComponent(AppNavbarMenuComponent); diff --git a/src/app/containers/app-navbar/app-navbar-menu/app-navbar-menu.component.ts b/src/app/containers/app-navbar/app-navbar-menu/app-navbar-menu.component.ts index d9cad873..28490c03 100644 --- a/src/app/containers/app-navbar/app-navbar-menu/app-navbar-menu.component.ts +++ b/src/app/containers/app-navbar/app-navbar-menu/app-navbar-menu.component.ts @@ -1,4 +1,13 @@ -import { Component, OnInit, ChangeDetectionStrategy, Input, Output, EventEmitter, HostListener } from '@angular/core'; +import { + Component, + OnInit, + ChangeDetectionStrategy, + Input, + Output, + EventEmitter, + HostListener +} from '@angular/core'; +import { expandFadeInAnimation } from '@shared/animations/fade-in.animation'; enum Key { Backspace = 8, @@ -14,16 +23,19 @@ enum Key { @Component({ selector: 'app-navbar-menu', + animations: [expandFadeInAnimation], template: ` +