Skip to content

Commit 45cef8f

Browse files
authored
Merge pull request #9 from m-mattia-m/develop
add filters and fix spelling
2 parents 4c19665 + 9bbdde8 commit 45cef8f

File tree

2 files changed

+95
-6
lines changed

2 files changed

+95
-6
lines changed

components/skills.vue

+94-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,55 @@
11
<script lang="ts" setup>
22
import type { Ref } from "vue";
3-
import { PlusIcon, MinusIcon } from "@heroicons/vue/24/outline";
3+
import { MinusIcon, PlusIcon } from "@heroicons/vue/24/outline";
4+
5+
const { t, tm, rt } = useI18n({
6+
useScope: "local",
7+
});
48
59
const openSkillIndex: Ref<number> = ref(-1);
610
711
function toggleSkillState(index: number) {
812
if (openSkillIndex.value === index) return (openSkillIndex.value = -1);
913
openSkillIndex.value = index;
1014
}
15+
16+
const skills: Ref<skill[]> = ref(tm("skills.content"));
17+
const filters: Ref<string[] | undefined> = ref(
18+
skills.value
19+
.map((skill) => skill.tags)
20+
.flat()
21+
.filter((tag, index, array) => array.indexOf(tag) === index)
22+
.sort((a, b) => b.length - a.length),
23+
);
24+
25+
const activeFilters: Ref<Map<string, boolean>> = ref(
26+
new Map<string, boolean>(),
27+
);
28+
29+
function updateFilter(filterKey: string): void {
30+
if (activeFilters.value.has(filterKey)) {
31+
activeFilters.value.delete(filterKey);
32+
} else {
33+
activeFilters.value.set(filterKey, true);
34+
}
35+
}
36+
37+
function filterSkills(): void {
38+
let allSkills = tm("skills.content") as skill[];
39+
if (activeFilters.value.size !== 0) {
40+
const activeFilterKeys = Array.from(activeFilters.value.keys());
41+
allSkills = allSkills.filter((skill) =>
42+
activeFilterKeys.every((filter) => skill.tags.includes(filter)),
43+
);
44+
}
45+
skills.value = allSkills;
46+
}
47+
48+
interface skill {
49+
title: string;
50+
tags: string[];
51+
description: string;
52+
}
1153
</script>
1254

1355
<template>
@@ -16,15 +58,35 @@ function toggleSkillState(index: number) {
1658
<h1 class="text-5xl text-dark dark:text-light pb-12">
1759
{{ $t("skills.title") }}
1860
</h1>
61+
<ul
62+
class="scrollbar overflow-hidden overflow-x-auto box-content w-full grid grid-flow-col-dense gap-1 pb-4"
63+
>
64+
<li
65+
v-for="filter in filters"
66+
:class="[
67+
activeFilters.get(filter)
68+
? 'bg-primary text-white'
69+
: 'bg-white text-primary',
70+
]"
71+
class="w-fit cursor-pointer flex justify-center rounded-full py-1 px-2 whitespace-nowrap text-xs"
72+
@click="
73+
updateFilter(filter);
74+
filterSkills();
75+
"
76+
>
77+
{{ filter }}
78+
</li>
79+
</ul>
1980
<div
2081
class="w-full flex flex-col justify-between items-start text-dark dark:text-light"
2182
>
2283
<!-- for desktop -->
2384
<ul class="w-full list-disc py-2 hidden lg:block">
2485
<li
25-
v-for="(skill, index) in $tm('skills.content')"
86+
v-for="(skill, index) in skills"
2687
class="w-full list-['\25A1'] list-inside my-1"
2788
>
89+
<!-- TODO: Skill list has a wrong styling on iPad but if I add md:/xl: the styling for desktop is wrong -->
2890
<div
2991
class="ml-6 -mt-[25px] grid grid-cols-10 grid-flow-col h-8 cursor-pointer"
3092
@click="toggleSkillState(index)"
@@ -59,7 +121,7 @@ function toggleSkillState(index: number) {
59121
<!-- for mobile -->
60122
<ul class="w-full py-2 block lg:hidden">
61123
<li
62-
v-for="(skill, index) in $tm('skills.content')"
124+
v-for="(skill, index) in skills"
63125
class="w-full py-4 list-none border-b-[0.5px] border-dark dark:border-light"
64126
>
65127
<div class="cursor-pointer" @click="toggleSkillState(index)">
@@ -78,7 +140,7 @@ function toggleSkillState(index: number) {
78140
</div>
79141
<p class="text-sm flex flex-row">
80142
<template v-for="(tag, index) in skill.tags" class="">
81-
<template v-if="index !== 0" class="pr-2">, </template>
143+
<template v-if="index !== 0" class="pr-2">,</template>
82144
{{ tag }}
83145
</template>
84146
</p>
@@ -96,4 +158,31 @@ function toggleSkillState(index: number) {
96158
</div>
97159
</template>
98160

99-
<style scoped></style>
161+
<style scoped>
162+
/* Styling the scrollbar */
163+
::-webkit-scrollbar {
164+
height: 2px;
165+
}
166+
167+
/* Track (background of the scrollbar) */
168+
::-webkit-scrollbar-track {
169+
@apply bg-transparent;
170+
border-radius: 3px;
171+
}
172+
173+
::-webkit-scrollbar-thumb {
174+
@apply bg-primary;
175+
}
176+
177+
/* Handle on hover */
178+
::-webkit-scrollbar-thumb:hover {
179+
@apply bg-primary;
180+
}
181+
182+
/* Firefox-specific scrollbar styling */
183+
* {
184+
scrollbar-width: none; /* thin */
185+
/* TODO: replace with the primary color from tailwind */
186+
scrollbar-color: #0b4f6c transparent;
187+
}
188+
</style>

locales/en.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
},
3636
{
3737
"title": "Java / Kotlin",
38-
"description": "In the summer of 2023, we started to rewrite our Go backend in Kotlin on account of having more experienced developers in Kotlin and Java Go in our company. For this reason, among others, we switched to a Spring-Boot Kotlin application. Before this, I worked with Java and Spring Boot for more or less a year on my apprenticeship.",
38+
"description": "In the summer of 2023, we started to rewrite our Go backend in Kotlin on account of having more experienced developers in Kotlin and Java than Go in our company. For this reason, among others, we switched to a Spring-Boot Kotlin application. Before this, I worked with Java and Spring Boot for more or less a year on my apprenticeship.",
3939
"tags": [
4040
"Tech",
4141
"Coding",

0 commit comments

Comments
 (0)