-
-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from trungk18/trung/standalone-components
Angular standalone components 😏
- Loading branch information
Showing
27 changed files
with
227 additions
and
285 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
import { Component } from '@angular/core'; | ||
import { AngularTetrisComponent } from './containers/angular-tetris/angular-tetris.component'; | ||
|
||
@Component({ | ||
selector: 'app-root', // eslint-disable-line @angular-eslint/component-selector | ||
templateUrl: './app.component.html', | ||
standalone: true, | ||
selector: 'app-root',//eslint-disable-line | ||
imports: [AngularTetrisComponent], | ||
template: '<angular-tetris></angular-tetris>', | ||
styleUrls: ['./app.component.scss'] | ||
}) | ||
export class AppComponent {} |
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { AsyncPipe, NgFor } from '@angular/common'; | ||
import { Component } from '@angular/core'; | ||
import { Tile, TileValue } from '@trungk18/interface/tile/tile'; | ||
import { TetrisService } from '@trungk18/state/tetris/tetris.service'; | ||
import { Observable } from 'rxjs'; | ||
import { map } from 'rxjs/operators'; | ||
import { TileComponent } from '../tile/tile.component'; | ||
|
||
@Component({ | ||
selector: 't-hold', | ||
standalone: true, | ||
imports: [NgFor, TileComponent, AsyncPipe], | ||
templateUrl: './hold.component.html', | ||
styleUrls: ['./hold.component.scss'] | ||
}) | ||
export class HoldComponent implements OnInit { | ||
hold$: Observable<Tile[][]>; | ||
constructor(private _tetrisService: TetrisService) {} | ||
export class HoldComponent { | ||
hold$: Observable<Tile[][]> = this._tetrisService.hold$.pipe( | ||
map((piece) => piece.next.map((row) => row.map((value) => new Tile(value as TileValue)))) | ||
); | ||
|
||
ngOnInit(): void { | ||
this.hold$ = this._tetrisService.hold$.pipe( | ||
map((piece) => piece.next.map((row) => row.map((value) => new Tile(value as TileValue)))) | ||
); | ||
} | ||
constructor(private _tetrisService: TetrisService) {} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,19 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { Observable } from 'rxjs'; | ||
import { Speed } from '@trungk18/interface/speed'; | ||
import { AsyncPipe, NgIf } from '@angular/common'; | ||
import { Component } from '@angular/core'; | ||
import { TetrisQuery } from '@trungk18/state/tetris/tetris.query'; | ||
import { NumberComponent } from '../number/number.component'; | ||
|
||
@Component({ | ||
selector: 't-level', | ||
standalone: true, | ||
imports: [AsyncPipe, NgIf, NumberComponent], | ||
templateUrl: './level.component.html', | ||
styleUrls: ['./level.component.scss'] | ||
}) | ||
export class LevelComponent implements OnInit { | ||
speed$: Observable<Speed>; | ||
initSpeed$: Observable<Speed>; | ||
hasCurrent$: Observable<boolean>; | ||
|
||
export class LevelComponent { | ||
constructor(private _query: TetrisQuery) {} | ||
|
||
ngOnInit(): void { | ||
this.speed$ = this._query.speed$; | ||
this.hasCurrent$ = this._query.hasCurrent$; | ||
this.initSpeed$ = this._query.initSpeed$; | ||
} | ||
speed$ = this._query.speed$; | ||
hasCurrent$ = this._query.hasCurrent$; | ||
initSpeed$ = this._query.initSpeed$; | ||
} |
Oops, something went wrong.