Skip to content

Commit 39c49b6

Browse files
committed
fix: move frameworks to utils
1 parent c927b38 commit 39c49b6

File tree

4 files changed

+25
-36
lines changed

4 files changed

+25
-36
lines changed

app/components/Package/DownloadAnalytics.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { VueUiXy } from 'vue-data-ui/vue-ui-xy'
44
import { useDebounceFn, useElementSize } from '@vueuse/core'
55
import { useCssVariables } from '~/composables/useColors'
66
import { OKLCH_NEUTRAL_FALLBACK, transparentizeOklch } from '~/utils/colors'
7+
import { getFrameworkColor, isListedFramework } from '~/utils/frameworks'
78
89
const props = defineProps<{
910
// For single package downloads history
@@ -57,9 +58,6 @@ const { colors } = useCssVariables(
5758
},
5859
)
5960
60-
// Listed frameworks have hardcoded colors
61-
const { getFrameworkColor, isListedFramework } = useFrameworks()
62-
6361
watch(
6462
() => colorMode.value,
6563
value => {

app/composables/useFrameworks.ts

Lines changed: 0 additions & 31 deletions
This file was deleted.

app/pages/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<script setup lang="ts">
22
import { debounce } from 'perfect-debounce'
3+
import { SHOWCASED_FRAMEWORKS } from '~/utils/frameworks'
34
45
const searchQuery = shallowRef('')
56
const searchInputRef = useTemplateRef('searchInputRef')
67
const { focused: isSearchFocused } = useFocus(searchInputRef)
7-
const { frameworks } = useFrameworks()
88
99
async function search() {
1010
const query = searchQuery.value.trim()
@@ -116,7 +116,7 @@ defineOgImageComponent('Default', {
116116
style="animation-delay: 0.3s"
117117
>
118118
<ul class="flex flex-wrap items-center justify-center gap-x-6 gap-y-3 list-none m-0 p-0">
119-
<li v-for="framework in frameworks" :key="framework.name">
119+
<li v-for="framework in SHOWCASED_FRAMEWORKS" :key="framework.name">
120120
<NuxtLink
121121
:to="{ name: 'package', params: { package: [framework.package] } }"
122122
class="link-subtle font-mono text-sm inline-flex items-center gap-2 group"

app/utils/frameworks.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
export const SHOWCASED_FRAMEWORKS = [
2+
{ name: 'nuxt', package: 'nuxt', color: 'oklch(0.7862 0.192 155.63)' },
3+
{ name: 'vue', package: 'vue', color: 'oklch(0.7025 0.132 160.37)' },
4+
{ name: 'nitro', package: 'nitro', color: 'oklch(70.4% 0.191 22.216)' },
5+
{ name: 'react', package: 'react', color: 'oklch(0.832 0.1167 218.69)' },
6+
{ name: 'svelte', package: 'svelte', color: 'oklch(0.6917 0.1865 35.04)' },
7+
{ name: 'vite', package: 'vite', color: 'oklch(0.7484 0.1439 294.03)' },
8+
{ name: 'next', package: 'next', color: 'oklch(71.7% .1648 250.794)' },
9+
{ name: 'astro', package: 'astro', color: 'oklch(0.5295 0.2434 270.23)' },
10+
{ name: 'typescript', package: 'typescript', color: 'oklch(0.5671 0.1399 253.3)' },
11+
{ name: 'angular', package: '@angular/core', color: 'oklch(0.626 0.2663 310.4)' },
12+
]
13+
14+
export type ShowcasedFramework = (typeof SHOWCASED_FRAMEWORKS)[number]['package']
15+
16+
export function getFrameworkColor(framework: ShowcasedFramework): string {
17+
return SHOWCASED_FRAMEWORKS.find(f => f.package === framework)!.color
18+
}
19+
20+
export function isListedFramework(name: string): name is ShowcasedFramework {
21+
return SHOWCASED_FRAMEWORKS.some(f => f.package === name)
22+
}

0 commit comments

Comments
 (0)