commit | author | age
|
f31b9e
|
1 |
<template> |
498b47
|
2 |
<section> |
CM |
3 |
<header> |
|
4 |
<h1>My friends</h1> |
|
5 |
</header> |
|
6 |
<ul> |
|
7 |
<friend-contact |
c4371d
|
8 |
v-for="friend in friends" |
CM |
9 |
:key="friend.id" |
8480d4
|
10 |
:id="friend.id" |
c4371d
|
11 |
:name="friend.name" |
CM |
12 |
:phone-number="friend.phone" |
|
13 |
:email-address="friend.email" |
8480d4
|
14 |
:is-favorite="friend.isFavorite" |
CM |
15 |
@toggle-favorite="toggleFavoriteStatus" |
498b47
|
16 |
></friend-contact> |
CM |
17 |
</ul> |
|
18 |
</section> |
f31b9e
|
19 |
</template> |
CM |
20 |
|
|
21 |
<script> |
|
22 |
export default { |
498b47
|
23 |
data() { |
CM |
24 |
return { |
|
25 |
friends: [ |
|
26 |
{ |
|
27 |
id: "manuel", |
|
28 |
name: "Manuel Lorenz", |
|
29 |
phone: "01234 5678 991", |
|
30 |
email: "manuel@localhost.com", |
8480d4
|
31 |
isFavorite: true, |
498b47
|
32 |
}, |
CM |
33 |
{ |
|
34 |
id: "julie", |
|
35 |
name: "Julie Jones", |
|
36 |
phone: "09876 543 221", |
|
37 |
email: "julie@localhost.com", |
8480d4
|
38 |
isFavorite: true, |
498b47
|
39 |
}, |
CM |
40 |
], |
|
41 |
} |
|
42 |
}, |
8480d4
|
43 |
methods:{ |
CM |
44 |
toggleFavoriteStatus(friendId){ |
|
45 |
const found = this.friends.find( |
|
46 |
(friend) => friend.id === friendId |
|
47 |
); |
|
48 |
found.isFavorite = !found.isFavorite; |
|
49 |
} |
|
50 |
} |
f31b9e
|
51 |
}; |
f54162
|
52 |
</script> |
CM |
53 |
|
|
54 |
<style> |
498b47
|
55 |
@import url('https://fonts.googleapis.com/css2?family=Jost&display=swap'); |
f54162
|
56 |
|
CM |
57 |
* { |
|
58 |
box-sizing: border-box; |
|
59 |
} |
|
60 |
|
|
61 |
html { |
|
62 |
font-family: 'Jost', sans-serif; |
|
63 |
} |
|
64 |
|
|
65 |
body { |
|
66 |
margin: 0; |
|
67 |
} |
|
68 |
|
|
69 |
header { |
|
70 |
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26); |
|
71 |
margin: 3rem auto; |
|
72 |
border-radius: 10px; |
|
73 |
padding: 1rem; |
|
74 |
background-color: #58004d; |
|
75 |
color: white; |
|
76 |
text-align: center; |
|
77 |
width: 90%; |
|
78 |
max-width: 40rem; |
|
79 |
} |
|
80 |
|
|
81 |
#app ul { |
|
82 |
margin: 0; |
|
83 |
padding: 0; |
|
84 |
list-style: none; |
|
85 |
} |
|
86 |
|
|
87 |
#app li { |
|
88 |
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26); |
|
89 |
margin: 1rem auto; |
|
90 |
border-radius: 10px; |
|
91 |
padding: 1rem; |
|
92 |
text-align: center; |
|
93 |
width: 90%; |
|
94 |
max-width: 40rem; |
|
95 |
} |
|
96 |
|
|
97 |
#app h2 { |
|
98 |
font-size: 2rem; |
|
99 |
border-bottom: 4px solid #ccc; |
|
100 |
color: #58004d; |
|
101 |
margin: 0 0 1rem 0; |
|
102 |
} |
|
103 |
|
|
104 |
#app button { |
|
105 |
font: inherit; |
|
106 |
cursor: pointer; |
|
107 |
border: 1px solid #ff0077; |
|
108 |
background-color: #ff0077; |
|
109 |
color: white; |
|
110 |
padding: 0.05rem 1rem; |
|
111 |
box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.26); |
|
112 |
} |
|
113 |
|
|
114 |
#app button:hover, |
|
115 |
#app button:active { |
|
116 |
background-color: #ec3169; |
|
117 |
border-color: #ec3169; |
|
118 |
box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.26); |
|
119 |
} |
|
120 |
</style> |