Day 3 of 100days of code.😎

Day 3 of 100days of code.😎

HelloπŸ’• and welcome to my Day 3 challenge.πŸ’ͺ

How I started Day 3.

It's just the third day and I feel like my brain is gonna explode alreadyπŸ€―πŸ˜„. So I started today by converting the pizzas menu to a fruits menu page to test my knowledge on the concepts learnt so far. This time I created a component folder for my components and just imported them so I can see clearlyπŸ˜₯.

See what it looks like. My rainbow of fruitπŸ₯°πŸ‘‡πŸ‘‡

Also added a little bit of responsiveness for mobile and tablet view. Then here I was trying out the outline-offset on the sold-out images πŸ™†β€β™€οΈ.

Additional concepts Learnt

Destructuring of Props:

We destructure props (property) to extract values from the props objects or arrays passed down to a component. This allows us to use the properties directly without needing to reference them via the props object. There are several patterns we see when accessing props in React .

  • First is destructing in the component parameter which is arguably the most common method at Line 23😢.πŸ‘‡

So the footer component was getting so long and I created a new component on line 23 and use at line 12 to make it simple. I encountered a problem after this being that the new component (Order) needed both the closeHour and openHour values πŸ˜‘. So what now??. Yeah you got it right pass some propsπŸŽ‰πŸ™Œ. But this time we destructure in the component parameter at Line 23 πŸ‘†πŸ‘†. It is very important you remember the object notation in the parenthesis i.e ({ closeHour, openHour}) and not (closeHour, openHour).

So let me do some changes and show you what it looks like when directly accessing props and referencing the object at Line 23πŸ‘‡πŸ‘‡.Then ctrl zπŸ˜„.

  • Second way to destructure props is to destructure in the component body. Let me show you an example at line 24πŸ‘‡πŸ‘‡. I think I like this too.

Then there's something about using the rest operator something like ({ closeHour, ...rest}) but not much I knowπŸ€·β€β™€οΈ.

Applying CSS classes dynamically:

From my rainbow of fruit menu, you can see that the text for the sold out items is Red and the images have some outline-offset property. This is because I used the template literal and ternary operator to check if the "fruitObj.soldOut" condition evaluates to true or false and conditionally render the className sold-out at line 53 πŸ‘‡πŸ‘‡

Thanks for readingπŸ™. To be continued.....

Β