Skip to content

Commit 3376231

Browse files
committed
chore: use v-for to render items in CallToAction
Why use more code when less code do trick
1 parent 1ea3ae9 commit 3376231

1 file changed

Lines changed: 33 additions & 56 deletions

File tree

app/components/CallToAction.vue

Lines changed: 33 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,30 @@
11
<script setup lang="ts">
2-
const socialLinks = {
3-
github: 'https://repo.npmx.dev',
4-
discord: 'https://chat.npmx.dev',
5-
bluesky: 'https://social.npmx.dev',
6-
}
2+
const socialLinks = [
3+
{
4+
id: 'github',
5+
href: 'https://repo.npmx.dev',
6+
icon: 'i-carbon:logo-github',
7+
titleKey: 'about.get_involved.contribute.title',
8+
descriptionKey: 'about.get_involved.contribute.description',
9+
ctaKey: 'about.get_involved.contribute.cta',
10+
},
11+
{
12+
id: 'discord',
13+
href: 'https://chat.npmx.dev',
14+
icon: 'i-carbon:chat',
15+
titleKey: 'about.get_involved.community.title',
16+
descriptionKey: 'about.get_involved.community.description',
17+
ctaKey: 'about.get_involved.community.cta',
18+
},
19+
{
20+
id: 'bluesky',
21+
href: 'https://social.npmx.dev',
22+
icon: 'i-simple-icons:bluesky',
23+
titleKey: 'about.get_involved.follow.title',
24+
descriptionKey: 'about.get_involved.follow.description',
25+
ctaKey: 'about.get_involved.follow.cta',
26+
},
27+
]
728
</script>
829

930
<template>
@@ -14,70 +35,26 @@ const socialLinks = {
1435

1536
<div class="grid gap-4 sm:grid-cols-3 sm:items-stretch sm:grid-rows-[auto,1fr,auto]">
1637
<a
17-
:href="socialLinks.github"
38+
v-for="link in socialLinks"
39+
:key="link.id"
40+
:href="link.href"
1841
target="_blank"
1942
rel="noopener noreferrer"
2043
class="group grid gap-3 p-4 rounded-lg bg-bg-subtle hover:bg-bg-elevated border border-border hover:border-border-hover transition-all duration-200 sm:grid-rows-subgrid sm:row-span-3"
2144
>
2245
<div class="flex gap-2">
23-
<span class="i-carbon:logo-github shrink-0 mt-1 w-5 h-5 text-fg" aria-hidden="true" />
46+
<span :class="link.icon" class="shrink-0 mt-1 w-5 h-5 text-fg" aria-hidden="true" />
2447
<span class="font-medium text-fg">
25-
{{ $t('about.get_involved.contribute.title') }}
48+
{{ $t(link.titleKey) }}
2649
</span>
2750
</div>
2851
<p class="text-sm text-fg-muted leading-relaxed">
29-
{{ $t('about.get_involved.contribute.description') }}
52+
{{ $t(link.descriptionKey) }}
3053
</p>
3154
<span
3255
class="text-sm text-fg-muted group-hover:text-fg inline-flex items-center gap-1 mt-auto"
3356
>
34-
{{ $t('about.get_involved.contribute.cta') }}
35-
<span class="i-carbon:arrow-right rtl-flip w-3 h-3" aria-hidden="true" />
36-
</span>
37-
</a>
38-
39-
<a
40-
:href="socialLinks.discord"
41-
target="_blank"
42-
rel="noopener noreferrer"
43-
class="group grid gap-3 p-4 rounded-lg bg-bg-subtle hover:bg-bg-elevated border border-border hover:border-border-hover transition-all duration-200 sm:grid-rows-subgrid sm:row-span-3"
44-
>
45-
<div class="flex gap-2">
46-
<span class="i-carbon:chat shrink-0 mt-1 w-5 h-5 text-fg" aria-hidden="true" />
47-
<span class="font-medium text-fg">
48-
{{ $t('about.get_involved.community.title') }}
49-
</span>
50-
</div>
51-
<p class="text-sm text-fg-muted leading-relaxed">
52-
{{ $t('about.get_involved.community.description') }}
53-
</p>
54-
<span
55-
class="text-sm text-fg-muted group-hover:text-fg inline-flex items-center gap-1 mt-auto"
56-
>
57-
{{ $t('about.get_involved.community.cta') }}
58-
<span class="i-carbon:arrow-right rtl-flip w-3 h-3" aria-hidden="true" />
59-
</span>
60-
</a>
61-
62-
<a
63-
:href="socialLinks.bluesky"
64-
target="_blank"
65-
rel="noopener noreferrer"
66-
class="group grid gap-3 p-4 rounded-lg bg-bg-subtle hover:bg-bg-elevated border border-border hover:border-border-hover transition-all duration-200 sm:grid-rows-subgrid sm:row-span-3"
67-
>
68-
<div class="flex gap-2">
69-
<span class="i-simple-icons:bluesky shrink-0 mt-1 w-5 h-5 text-fg" aria-hidden="true" />
70-
<span class="font-medium text-fg">
71-
{{ $t('about.get_involved.follow.title') }}
72-
</span>
73-
</div>
74-
<p class="text-sm text-fg-muted leading-relaxed">
75-
{{ $t('about.get_involved.follow.description') }}
76-
</p>
77-
<span
78-
class="text-sm text-fg-muted group-hover:text-fg inline-flex items-center gap-1 mt-auto"
79-
>
80-
{{ $t('about.get_involved.follow.cta') }}
57+
{{ $t(link.ctaKey) }}
8158
<span class="i-carbon:arrow-right rtl-flip w-3 h-3" aria-hidden="true" />
8259
</span>
8360
</a>

0 commit comments

Comments
 (0)