| | |
| | | <template> |
| | | <section> |
| | | <header> |
| | | <h1>My friends</h1> |
| | | </header> |
| | | |
| | | |
| | | <ul> |
| | | <friend-contact></friend-contact> |
| | | <friend-contact></friend-contact> |
| | | </ul> |
| | | </section> |
| | | <section> |
| | | <header> |
| | | <h1>My friends</h1> |
| | | </header> |
| | | <ul> |
| | | <friend-contact |
| | | v-for="friend in friends" |
| | | :key="friend.id" |
| | | :id="friend.id" |
| | | :name="friend.name" |
| | | :phone-number="friend.phone" |
| | | :email-address="friend.email" |
| | | :is-favorite="friend.isFavorite" |
| | | @toggle-favorite="toggleFavoriteStatus" |
| | | ></friend-contact> |
| | | </ul> |
| | | </section> |
| | | </template> |
| | | |
| | | <script> |
| | | export default { |
| | | data() { |
| | | return { |
| | | friends: [ |
| | | { |
| | | id: "manuel", |
| | | name: "Manuel Lorenz", |
| | | phone: "01234 5678 991", |
| | | email: "manuel@localhost.com", |
| | | }, |
| | | { |
| | | id: "julie", |
| | | name: "Julie Jones", |
| | | phone: "09876 543 221", |
| | | email: "julie@localhost.com", |
| | | }, |
| | | ], |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | friends: [ |
| | | { |
| | | id: "manuel", |
| | | name: "Manuel Lorenz", |
| | | phone: "01234 5678 991", |
| | | email: "manuel@localhost.com", |
| | | isFavorite: true, |
| | | }, |
| | | { |
| | | id: "julie", |
| | | name: "Julie Jones", |
| | | phone: "09876 543 221", |
| | | email: "julie@localhost.com", |
| | | isFavorite: true, |
| | | }, |
| | | ], |
| | | } |
| | | }, |
| | | methods:{ |
| | | toggleFavoriteStatus(friendId){ |
| | | const found = this.friends.find( |
| | | (friend) => friend.id === friendId |
| | | ); |
| | | found.isFavorite = !found.isFavorite; |
| | | } |
| | | } |
| | | }; |
| | | </script> |
| | | |
| | | <style> |
| | | @import url('https://fonts.googleapis.com/css2?family=Jost&display=swap'); |
| | | @import url('https://fonts.googleapis.com/css2?family=Jost&display=swap'); |
| | | |
| | | * { |
| | | box-sizing: border-box; |
| | |
| | | border-color: #ec3169; |
| | | box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.26); |
| | | } |
| | | |
| | | </style> |