forked from vuejs/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeveloperProficiencies.vue
87 lines (75 loc) · 2.06 KB
/
DeveloperProficiencies.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<script setup lang="ts">
import { ref, computed } from 'vue'
import partnerConfig from '../partnerConfig'
const props = defineProps<{
proficiencies: string[]
title?: string
enableShowAll?: boolean
}>()
const showAll = ref(false)
const maxVisibleProficiencies = partnerConfig.proficiencies.skillsPerCard
const visibleProficiencies = computed(() => {
if (!props.enableShowAll) {
return props.proficiencies
}
if (props.proficiencies.length <= maxVisibleProficiencies) {
return props.proficiencies
}
return showAll.value ? props.proficiencies : props.proficiencies.slice(0, maxVisibleProficiencies)
})
const shouldShowButton = computed(() => {
return props.enableShowAll && props.proficiencies.length > maxVisibleProficiencies
})
const toggleShowAll = (event: Event) => {
event.stopPropagation()
event.preventDefault()
showAll.value = !showAll.value
}
</script>
<template>
<div class="developer-proficiencies">
<h4 v-if="title" class="developer-proficiencies__title">{{ title }}</h4>
<div class="developer-proficiencies__list">
<span class="developer-proficiencies__item" v-for="(p, key) in visibleProficiencies" :key="`prof-${key}`">{{ p }}</span>
<button
v-if="shouldShowButton"
class="developer-proficiencies__toggle"
@click.stop="toggleShowAll"
>
{{ showAll ? 'Show less' : 'Show all' }}
</button>
</div>
</div>
</template>
<style scoped>
.developer-proficiencies {
display: flex;
flex-direction: column;
}
.developer-proficiencies__list {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.developer-proficiencies__item {
display: inline-block;
color: var(--vt-c-text-code);
font-weight: 600;
font-size: 0.85em;
background-color: var(--vt-c-bg-mute);
padding: 4px 10px;
border-radius: 6px;
}
.developer-proficiencies__toggle {
display: inline-block;
font-weight: 600;
font-size: 0.85em;
color: var(--vt-c-brand);
padding: 4px 10px;
border-radius: 6px;
cursor: pointer;
}
.developer-proficiencies__toggle:hover {
color: var(--vt-c-brand-dark);
}
</style>