Skip to content

Commit 6905555

Browse files
committed
feat: Adjust the number of initially visible tags in blog and archive cards based on screen size.
1 parent 6b0bed3 commit 6905555

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

components/archive/card.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,12 @@ onMounted(() => {
5252
const visibleTags = computed(() => {
5353
if (showAllTags.value)
5454
return props.tags
55-
return props.tags.slice(0, 3)
55+
return isMobile.value ? props.tags.slice(0, 2) : props.tags.slice(0, 3)
5656
})
5757
5858
const remainingTagsCount = computed(() => {
59-
return Math.max(0, props.tags.length - 3)
59+
const visibleCount = isMobile.value ? 2 : 3
60+
return Math.max(0, props.tags.length - visibleCount)
6061
})
6162
6263
function toggleTags(event: Event) {
@@ -109,7 +110,7 @@ const buttonLabel = computed(() =>
109110
<span class="bg-hoppr-purple text-white px-2 py-1 rounded-full tracking-wider" role="listitem">{{ tag }}</span>
110111
</template>
111112
<button
112-
v-if="props.tags.length > 3"
113+
v-if="props.tags.length > (isMobile ? 2 : 3)"
113114
class="bg-gray-200 text-gray-700 px-2 py-1 rounded-full text-sm hover:bg-gray-300 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-hoppr-purple"
114115
:aria-expanded="showAllTags"
115116
:aria-label="buttonLabel"

components/blog/card.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ onMounted(() => {
4848
const visibleTags = computed(() => {
4949
if (showAllTags.value)
5050
return props.tags
51-
return isMobile.value ? props.tags.slice(0, 3) : props.tags.slice(0, 2)
51+
return isMobile.value ? props.tags.slice(0, 2) : props.tags.slice(0, 2)
5252
})
5353
5454
const remainingTagsCount = computed(() => {
55-
const visibleCount = isMobile.value ? 3 : 2
55+
const visibleCount = isMobile.value ? 2 : 2
5656
return Math.max(0, props.tags.length - visibleCount)
5757
})
5858
@@ -104,7 +104,7 @@ const buttonLabel = computed(() =>
104104
<span class="bg-hoppr-purple text-white px-2 py-1 rounded-full tracking-wider" role="listitem">{{ tag }}</span>
105105
</template>
106106
<button
107-
v-if="props.tags.length > (isMobile ? 3 : 2)"
107+
v-if="props.tags.length > (isMobile ? 2 : 2)"
108108
class="bg-gray-200 text-gray-700 px-2 py-1 rounded-full text-sm hover:bg-gray-300 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-hoppr-purple"
109109
:aria-expanded="showAllTags"
110110
:aria-label="buttonLabel"

0 commit comments

Comments
 (0)