1+ <template >
2+ <div class =" friend-card" >
3+ <img v-if =" friend.image" :src =" friend.image" class =" friend-avatar" />
4+ <div v-else class =" friend-avatar-placeholder" >{{ initials }}</div >
5+ <div class =" friend-info" >
6+ <div class =" friend-name" >{{ friend.username }}</div >
7+ <div class =" friend-email" >{{ friend.email }}</div >
8+ <div v-if =" isFriend" >
9+ <div class =" friend-points" >🚀 {{ friend.rocketPoints ?? 0 }}</div >
10+ <div class =" friend-steps" >👣 {{ friend.steps ?? 0 }}</div >
11+ </div >
12+ </div >
13+ <button v-if =" isFriend" class =" unfollow-btn" @click =" $emit('unfollow', friend.id)" > Unfollow </button >
14+ <button v-else class =" follow-btn" @click =" $emit('add-friend', friend)" > Follow </button >
15+ </div >
16+ </template >
17+
18+ <script setup lang="ts">
19+ const props = defineProps <{
20+ friend: { id: string , username: string , email: string , rocketPoints: number , image? : string , steps? : number },
21+ isFriend? : boolean
22+ }>();
23+
24+ const initials = props .friend .username
25+ ? props .friend .username .split (' ' ).map (n => n [0 ]).join (' ' ).toUpperCase ()
26+ : ' ' ;
27+ </script >
28+
29+ <style scoped>
30+ .friend-card {
31+ display : flex ;
32+ align-items : center ;
33+ background : linear-gradient (90deg , #e0e7ff 0% , #f3f8ff 100% );
34+ border-radius : 1rem ;
35+ box-shadow : 0 2px 8px rgba (30 ,60 ,114 ,0.08 );
36+ padding : 1rem 1.5rem ;
37+ min-width : 600px ;
38+ max-width : 700px ;
39+ width : 100% ;
40+ margin : 0.5rem ;
41+ position : relative ;
42+ }
43+ .friend-avatar , .friend-avatar-placeholder {
44+ width : 60px ;
45+ height : 60px ;
46+ border-radius : 50% ;
47+ object-fit : cover ;
48+ background : #c7d2fe ;
49+ display : flex ;
50+ align-items : center ;
51+ justify-content : center ;
52+ font-size : 2rem ;
53+ color : #374151 ;
54+ margin-right : 1rem ;
55+ }
56+ .friend-info {
57+ flex : 1 ;
58+ }
59+ .friend-name {
60+ font-size : 2.0rem ;
61+ font-weight : 600 ;
62+ color : #2a5298 ;
63+ }
64+ .friend-email {
65+ font-size : 0.95rem ;
66+ color : #64748b ;
67+ }
68+ .friend-points {
69+ font-size : 0.95rem ;
70+ color : #64748b ;
71+ }
72+ .friend-steps {
73+ font-size : 0.95rem ;
74+ color : #64748b ;
75+ }
76+ .unfollow-btn {
77+ background : #fff ;
78+ border : 1px solid #ef4444 ;
79+ color : #ef4444 ;
80+ border-radius : 0.5rem ;
81+ padding : 0.4rem 1rem ;
82+ font-weight : 500 ;
83+ cursor : pointer ;
84+ transition : background 0.2s , color 0.2s ;
85+ position : absolute ;
86+ bottom : 1rem ;
87+ right : 1rem ;
88+ }
89+ .unfollow-btn :hover {
90+ background : #ef4444 ;
91+ color : #fff ;
92+ }
93+ .follow-btn {
94+ background : #22c55e ;
95+ border : 1px solid #22c55e ;
96+ color : #fff ;
97+ border-radius : 0.5rem ;
98+ padding : 0.4rem 1rem ;
99+ font-weight : 500 ;
100+ cursor : pointer ;
101+ transition : background 0.2s , color 0.2s ;
102+ position : absolute ;
103+ bottom : 1rem ;
104+ right : 1rem ;
105+ }
106+ .follow-btn :hover {
107+ background : #16a34a ;
108+ border-color : #16a34a ;
109+ }
110+ </style >
0 commit comments