Skip to content

Commit ba5ab13

Browse files
committed
refactor: apply to other components with classicon prop
1 parent 264e327 commit ba5ab13

6 files changed

Lines changed: 17 additions & 11 deletions

File tree

app/components/Button/Base.vue

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
<script setup lang="ts">
2-
type StartIcon =
3-
| `i-carbon:${string}`
4-
| `i-lucide:${string}`
5-
| `i-simple-icons:${string}`
6-
| `i-svg-spinners:${string}`
7-
| `i-custom:${string}`
2+
import type { IconClass } from '~/types'
83
94
const props = withDefaults(
105
defineProps<{
@@ -15,7 +10,7 @@ const props = withDefaults(
1510
ariaKeyshortcuts?: string
1611
block?: boolean
1712
18-
classicon?: StartIcon
13+
classicon?: IconClass
1914
}>(),
2015
{
2116
type: 'button',

app/components/Link/Base.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script setup lang="ts">
22
import type { NuxtLinkProps } from '#app'
3+
import type { IconClass } from '~/types'
34
45
const props = withDefaults(
56
defineProps<
@@ -26,7 +27,7 @@ const props = withDefaults(
2627
*/
2728
rel?: never
2829
29-
classicon?: string
30+
classicon?: IconClass
3031
3132
to?: NuxtLinkProps['to']
3233

app/components/Tag/Static.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<script setup lang="ts">
2+
import type { IconClass } from '~/types'
3+
24
const props = withDefaults(
35
defineProps<{
46
as?: string | Component
57
variant?: 'ghost' | 'default'
68
7-
classicon?: string
9+
classicon?: IconClass
810
}>(),
911
{ as: 'span', variant: 'default' },
1012
)

app/pages/package/[[org]]/[name].vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type {
99
SkillsListResponse,
1010
} from '#shared/types'
1111
import type { JsrPackageInfo } from '#shared/types/jsr'
12+
import type { IconClass } from '~/types'
1213
import { assertValidPackageName } from '#shared/utils/npm'
1314
import { joinURL } from 'ufo'
1415
import { areUrlsEquivalent } from '#shared/utils/url'
@@ -399,7 +400,7 @@ const repositoryUrl = computed(() => {
399400
400401
const { meta: repoMeta, repoRef, stars, starsLink, forks, forksLink } = useRepoMeta(repositoryUrl)
401402
402-
const PROVIDER_ICONS: Record<string, string> = {
403+
const PROVIDER_ICONS: Record<string, IconClass> = {
403404
github: 'i-simple-icons:github',
404405
gitlab: 'i-simple-icons:gitlab',
405406
bitbucket: 'i-simple-icons:bitbucket',
@@ -412,7 +413,7 @@ const PROVIDER_ICONS: Record<string, string> = {
412413
radicle: 'i-lucide:network', // Radicle is a P2P network, using network icon
413414
}
414415
415-
const repoProviderIcon = computed(() => {
416+
const repoProviderIcon = computed((): IconClass => {
416417
const provider = repoRef.value?.provider
417418
if (!provider) return 'i-simple-icons:github'
418419
return PROVIDER_ICONS[provider] ?? 'i-lucide:code'

app/types/icon.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export type IconClass =
2+
| `i-carbon:${string}`
3+
| `i-lucide:${string}`
4+
| `i-simple-icons:${string}`
5+
| `i-svg-spinners:${string}`
6+
| `i-custom:${string}`

app/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
export * from './icon'
12
export * from './navigation'

0 commit comments

Comments
 (0)