Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CardComponent (duplication de code) #50

Closed
maxdhn opened this issue Apr 29, 2019 · 1 comment
Closed

CardComponent (duplication de code) #50

maxdhn opened this issue Apr 29, 2019 · 1 comment
Labels
enhancement New feature or request to do

Comments

@maxdhn
Copy link
Contributor

maxdhn commented Apr 29, 2019

Template HTML de CategorieComponent :

      <div class="card m-4">
        <div class="hovereffect">
          <img class="img-responsive border border-dark col" src="assets/img/{{ categorie }}.jpg" alt="" />
          <div class="overlay">
            <h2 class="font-weight-bolder">{{ categorie }}</h2>
            <a class="info" (click)="categorieRest(categorie)" routerLink="profiles/establishments">Show restaurants</a>
          </div>
        </div>

Template HTML de ListEstablishmentComponent :

      <div class="card m-4">
        <div class="hovereffect">
          <img class="img-responsive border border-dark col" src="{{ establishment.medias[0]?.url }}" />

          <div class="overlay">
            <h2 class="font-weight-bolder">{{ establishment.name }}</h2>
            <a class="info btn btn-danger" [routerLink]="['/establishments/details', establishment._id]">See
              restaurant</a>
          </div>
        </div>
      </div>

Le code HMLT est très similaire donc création d'un component !!
Créer un component CardComponent qui mutualise les templates ci dessus.
Ajouter un @Input pour l'url de l'image, un @Input pour le nom, un @Input pour l'id de l’établissement. BONUS utiliser <ng-content> pour le contenu de <h2>.
Utiliser ce component dans ListEstablishmentComponent et CategorieComponent

@maxdhn maxdhn added enhancement New feature or request to do labels Apr 29, 2019
This was referenced Apr 29, 2019
@MartialBlot
Copy link
Contributor

ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request to do
Projects
None yet
Development

No branches or pull requests

2 participants