Stellar-Junior-Dev / cocktailMasters-cosmin

0 stars 0 forks source link

[Code review] Move all the code that appends to the "frame" element in the "renderCocktailDetails" function #5

Closed emilianraduu closed 1 year ago

emilianraduu commented 1 year ago

https://github.com/Stellar-Junior-Dev/cocktailMasters-cosmin/blob/ea54941415d5eaccef593cf4838dec64aa70a9dd/detailsPage/script.js#L94

To minimise the scope of the functions and to make them have a single purpose it is recommended that all the code regarding the "frame" logic to be rendered only in the "renderCocktailDetails" function.

So after the modifications the main "logic" of the code should be the following:

  1. window onload calls loadDetailsPage
  2. loadDetailsPage calls renderHeaderImage
  3. renderHeaderImage renders the header image
    1. the renderHeaderImage appends the two icons that are returned from the "renderIcon" function
  4. loadDetailsPage appends to the "body" element the result of the renderHeaderImage
  5. loadDetailsPage calls renderCocktailDetails
  6. renderCocktailDetails renders the title, tags, ingredient list, instruction list and bottom buttons.