Skip to content

Commit 2a474e9

Browse files
refactor: remove unnecessary prop from links (#1247)
1 parent e0c6b73 commit 2a474e9

File tree

11 files changed

+70
-81
lines changed

11 files changed

+70
-81
lines changed

app/components/AppHeader.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ onKeyStroke(
270270
<!-- Mobile: Menu button (always visible, click to open menu) -->
271271
<ButtonBase
272272
type="button"
273-
class="sm:hidden flex"
273+
class="sm:hidden"
274274
:aria-label="$t('nav.open_menu')"
275275
:aria-expanded="showMobileMenu"
276276
@click="showMobileMenu = !showMobileMenu"

app/components/Button/Base.vue

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const props = withDefaults(
66
variant?: 'primary' | 'secondary'
77
size?: 'small' | 'medium'
88
ariaKeyshortcuts?: string
9+
block?: boolean
910
1011
classicon?: string
1112
}>(),
@@ -27,8 +28,10 @@ defineExpose({
2728
<template>
2829
<button
2930
ref="el"
30-
class="group cursor-pointer inline-flex gap-x-1 items-center justify-center font-mono border border-border rounded-md transition-all duration-200 disabled:(opacity-40 cursor-not-allowed border-transparent)"
31+
class="group cursor-pointer gap-x-1 items-center justify-center font-mono border border-border rounded-md transition-all duration-200 disabled:(opacity-40 cursor-not-allowed border-transparent)"
3132
:class="{
33+
'inline-flex': !block,
34+
'flex': block,
3235
'text-sm px-4 py-2': size === 'medium',
3336
'text-xs px-2 py-0.5': size === 'small',
3437
'bg-transparent text-fg hover:enabled:(bg-fg/10) focus-visible:enabled:(bg-fg/10) aria-pressed:(bg-fg/10 border-fg/20 hover:enabled:(bg-fg/20 text-fg/50))':
@@ -48,11 +51,7 @@ defineExpose({
4851
"
4952
:aria-keyshortcuts="ariaKeyshortcuts"
5053
>
51-
<span
52-
v-if="classicon"
53-
:class="[size === 'small' ? 'size-3' : 'size-4', classicon]"
54-
aria-hidden="true"
55-
/>
54+
<span v-if="classicon" class="size-[1em]" :class="classicon" aria-hidden="true" />
5655
<slot />
5756
<kbd
5857
v-if="ariaKeyshortcuts"

app/components/Code/FileTree.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ watch(
5050
<!-- Directory -->
5151
<template v-if="node.type === 'directory'">
5252
<ButtonBase
53-
class="w-full flex! justify-start! rounded-none! border-none!"
53+
class="w-full justify-start! rounded-none! border-none!"
54+
block
5455
:aria-pressed="isNodeActive(node)"
5556
:style="{ paddingLeft: `${depth * 12 + 12}px` }"
5657
@click="toggleDir(node.path)"
@@ -82,7 +83,8 @@ watch(
8283
variant="button-secondary"
8384
:to="getFileRoute(node.path)"
8485
:aria-current="currentPath === node.path"
85-
class="w-full flex! justify-start! rounded-none! border-none!"
86+
class="w-full justify-start! rounded-none! border-none!"
87+
block
8688
:style="{ paddingLeft: `${depth * 12 + 32}px` }"
8789
:classicon="getFileIcon(node.name)"
8890
>

app/components/CollapsibleSection.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ useHead({
103103
/>
104104
</button>
105105

106-
<LinkBase :to="`#${id}`" class="">
106+
<LinkBase :to="`#${id}`">
107107
{{ title }}
108108
</LinkBase>
109109
</component>

app/components/Compare/ComparisonGrid.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ function getReplacementTooltip(col: ComparisonGridColumn): string {
4242
<span class="inline-flex items-center gap-1.5 truncate">
4343
<LinkBase
4444
:to="packageRoute(col.name, col.version)"
45-
class="text-sm flex! truncate"
45+
class="text-sm truncate"
46+
block
4647
:title="col.version ? `${col.name}@${col.version}` : col.name"
4748
>
4849
{{ col.name }}<template v-if="col.version">@{{ col.version }}</template>

app/components/Header/AuthModal.client.vue

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,7 @@ watch(handleInput, newHandleInput => {
142142
{{ $t('auth.modal.create_account') }}
143143
</ButtonBase>
144144
<hr class="color-border" />
145-
<ButtonBase
146-
type="button"
147-
variant="primary"
148-
class="w-full flex items-center justify-center gap-2"
149-
@click="handleBlueskySignIn"
150-
>
145+
<ButtonBase type="button" variant="primary" class="w-full" @click="handleBlueskySignIn" block>
151146
{{ $t('auth.modal.connect_bluesky') }}
152147
<svg fill="none" viewBox="0 0 64 57" width="20" style="width: 20px">
153148
<path

app/components/Link/Base.vue

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const props = withDefaults(
1212
type?: never
1313
variant?: 'button-primary' | 'button-secondary' | 'link'
1414
size?: 'small' | 'medium'
15-
iconSize?: 'sm' | 'md' | 'lg'
15+
block?: boolean
1616
1717
ariaKeyshortcuts?: string
1818
@@ -50,28 +50,20 @@ const isLinkAnchor = computed(
5050
() => !!props.to && typeof props.to === 'string' && props.to.startsWith('#'),
5151
)
5252
53-
const ICON_SIZE_MAP = {
54-
sm: 'size-3 min-w-3',
55-
md: 'size-4 min-w-4',
56-
lg: 'size-5 min-w-5',
57-
}
58-
5953
/** size is only applicable for button like links */
6054
const isLink = computed(() => props.variant === 'link')
61-
const isButton = computed(() => props.variant !== 'link')
62-
const isButtonSmall = computed(() => props.size === 'small' && props.variant !== 'link')
63-
const isButtonMedium = computed(() => props.size === 'medium' && props.variant !== 'link')
64-
65-
const iconSizeClass = computed(
66-
() => ICON_SIZE_MAP[props.iconSize || (isButtonSmall.value && 'sm') || 'md'],
67-
)
55+
const isButton = computed(() => !isLink.value)
56+
const isButtonSmall = computed(() => props.size === 'small' && !isLink.value)
57+
const isButtonMedium = computed(() => props.size === 'medium' && !isLink.value)
6858
</script>
6959

7060
<template>
7161
<span
7262
v-if="disabled"
7363
:class="{
74-
'opacity-50 inline-flex gap-x-1 items-center justify-center font-mono border border-transparent rounded-md':
64+
'flex': block,
65+
'inline-flex': !block,
66+
'opacity-50 gap-x-1 items-center justify-center font-mono border border-transparent rounded-md':
7567
isButton,
7668
'text-sm px-4 py-2': isButtonMedium,
7769
'text-xs px-2 py-0.5': isButtonSmall,
@@ -82,13 +74,16 @@ const iconSizeClass = computed(
8274
/></span>
8375
<NuxtLink
8476
v-else
85-
class="group/link inline-flex gap-x-1 items-center justify-center"
77+
class="group/link gap-x-1 items-center"
8678
:class="{
79+
'flex': block,
80+
'inline-flex': !block,
8781
'underline-offset-[0.2rem] underline decoration-1 decoration-fg/30':
8882
!isLinkAnchor && isLink && !noUnderline,
89-
'font-mono text-fg hover:(decoration-accent text-accent) focus-visible:(decoration-accent text-accent) transition-colors duration-200':
83+
'justify-start font-mono text-fg hover:(decoration-accent text-accent) focus-visible:(decoration-accent text-accent) transition-colors duration-200':
9084
isLink,
91-
'font-mono border border-border rounded-md transition-all duration-200': isButton,
85+
'justify-center font-mono border border-border rounded-md transition-all duration-200':
86+
isButton,
9287
'text-sm px-4 py-2': isButtonMedium,
9388
'text-xs px-2 py-0.5': isButtonSmall,
9489
'bg-transparent text-fg hover:(bg-fg/10 text-accent) focus-visible:(bg-fg/10 text-accent) aria-[current=true]:(bg-fg/10 text-accent border-fg/20 hover:enabled:(bg-fg/20 text-fg/50))':
@@ -100,22 +95,22 @@ const iconSizeClass = computed(
10095
:aria-keyshortcuts="ariaKeyshortcuts"
10196
:target="isLinkExternal ? '_blank' : undefined"
10297
>
103-
<span v-if="classicon" class="me-1" :class="[iconSizeClass, classicon]" aria-hidden="true" />
98+
<span v-if="classicon" class="size-[1em]" :class="classicon" aria-hidden="true" />
10499
<slot />
105100
<!-- automatically show icon indicating external link -->
106101
<span
107102
v-if="isLinkExternal && !classicon"
108-
class="i-carbon:launch rtl-flip w-3 h-3 opacity-50"
103+
class="i-carbon:launch rtl-flip size-[1em] opacity-50"
109104
aria-hidden="true"
110105
/>
111106
<span
112107
v-else-if="isLinkAnchor && isLink"
113-
class="i-carbon:link w-3 h-3 opacity-0 group-hover/link:opacity-100 transition-opacity duration-200"
108+
class="i-carbon:link size-[1em] opacity-0 group-hover/link:opacity-100 transition-opacity duration-200"
114109
aria-hidden="true"
115110
/>
116111
<kbd
117112
v-if="ariaKeyshortcuts"
118-
class="ms-2 inline-flex items-center justify-center w-4 h-4 text-xs text-fg bg-bg-muted border border-border rounded no-underline"
113+
class="ms-2 inline-flex items-center justify-center size-4 text-xs text-fg bg-bg-muted border border-border rounded no-underline"
119114
aria-hidden="true"
120115
>
121116
{{ ariaKeyshortcuts }}

app/components/Package/Versions.vue

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -354,33 +354,31 @@ function getTagVersions(tag: string): VersionDisplay[] {
354354
<!-- Version info -->
355355
<div class="flex-1 py-1.5 min-w-0 flex gap-2 justify-between items-center">
356356
<div class="overflow-hidden">
357-
<div>
358-
<LinkBase
359-
:to="versionRoute(row.primaryVersion.version)"
360-
class="text-sm block truncate"
361-
:class="
362-
row.primaryVersion.deprecated ? 'text-red-400 hover:text-red-300' : undefined
363-
"
364-
:title="
365-
row.primaryVersion.deprecated
366-
? $t('package.versions.deprecated_title', {
367-
version: row.primaryVersion.version,
368-
})
369-
: row.primaryVersion.version
370-
"
371-
:classicon="row.primaryVersion.deprecated ? 'i-carbon-warning-hex' : undefined"
372-
icon-size="sm"
373-
>
374-
<span dir="ltr">
375-
{{ row.primaryVersion.version }}
376-
</span>
377-
</LinkBase>
378-
</div>
357+
<LinkBase
358+
:to="versionRoute(row.primaryVersion.version)"
359+
block
360+
class="text-sm"
361+
:class="
362+
row.primaryVersion.deprecated ? 'text-red-400 hover:text-red-300' : undefined
363+
"
364+
:title="
365+
row.primaryVersion.deprecated
366+
? $t('package.versions.deprecated_title', {
367+
version: row.primaryVersion.version,
368+
})
369+
: row.primaryVersion.version
370+
"
371+
:classicon="row.primaryVersion.deprecated ? 'i-carbon-warning-hex' : undefined"
372+
>
373+
<span dir="ltr" class="block truncate">
374+
{{ row.primaryVersion.version }}
375+
</span>
376+
</LinkBase>
379377
<div v-if="row.tags.length" class="flex items-center gap-1 mt-0.5 flex-wrap">
380378
<span
381379
v-for="tag in row.tags"
382380
:key="tag"
383-
class="text-4xs font-semibold text-fg-subtle uppercase tracking-wide truncate max-w-[150px]"
381+
class="text-4xs font-semibold text-fg-subtle uppercase tracking-wide truncate"
384382
:title="tag"
385383
>
386384
{{ tag }}
@@ -415,17 +413,17 @@ function getTagVersions(tag: string): VersionDisplay[] {
415413
<div class="flex items-center justify-between gap-2">
416414
<LinkBase
417415
:to="versionRoute(v.version)"
418-
class="text-xs block truncate"
416+
block
417+
class="text-xs"
419418
:class="v.deprecated ? 'text-red-400 hover:text-red-300' : undefined"
420419
:title="
421420
v.deprecated
422421
? $t('package.versions.deprecated_title', { version: v.version })
423422
: v.version
424423
"
425424
:classicon="v.deprecated ? 'i-carbon-warning-hex' : undefined"
426-
icon-size="sm"
427425
>
428-
<span dir="ltr">
426+
<span dir="ltr" class="block truncate">
429427
{{ v.version }}
430428
</span>
431429
</LinkBase>
@@ -513,7 +511,8 @@ function getTagVersions(tag: string): VersionDisplay[] {
513511
<div class="flex items-center justify-between gap-2">
514512
<LinkBase
515513
:to="versionRoute(row.primaryVersion.version)"
516-
class="text-xs block truncate"
514+
block
515+
class="text-xs"
517516
:class="
518517
row.primaryVersion.deprecated ? 'text-red-400 hover:text-red-300' : undefined
519518
"
@@ -525,9 +524,8 @@ function getTagVersions(tag: string): VersionDisplay[] {
525524
: row.primaryVersion.version
526525
"
527526
:classicon="row.primaryVersion.deprecated ? 'i-carbon-warning-hex' : undefined"
528-
icon-size="sm"
529527
>
530-
<span dir="ltr">
528+
<span dir="ltr" class="block truncate">
531529
{{ row.primaryVersion.version }}
532530
</span>
533531
</LinkBase>
@@ -586,7 +584,8 @@ function getTagVersions(tag: string): VersionDisplay[] {
586584
<LinkBase
587585
v-if="group.versions[0]?.version"
588586
:to="versionRoute(group.versions[0]?.version)"
589-
class="text-xs block truncate"
587+
block
588+
class="text-xs"
590589
:class="
591590
group.versions[0]?.deprecated
592591
? 'text-red-400 hover:text-red-300'
@@ -602,9 +601,8 @@ function getTagVersions(tag: string): VersionDisplay[] {
602601
:classicon="
603602
group.versions[0]?.deprecated ? 'i-carbon-warning-hex' : undefined
604603
"
605-
icon-size="sm"
606604
>
607-
<span dir="ltr">
605+
<span dir="ltr" class="block truncate">
608606
{{ group.versions[0]?.version }}
609607
</span>
610608
</LinkBase>
@@ -644,11 +642,11 @@ function getTagVersions(tag: string): VersionDisplay[] {
644642
<div v-else class="py-1">
645643
<div class="flex items-center justify-between gap-2">
646644
<div class="flex items-center gap-2 min-w-0">
647-
<span class="w-4 shrink-0" />
648645
<LinkBase
649646
v-if="group.versions[0]?.version"
650647
:to="versionRoute(group.versions[0]?.version)"
651-
class="text-xs block truncate"
648+
block
649+
class="text-xs ms-6"
652650
:class="
653651
group.versions[0]?.deprecated
654652
? 'text-red-400 hover:text-red-300'
@@ -664,9 +662,8 @@ function getTagVersions(tag: string): VersionDisplay[] {
664662
:classicon="
665663
group.versions[0]?.deprecated ? 'i-carbon-warning-hex' : undefined
666664
"
667-
icon-size="sm"
668665
>
669-
<span dir="ltr">
666+
<span dir="ltr" class="block truncate">
670667
{{ group.versions[0]?.version }}
671668
</span>
672669
</LinkBase>
@@ -708,7 +705,8 @@ function getTagVersions(tag: string): VersionDisplay[] {
708705
<div class="flex items-center justify-between gap-2">
709706
<LinkBase
710707
:to="versionRoute(v.version)"
711-
class="text-xs block truncate"
708+
block
709+
class="text-xs"
712710
:class="v.deprecated ? 'text-red-400 hover:text-red-300' : undefined"
713711
:title="
714712
v.deprecated
@@ -717,7 +715,7 @@ function getTagVersions(tag: string): VersionDisplay[] {
717715
"
718716
:classicon="v.deprecated ? 'i-carbon-warning-hex' : undefined"
719717
>
720-
<span dir="ltr">
718+
<span dir="ltr" class="block truncate">
721719
{{ v.version }}
722720
</span>
723721
</LinkBase>

app/components/ReadmeTocDropdown.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ function handleKeydown(event: KeyboardEvent) {
152152
@click="toggle"
153153
@keydown="handleKeydown"
154154
classicon="i-carbon:list"
155-
class="px-2.5 flex items-center"
155+
class="px-2.5"
156+
block
156157
>
157158
<span
158159
class="i-carbon:chevron-down w-3 h-3"

app/components/Tag/Static.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const props = withDefaults(
1616
class="bg-bg-muted text-fg-muted inline-flex gap-x-1 items-center justify-center font-mono border border-transparent rounded-md text-xs px-2 py-0.5"
1717
:class="{ 'opacity-40': variant === 'ghost' }"
1818
>
19-
<span v-if="classicon" :class="['size-3', classicon]" aria-hidden="true" />
19+
<span v-if="classicon" class="size-[1em]" :class="classicon" aria-hidden="true" />
2020
<slot />
2121
</component>
2222
</template>

0 commit comments

Comments
 (0)