-
Notifications
You must be signed in to change notification settings - Fork 0
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 #60 from EngiBeerHub:feature/9-individual-view
Feature/9-individual-view
- Loading branch information
Showing
21 changed files
with
252 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,27 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { RouterModule, Routes } from '@angular/router'; | ||
import { TopPageComponent } from './components/pages/top/top-page.component'; | ||
import { BeerDetailComponent } from './components/pages/beer-detail/beer-detail.component'; | ||
import { HomeComponent } from './components/pages/home/home.component'; | ||
|
||
const routes: Routes = [ | ||
{ path: '', redirectTo: '/top', pathMatch: 'prefix' }, | ||
{ path: 'top', component: TopPageComponent }, | ||
{ | ||
path: '', | ||
component: TopPageComponent, | ||
children: [ | ||
{ path: '', redirectTo: '/home', pathMatch: 'full' }, | ||
{ path: 'home', component: HomeComponent }, | ||
{ path: 'detail', component: BeerDetailComponent }, | ||
], | ||
}, | ||
]; | ||
|
||
@NgModule({ | ||
imports: [RouterModule.forRoot(routes)], | ||
imports: [ | ||
RouterModule.forRoot(routes, { | ||
scrollPositionRestoration: 'top', | ||
}), | ||
], | ||
exports: [RouterModule], | ||
}) | ||
export class AppRoutingModule {} |
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 |
---|---|---|
|
@@ -7,5 +7,6 @@ | |
[beer]="beer" | ||
[imageUrl]="imageUrl" | ||
[error]="error" | ||
(click)="onClickCard(beer!)" | ||
></app-beer-card> | ||
</ng-template> |
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 |
---|---|---|
|
@@ -11,7 +11,9 @@ | |
} | ||
|
||
app-beer-card { | ||
height: 456px; | ||
margin-top: 8px; | ||
max-width: 936px; | ||
cursor: pointer; | ||
} | ||
} |
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
74 changes: 74 additions & 0 deletions
74
src/app/components/pages/beer-detail/beer-detail.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,74 @@ | ||
<div class="container"> | ||
<app-beer-card | ||
class="beer-card" | ||
[beer]="beer" | ||
[imageUrl]="beer.image_url ? beer.image_url : altImageUrl" | ||
></app-beer-card> | ||
|
||
<mat-list> | ||
<mat-list-item> | ||
<span matListItemTitle>First Brewed</span> | ||
<span>{{ beer.first_brewed }}</span> | ||
</mat-list-item> | ||
<mat-divider></mat-divider> | ||
|
||
<mat-list-item> | ||
<span matListItemTitle>Ph</span> | ||
<span>{{ beer.ph }}</span> | ||
</mat-list-item> | ||
<mat-divider></mat-divider> | ||
|
||
<mat-list-item> | ||
<span matListItemTitle>Contributed By</span> | ||
<span>{{ beer.contributed_by }}</span> | ||
</mat-list-item> | ||
<mat-divider></mat-divider> | ||
|
||
<mat-list-item [lines]="matListItemLine"> | ||
<span matListItemTitle>Brewers Tips</span> | ||
<span>{{ beer.brewers_tips }}</span> | ||
</mat-list-item> | ||
<mat-divider></mat-divider> | ||
|
||
<mat-list-item [lines]="matListItemLine"> | ||
<span matListItemTitle>Food Pairing</span> | ||
<span>{{ foodPairings }}</span> | ||
</mat-list-item> | ||
<mat-divider></mat-divider> | ||
|
||
<div mat-subheader> | ||
Ingredients | ||
|
||
<div mat-subheader> | ||
Malt | ||
<div *ngFor="let malt of beer.ingredients.malt"> | ||
<mat-list-item> | ||
<span matListItemTitle>{{ malt.name }}</span> | ||
<span>{{ malt.amount.value }}{{ malt.amount.unit }}</span> | ||
</mat-list-item> | ||
<mat-divider></mat-divider> | ||
</div> | ||
</div> | ||
|
||
<div mat-subheader> | ||
Hops | ||
<div *ngFor="let hop of beer.ingredients.hops"> | ||
<mat-list-item> | ||
<span matListItemTitle>{{ hop.name }}</span> | ||
<span | ||
>{{ hop.amount.value }}{{ hop.amount.unit }}, {{ hop.attribute }}, | ||
added at {{ hop.add }}</span | ||
> | ||
</mat-list-item> | ||
<mat-divider></mat-divider> | ||
</div> | ||
</div> | ||
|
||
<mat-list-item> | ||
<span matListItemTitle>Yeast</span> | ||
<span>{{ beer.ingredients.yeast }}</span> | ||
</mat-list-item> | ||
<mat-divider></mat-divider> | ||
</div> | ||
</mat-list> | ||
</div> |
8 changes: 8 additions & 0 deletions
8
src/app/components/pages/beer-detail/beer-detail.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,8 @@ | ||
.container { | ||
margin-top: -8px; | ||
padding: 0 8px; | ||
|
||
mat-list { | ||
max-width: 100%; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/app/components/pages/beer-detail/beer-detail.component.spec.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,21 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { BeerDetailComponent } from './beer-detail.component'; | ||
|
||
describe('DetailComponent', () => { | ||
let component: BeerDetailComponent; | ||
let fixture: ComponentFixture<BeerDetailComponent>; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [BeerDetailComponent], | ||
}); | ||
fixture = TestBed.createComponent(BeerDetailComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
28 changes: 28 additions & 0 deletions
28
src/app/components/pages/beer-detail/beer-detail.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,28 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { Router } from '@angular/router'; | ||
import { Beer } from 'src/app/models/beer'; | ||
|
||
@Component({ | ||
templateUrl: './beer-detail.component.html', | ||
styleUrls: ['./beer-detail.component.scss'], | ||
}) | ||
export class BeerDetailComponent implements OnInit { | ||
beer!: Beer; | ||
altImageUrl = 'https://images.punkapi.com/v2/keg.png'; | ||
foodPairings!: string; | ||
matListItemLine = 3; // pc default lines | ||
|
||
constructor(private router: Router) {} | ||
|
||
ngOnInit(): void { | ||
this.beer = (history.state as BeerState).beer; | ||
this.foodPairings = this.beer.food_pairing.join(', '); | ||
} | ||
} | ||
|
||
/** | ||
* state passed from parent component | ||
*/ | ||
export interface BeerState { | ||
beer: Beer; | ||
} |
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,9 @@ | ||
<div class="main-content"> | ||
<h1>Today's Beer</h1> | ||
|
||
<app-random-beer></app-random-beer> | ||
|
||
<h1>All Beers</h1> | ||
|
||
<app-beer-list></app-beer-list> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
@use '@angular/material' as mat; | ||
@import '../../../../styles.scss'; | ||
|
||
h1 { | ||
font-size: 32px; | ||
margin-top: 24px; | ||
margin-left: 8px; | ||
color: mat.get-color-from-palette($primary); | ||
} | ||
|
||
app-random-beer { | ||
margin: 0 8px; | ||
} |
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,21 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { HomeComponent } from './home.component'; | ||
|
||
describe('HomeComponent', () => { | ||
let component: HomeComponent; | ||
let fixture: ComponentFixture<HomeComponent>; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [HomeComponent] | ||
}); | ||
fixture = TestBed.createComponent(HomeComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
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,7 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
templateUrl: './home.component.html', | ||
styleUrls: ['./home.component.scss'], | ||
}) | ||
export class HomeComponent {} |
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
Oops, something went wrong.