Skip to content

Commit 706b3ac

Browse files
committed
refactor: badge types constant should be shared
1 parent 263bb3f commit 706b3ac

File tree

3 files changed

+25
-50
lines changed

3 files changed

+25
-50
lines changed

docs/app/components/BadgeGenerator.vue

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,6 @@ const isValid = ref(true)
77
88
const { copy, copied } = useClipboard({ copiedDuring: 2000 })
99
10-
const types = [
11-
'version',
12-
'license',
13-
'size',
14-
'downloads',
15-
'downloads-day',
16-
'downloads-week',
17-
'downloads-month',
18-
'downloads-year',
19-
'vulnerabilities',
20-
'dependencies',
21-
'created',
22-
'updated',
23-
'engines',
24-
'types',
25-
'maintainers',
26-
'deprecated',
27-
'quality',
28-
'popularity',
29-
'maintenance',
30-
'score',
31-
'name',
32-
]
33-
3410
watch([pkg, type], () => {
3511
isValid.value = true
3612
})
@@ -76,7 +52,7 @@ const copyToClipboard = async () => {
7652
v-model="type"
7753
class="w-full h-10.5 px-4 py-2 rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-black/20 focus:ring-2 focus:ring-emerald-500/20 focus:border-emerald-500 outline-none text-sm transition-all appearance-none cursor-pointer"
7854
>
79-
<option v-for="t in types" :key="t" :value="t" class="dark:bg-gray-900">
55+
<option v-for="t in BADGE_TYPES" :key="t" :value="t" class="dark:bg-gray-900">
8056
{{ formatLabel(t) }}
8157
</option>
8258
</select>

docs/app/components/BadgeGeneratorParameters.vue

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,6 @@ const badgeColor = useState('badge-color', () => '')
1414
const usePkgName = useState('badge-use-name', () => false)
1515
const badgeStyle = useState('badge-style', () => 'default')
1616
17-
const types = [
18-
'version',
19-
'license',
20-
'size',
21-
'downloads',
22-
'downloads-day',
23-
'downloads-week',
24-
'downloads-month',
25-
'downloads-year',
26-
'vulnerabilities',
27-
'dependencies',
28-
'created',
29-
'updated',
30-
'engines',
31-
'types',
32-
'maintainers',
33-
'deprecated',
34-
'quality',
35-
'popularity',
36-
'maintenance',
37-
'score',
38-
'name',
39-
]
40-
4117
const styles = ['default', 'shieldsio']
4218
4319
const validateHex = hex => {
@@ -122,7 +98,7 @@ const copyToClipboard = async () => {
12298
v-model="type"
12399
class="w-full h-10.5 px-4 py-2 rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-black/20 focus:ring-2 focus:ring-emerald-500/20 focus:border-emerald-500 outline-none text-sm transition-all appearance-none cursor-pointer"
124100
>
125-
<option v-for="t in types" :key="t" :value="t" class="dark:bg-gray-900">
101+
<option v-for="t in BADGE_TYPES" :key="t" :value="t" class="dark:bg-gray-900">
126102
{{ formatLabel(t) }}
127103
</option>
128104
</select>

docs/shared/utils/badges.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
export const BADGE_TYPES = Object.freeze([
2+
'version',
3+
'license',
4+
'size',
5+
'downloads',
6+
'downloads-day',
7+
'downloads-week',
8+
'downloads-month',
9+
'downloads-year',
10+
'vulnerabilities',
11+
'dependencies',
12+
'created',
13+
'updated',
14+
'engines',
15+
'types',
16+
'maintainers',
17+
'deprecated',
18+
'quality',
19+
'popularity',
20+
'maintenance',
21+
'score',
22+
'name',
23+
] as const)

0 commit comments

Comments
 (0)