@@ -7,14 +7,14 @@ import { ref, onMounted, computed } from 'vue'
7
7
8
8
const SORT_OPTIONS = {
9
9
sort: [" year" , " author" , " title" , " conference" ],
10
- order : [ " ascending" , " descending " ]
10
+ ascending : false // boolean for ascending/descending order, true = ascending
11
11
}
12
12
13
13
const publications = ref ([])
14
14
15
15
const sorting = ref ({
16
- sort: " year " ,
17
- order : " descending "
16
+ sort: " author " ,
17
+ ascending : false
18
18
})
19
19
20
20
// helper
@@ -29,13 +29,13 @@ function sortByAuthor(a, b, order) {
29
29
const sortedPublications = computed (() => {
30
30
return [... publications .value ].sort ((a , b ) => {
31
31
const sortKey = sorting .value .sort
32
- const order = sorting .value .order === " ascending" ? 1 : - 1
32
+ const order = sorting .value .ascending ? 1 : - 1
33
33
34
34
if (sortKey === " year" ) {
35
35
if (a .year !== b .year ) {
36
- return (b .year - a .year )
36
+ return (b .year - a .year ) * order
37
37
}
38
- return sortByAuthor (a, b, order )
38
+ return sortByAuthor (a, b, 1 )
39
39
}
40
40
41
41
if (sortKey === " author" ) {
@@ -54,6 +54,20 @@ const sortedPublications = computed(() => {
54
54
})
55
55
})
56
56
57
+ function handleSortToggle (v ) {
58
+ // console.log(sorting.value.sort, v)
59
+ // if (sorting.value.sort == v) {
60
+ // sorting.value.ascending = !sorting.value.ascending
61
+ // }
62
+ // else {
63
+ // sorting.value.ascending = false
64
+ // }
65
+ }
66
+
67
+ function handleSortOptionChange (v , e ) {
68
+ console .log (v,e)
69
+ }
70
+
57
71
onMounted (async () => {
58
72
const response = await fetch (' /assets/publications.json' )
59
73
publications .value = await response .json ()
@@ -68,9 +82,9 @@ onMounted(async () => {
68
82
}
69
83
70
84
.publication img {
71
- max-width : 200 px ;
85
+ max-width : 150 px ;
72
86
height : auto ; /* Maintain aspect ratio */
73
- margin-left : 20px ;
87
+ margin-right : 20px ;
74
88
object-fit : contain ; /* Ensure the image fits within the container while maintaining aspect ratio */
75
89
}
76
90
@@ -84,21 +98,53 @@ onMounted(async () => {
84
98
}
85
99
86
100
.publication img {
87
- margin-left : 0 ;
101
+ margin-right : 0 ;
88
102
margin-bottom : 10px ;
89
103
}
90
104
}
91
105
</style >
92
106
107
+ <v-row
108
+ justify="space-between"
109
+ class="mb-4"
110
+ >
111
+
93
112
# Publications
94
113
114
+ <v-btn-toggle
115
+ : value ="sorting.sort"
116
+ @change ="handleSortOptionChange(sorting, $event)"
117
+ mandatory
118
+ group
119
+ >
120
+ <v-btn value="year" @click="() => handleSortToggle('year')">
121
+ Year
122
+ <v-icon v-if="sorting.sort === 'year'" class="opacity-60">
123
+ {{ (sorting.ascending) ? "mdi-arrow-up" : "mdi-arrow-down" }}
124
+ </v-icon>
125
+ </v-btn>
126
+ <v-btn value="author" @click="() => handleSortToggle('author')">
127
+ Author
128
+ <v-icon v-if="sorting.sort === 'author'" class="opacity-60">
129
+ {{ (sorting.ascending) ? "mdi-arrow-up" : "mdi-arrow-down" }}
130
+ </v-icon>
131
+ </v-btn>
132
+ <v-btn value="title" @click="() => handleSortToggle('title')">
133
+ Title
134
+ <v-icon v-if="sorting.sort === 'title'" class="opacity-60">
135
+ {{ (sorting.ascending) ? "mdi-arrow-up" : "mdi-arrow-down" }}
136
+ </v-icon>
137
+ </v-btn>
138
+ </v-btn-toggle >
139
+ </v-row >
140
+
95
141
<div class =" container " >
96
142
<div v-for =" publication in sortedPublications " :key =" publication.title " class =" publication " >
143
+ <img v-if="publication.image" :src="`../assets/images/publications/${publication.image.src}`" :alt="publication.image.alt">
97
144
<div class="publication-info">
98
- <a :href="publication.link" target="_blank">{{ publication.title }}</a>
99
145
<p>{{ publication.authors }}</p>
146
+ <a :href="publication.link" target="_blank">{{ publication.title }}</a>
100
147
<p>{{ publication.conference }} ({{ publication.year }})</p>
101
148
</div>
102
- <img v-if="publication.image" :src="`../assets/images/publications/${publication.image.src}`" :alt="publication.image.alt">
103
149
</div >
104
- </div >
150
+ </div >
0 commit comments