From 65db525cfb90afc0f3162da4e0808961e014f667 Mon Sep 17 00:00:00 2001 From: "hugo.pradier2" Date: Mon, 24 Jun 2024 11:40:45 +0200 Subject: [PATCH] correctif affichage recette unique --- src/app/recipe/recipe.component.html | 38 +++++++++++++++------------- src/app/recipe/recipe.component.scss | 12 +++++++++ src/app/recipe/recipe.component.ts | 8 ++++++ 3 files changed, 41 insertions(+), 17 deletions(-) diff --git a/src/app/recipe/recipe.component.html b/src/app/recipe/recipe.component.html index ee19345..25d91fb 100644 --- a/src/app/recipe/recipe.component.html +++ b/src/app/recipe/recipe.component.html @@ -2,26 +2,30 @@ - {{ recipe.name }} - {{ recipe.description }} - {{ recipe.name }} - - Placeholder Image - + Name : {{ recipe.name }} + Description : + + + + Image : + {{ recipe.name }} + + Placeholder Image +

Ingredients

  • diff --git a/src/app/recipe/recipe.component.scss b/src/app/recipe/recipe.component.scss index 011730b..deb6e59 100644 --- a/src/app/recipe/recipe.component.scss +++ b/src/app/recipe/recipe.component.scss @@ -2,3 +2,15 @@ max-width: 600px; margin-bottom: 8px; } + +.description { + max-width: 100%; + overflow: hidden; +} + +.recipe-image { + max-width: 500px; + max-height: 500px; + display: block; + margin: 8px 0; +} diff --git a/src/app/recipe/recipe.component.ts b/src/app/recipe/recipe.component.ts index 79606ac..f5dba3b 100644 --- a/src/app/recipe/recipe.component.ts +++ b/src/app/recipe/recipe.component.ts @@ -16,6 +16,7 @@ import { MatCardModule } from '@angular/material/card'; export class RecipeComponent implements OnInit { recipe: Recipe | undefined; ingredientRecipes: IngredientRecipe[] = []; + formattedDescription: string = ''; constructor(private route: ActivatedRoute) {} @@ -28,6 +29,9 @@ export class RecipeComponent implements OnInit { if (this.recipe) { this.ingredientRecipes = this.getIngredientRecipes(this.recipe.id); + this.formattedDescription = this.formatDescription( + this.recipe.description + ); } } @@ -48,4 +52,8 @@ export class RecipeComponent implements OnInit { navBack(): void { window.history.back(); } + + formatDescription(description: string): string { + return description.replace(/(.{50})/g, '$1
    '); + } }