44 No recent events
55 </span >
66 <ul v-else >
7- <li v-for =" { date, username, action, repo, id, eventUrl } in events" :key =" id" >
8- <time >{{ date }}</time >:
7+ <li v-for =" { date, type, username, action, repo, id, eventUrl } in events" :key =" id" >
8+ <time >{{ date }}:</time >
9+ <component :is =" getIconComponent(type)" :style =" composeIconStyle(action)" class =" user-feed__icon" />
910 <a
1011 :href =" `https://github.com/${username}`"
1112 target =" _blank"
2930 </section >
3031</template >
3132<script setup lang="ts">
32- import { useEventsStore } from " @/store/events" ;
33+ import type { CSSProperties } from " vue" ;
34+ import {
35+ IconCalendarEvent ,
36+ IconCircleDot ,
37+ IconEye ,
38+ IconGitFork ,
39+ IconGitPullRequest ,
40+ IconStar ,
41+ IconTag ,
42+ IconUser ,
43+ type Icon
44+ } from " @tabler/icons-vue" ;
45+ import { useEventsStore , type FeedEvent } from " @/store/events" ;
3346
3447const { events, amount } = useEventsStore ();
48+
49+ function getIconComponent(type : FeedEvent [" type" ]): Icon {
50+ switch (type ) {
51+ case " ForkEvent" : return IconGitFork ;
52+ case " IssuesEvent" : return IconCircleDot ;
53+ case " MemberEvent" : return IconUser ;
54+ case " PublicEvent" : return IconEye ;
55+ case " PullRequestEvent" : return IconGitPullRequest ;
56+ case " ReleaseEvent" : return IconTag ;
57+ case " WatchEvent" : return IconStar ;
58+ default : return IconCalendarEvent ;
59+ }
60+ }
61+ function getIconColor(action : FeedEvent [" action" ]): string | null {
62+ switch (action ) {
63+ case " opened issue" :
64+ case " opened pull request" :
65+ case " published release" :
66+ return " #3fb950" ; // green
67+ case " merged pull request" :
68+ return " #ab7df8" ; // purple
69+ case " closed issue" :
70+ case " closed pull request" :
71+ return " #f85149" ; // red
72+ case " made public" :
73+ case " starred" :
74+ return " #e3b341" ; // yellow
75+ case " forked" :
76+ case " joined" :
77+ return " #9198a1" ; // gray
78+ default :
79+ return null ;
80+ }
81+ }
82+ function composeIconStyle(action : FeedEvent [" action" ]): CSSProperties | null {
83+ const color = getIconColor (action );
84+ return color ? { stroke: color } : null ;
85+ }
3586 </script >
3687<style lang="scss">
3788.user-feed {
@@ -50,5 +101,11 @@ const { events, amount } = useEventsStore();
50101 }
51102 }
52103 }
104+ & __icon {
105+ width : 1rem ;
106+ height : 1rem ;
107+ margin-inline : .25rem ;
108+ vertical-align : bottom ;
109+ }
53110}
54111 </style >
0 commit comments