Skip to content

Commit 86242b9

Browse files
committed
refactor: add explicit block prop to link and button comps
1 parent 322495f commit 86242b9

7 files changed

Lines changed: 21 additions & 24 deletions

File tree

app/components/Button/Base.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const props = withDefaults(
66
'variant'?: 'primary' | 'secondary'
77
'size'?: 'small' | 'medium'
88
'keyshortcut'?: string
9+
'block'?: boolean
910
1011
/**
1112
* Do not use this directly. Use keyshortcut instead; it generates the correct HTML and displays the shortcut in the UI.
@@ -32,8 +33,10 @@ defineExpose({
3233
<template>
3334
<button
3435
ref="el"
35-
class="group cursor-pointer 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)"
36+
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)"
3637
:class="{
38+
'inline-flex': !block,
39+
'flex': block,
3740
'text-sm px-4 py-2': size === 'medium',
3841
'text-xs px-2 py-0.5': size === 'small',
3942
'bg-transparent text-fg hover:enabled:(bg-fg/10) focus-visible:enabled:(bg-fg/10) aria-pressed:(bg-fg text-bg border-fg hover:enabled:(bg-fg text-bg/50))':

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/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: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ const props = withDefaults(
1010
* `type` should never be used, because this will always be a link.
1111
* */
1212
'type'?: never
13-
'variant'?: 'button-primary' | 'button-secondary' | 'link' | 'link-block'
13+
'variant'?: 'button-primary' | 'button-secondary' | 'link'
1414
'size'?: 'small' | 'medium'
15+
'block'?: boolean
1516
1617
'keyshortcut'?: string
1718
@@ -52,19 +53,18 @@ const isLinkAnchor = computed(
5253
)
5354
5455
/** size is only applicable for button like links */
55-
const isLink = computed(() => props.variant === 'link' || props.variant === 'link-block')
56+
const isLink = computed(() => props.variant === 'link')
5657
const isButton = computed(() => !isLink.value)
5758
const isButtonSmall = computed(() => props.size === 'small' && !isLink.value)
5859
const isButtonMedium = computed(() => props.size === 'medium' && !isLink.value)
59-
const isBlock = computed(() => isButton.value || props.variant === 'link-block')
6060
</script>
6161

6262
<template>
6363
<span
6464
v-if="disabled"
6565
:class="{
66-
'flex': isBlock,
67-
'inline-flex': !isBlock,
66+
'flex': block,
67+
'inline-flex': !block,
6868
'opacity-50 gap-x-1 items-center justify-center font-mono border border-transparent rounded-md':
6969
isButton,
7070
'text-sm px-4 py-2': isButtonMedium,
@@ -78,8 +78,8 @@ const isBlock = computed(() => isButton.value || props.variant === 'link-block')
7878
v-else
7979
class="group/link gap-x-1 items-center"
8080
:class="{
81-
'flex': isBlock,
82-
'inline-flex': !isBlock,
81+
'flex': block,
82+
'inline-flex': !block,
8383
'underline-offset-[0.2rem] underline decoration-1 decoration-fg/30': !isLinkAnchor && isLink,
8484
'justify-start font-mono text-fg hover:(decoration-accent text-accent) focus-visible:(decoration-accent text-accent) transition-colors duration-200':
8585
isLink,

app/components/Package/Versions.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ function getTagVersions(tag: string): VersionDisplay[] {
356356
<div class="overflow-hidden">
357357
<LinkBase
358358
:to="versionRoute(row.primaryVersion.version)"
359-
variant="link-block"
359+
block
360360
class="text-sm"
361361
:class="
362362
row.primaryVersion.deprecated ? 'text-red-400 hover:text-red-300' : undefined
@@ -413,7 +413,7 @@ function getTagVersions(tag: string): VersionDisplay[] {
413413
<div class="flex items-center justify-between gap-2">
414414
<LinkBase
415415
:to="versionRoute(v.version)"
416-
variant="link-block"
416+
block
417417
class="text-xs"
418418
:class="v.deprecated ? 'text-red-400 hover:text-red-300' : undefined"
419419
:title="
@@ -511,7 +511,7 @@ function getTagVersions(tag: string): VersionDisplay[] {
511511
<div class="flex items-center justify-between gap-2">
512512
<LinkBase
513513
:to="versionRoute(row.primaryVersion.version)"
514-
variant="link-block"
514+
block
515515
class="text-xs"
516516
:class="
517517
row.primaryVersion.deprecated ? 'text-red-400 hover:text-red-300' : undefined
@@ -584,7 +584,7 @@ function getTagVersions(tag: string): VersionDisplay[] {
584584
<LinkBase
585585
v-if="group.versions[0]?.version"
586586
:to="versionRoute(group.versions[0]?.version)"
587-
variant="link-block"
587+
block
588588
class="text-xs"
589589
:class="
590590
group.versions[0]?.deprecated
@@ -645,7 +645,7 @@ function getTagVersions(tag: string): VersionDisplay[] {
645645
<LinkBase
646646
v-if="group.versions[0]?.version"
647647
:to="versionRoute(group.versions[0]?.version)"
648-
variant="link-block"
648+
block
649649
class="text-xs ms-6"
650650
:class="
651651
group.versions[0]?.deprecated
@@ -705,7 +705,7 @@ function getTagVersions(tag: string): VersionDisplay[] {
705705
<div class="flex items-center justify-between gap-2">
706706
<LinkBase
707707
:to="versionRoute(v.version)"
708-
variant="link-block"
708+
block
709709
class="text-xs"
710710
:class="v.deprecated ? 'text-red-400 hover:text-red-300' : undefined"
711711
:title="

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/pages/package-code/[...path].vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,6 @@ defineOgImageComponent('Default', {
497497
<LinkBase
498498
variant="button-secondary"
499499
:to="`https://cdn.jsdelivr.net/npm/${packageName}@${version}/${filePath}`"
500-
class="inline-flex items-center gap-2"
501500
>
502501
{{ $t('code.view_raw') }}
503502
</LinkBase>
@@ -549,7 +548,6 @@ defineOgImageComponent('Default', {
549548
<LinkBase
550549
variant="button-secondary"
551550
:to="`https://cdn.jsdelivr.net/npm/${packageName}@${version}/${filePath}`"
552-
class="inline-flex items-center gap-2"
553551
>
554552
{{ $t('code.view_raw') }}
555553
</LinkBase>

0 commit comments

Comments
 (0)