-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add recipe-list and recipe-search components - Replace home component with recipe-search - Add searchRecipes method to recipe service - Add SearchRecipes method to RecipeController gh-16 Co-authored-by: Syed Zaidi <[email protected]> Co-authored-by: Zubair Shibly <[email protected]>
- Loading branch information
1 parent
e3b1110
commit 1f9b5dd
Showing
16 changed files
with
191 additions
and
48 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 was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<ng-container *ngIf="recipeList.length != 0"> | ||
<ng-container *ngIf="recipeList.length == 1; else moreThanOne"> | ||
<h3>There is {{ recipeList.length }} recipe in the list.</h3> | ||
<div *ngFor="let recipe of recipeList"> | ||
<a [routerLink]="['/recipe', recipe.id]">{{ recipe.name }}</a> | ||
</div> | ||
</ng-container> | ||
<ng-template #moreThanOne> | ||
<h3> | ||
There are {{ recipeList.length }} recipes in the list that contain the term | ||
'{{ searchedQuery }}' | ||
</h3> | ||
<div *ngFor="let recipe of recipeList"> | ||
<a>{{ recipe.name }}</a> | ||
</div> | ||
</ng-template> | ||
</ng-container> | ||
|
||
<!-- TODO (NilinReza): handle 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.center-container { | ||
display: flex; | ||
align-items: center; | ||
height: 10vh; /* This will take the full height of the viewport */ | ||
} | ||
|
||
.form-control { | ||
border-radius: 25px; /* Rounded edges */ | ||
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); /* Shadow effect */ | ||
padding-left: 35px; /* Make room for the search icon */ | ||
width: 50vw; /* Increase the width of the search bar to 70% of the viewport width */ | ||
} | ||
.form-outline { | ||
position: relative; /* Allow the search icon and filter button to be positioned relative to this element */ | ||
margin-top: 10px; | ||
margin-bottom: 10px; /* Add space after the search bar */ | ||
} | ||
.form-outline i { | ||
position: absolute; | ||
left: 10px; | ||
top: 50%; | ||
transform: translateY(-50%); /* Vertically center the search icon */ | ||
} |
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,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { RecipeListComponent } from './recipe-list.component'; | ||
|
||
describe('RecipeListComponent', () => { | ||
let component: RecipeListComponent; | ||
let fixture: ComponentFixture<RecipeListComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [RecipeListComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(RecipeListComponent); | ||
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,16 @@ | ||
import { Component, Input } from '@angular/core'; | ||
import { Recipe, RecipeService } from '@services'; | ||
|
||
@Component({ | ||
selector: 'app-recipe-list', | ||
templateUrl: './recipe-list.component.html', | ||
styleUrls: ['./recipe-list.component.scss'], | ||
}) | ||
export class RecipeListComponent { | ||
@Input() public searchedQuery: string = ''; | ||
@Input() public recipeList: Recipe[] = []; | ||
|
||
constructor(private recipeService: RecipeService) {} | ||
|
||
//TODO : filter and sort has to be implemented | ||
} |
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 @@ | ||
<h1>PantryPal</h1> | ||
<p>Use the search bar below to search for any recipe</p> | ||
|
||
<form (ngSubmit)="onSearch(inputText)"> | ||
<div class="form-outline"> | ||
<i class="fas fa-search"></i> | ||
<input | ||
type="text" | ||
class="form-control" | ||
name="inputText" | ||
[(ngModel)]="inputText" | ||
placeholder="Search Recipe.." | ||
/> | ||
</div> | ||
<button type="submit">Search</button> | ||
</form> | ||
|
||
<app-recipe-list | ||
[recipeList]="recipeList" | ||
[searchedQuery]="searchText" | ||
></app-recipe-list> |
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,23 @@ | ||
.center-container { | ||
display: flex; | ||
align-items: center; | ||
height: 10vh; /* This will take the full height of the viewport */ | ||
} | ||
|
||
.form-control { | ||
border-radius: 25px; /* Rounded edges */ | ||
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); /* Shadow effect */ | ||
padding-left: 35px; /* Make room for the search icon */ | ||
width: 50vw; /* Increase the width of the search bar to 70% of the viewport width */ | ||
} | ||
.form-outline { | ||
position: relative; /* Allow the search icon and filter button to be positioned relative to this element */ | ||
margin-top: 10px; | ||
margin-bottom: 10px; /* Add space after the search bar */ | ||
} | ||
.form-outline i { | ||
position: absolute; | ||
left: 10px; | ||
top: 50%; | ||
transform: translateY(-50%); /* Vertically center the search icon */ | ||
} |
14 changes: 6 additions & 8 deletions
14
client/src/app/home/home.component.spec.ts → ...pe-search/recipe-search.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
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,22 @@ | ||
import { Component } from '@angular/core'; | ||
import { Recipe, RecipeService } from '@services'; | ||
|
||
@Component({ | ||
selector: 'app-search', | ||
templateUrl: './recipe-search.component.html', | ||
styleUrls: ['./recipe-search.component.scss'], | ||
}) | ||
export class RecipeSearchComponent { | ||
public searchText = ''; | ||
public inputText = ''; | ||
public recipeList: Recipe[] = []; | ||
|
||
constructor(private recipeService: RecipeService) {} | ||
|
||
public onSearch(searchQuery: string) { | ||
this.searchText = searchQuery; | ||
this.recipeService | ||
.searchRecipes(searchQuery) | ||
.subscribe((recipeList: Recipe[]) => (this.recipeList = recipeList)); | ||
} | ||
} |
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