# Berry Good Friends πŸ“πŸ“πŸ“πŸ“πŸ“ ![](https://i.imgur.com/qGVLWPw.jpg =600x) --- ## Demo ![](https://media.giphy.com/media/3o6Mb5W48vOsqke0ec/giphy.gif =600x) --- ## APIs we used - https://jsonplaceholder.typicode.com/ - this is a fake API 🀭 it just generates imaginary users with imaginary info ![](https://i.imgur.com/4GNoEm1.png =400x) --- - https://robohash.org/ - put ANY text attached after the site url and get back a pretty image for your site! ![](https://i.imgur.com/GX9Feyg.png =200x) ![](https://i.imgur.com/ADuJo3M.png =230x) --- ## Process ![](https://i.imgur.com/XbB3AAR.png) --- After we decided the concept, we did a very quick first design in `Miro` ![](https://i.imgur.com/OQtTnDI.png =500x) --- ## What we learned & Mistakes :books: :bug: --- ### href in React - href are automatically relative to server (it thinks it's a sub-route). It's a big topic online! - Would send you :slightly_frowning_face: to <www.berry.com/user-website> :smile: instead of<www.user-website.com> ```jsx= // These don't work: <a href={props.user.website}>... <a href="https://{props.user.website}">... // This works (Thanks Antonio!!!): <a href={`https://${props.user.website}`}>... ``` --- ### Attach a class - Matter of personal preference #### Version 1: .querySelector ```javascript= <button onClick={(e) => document.querySelector('.card-container').classList.toggle('flipped') }> Surprise πŸ˜‰ </button>; ``` #### Version 2: React state ```javascript= const [flipped, setFlipped] = useState(''); <article className={`card-container ${flipped}`}> <button onClick={() => setFlipped('')}>Surprise πŸ˜‰</button> </article>; ``` --- *That prompted some quick research πŸ”Ž* ## Declarative UI vs Imperative UI <span style="color:lightblue"><b>React is a declarative UI βš›</b></span> --- πŸ’‘ In a declarative UI framework, *you should never find yourself writing code that manipulates your UI*. Events (user interaction, pushed server events) only mutate the application state, which is then reflected in the UI. --- pros βž•: the behaviour of declarative UI is *easier to predict* and test. It’s easy to predict the effect of new code at compile time, because the UI defines *precisely* how it responds to the state of the application, and also how it mutates that state βœ… --- ## but, moving on... 🎴 --- ### Card Flip ![](https://i.imgur.com/YC6jrkL.png) --- ### Card flip: We used ```css= .card{ backface-visibility: hidden; } .card-b { transform: rotateY(180deg); } ``` - Click Surprise button :arrow_right: event :arrow_right: attach class to card ```css= .card-container.flipped { transform: rotateY(180deg); } ``` --- ### :construction: Card flip doesn't always work :construction: - Sometimes you get a <span style="color:green; font-weight: bold;">blank</span> backside - Sometimes you see the <span style="color:green; font-weight: bold;">backside</span> (Firefox) - <span style="color:green; font-weight: bold;">Absolute/relative</span> positions were a bit confusing :arrow_right: We should probably investigate <span style="color:green; font-weight: bold;">backface-visibility: hidden</span> further --- ## If we had more time :alarm_clock: - Use a <span style="color:green; font-weight: bold;">database</span>: store score between <span style="color:green; font-weight: bold;">devices</span> - <span style="color:green; font-weight: bold;">Sort</span> cards by score - <span style="color:green; font-weight: bold;">More foods</span>: :strawberry::green_salad: :candy::grapes: - Each card has <span style="color:green; font-weight: bold;">individual</span> - <span style="color:green; font-weight: bold;">Intervals</span> - <span style="color:green; font-weight: bold;">Preferences:</span> like :strawberry:, dislike :green_salad: --- ![](https://media.giphy.com/media/3oz8xIsloV7zOmt81G/giphy.gif =500x) --- ![](https://media.giphy.com/media/xT5LMB2WiOdjpB7K4o/giphy.gif =500x) πŸ“πŸ“πŸ“πŸ“πŸ“ ---
{"metaMigratedAt":"2023-06-16T13:26:14.866Z","metaMigratedFrom":"Content","title":"Berry Good Friends","breaks":true,"contributors":"[{\"id\":\"6cc335f8-1f36-47ab-89ea-21858127bf52\",\"add\":3162,\"del\":623},{\"id\":\"c64c09fb-f2ff-4773-96d9-380de11398cb\",\"add\":1687,\"del\":206}]"}
    185 views