Skip to content

Commit 51b4fd5

Browse files
committed
feat: allow to make links block elements and make buttons blocks by default
1 parent 37412df commit 51b4fd5

3 files changed

Lines changed: 27 additions & 16 deletions

File tree

app/components/Button/Base.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ defineExpose({
3232
<template>
3333
<button
3434
ref="el"
35-
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)"
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)"
3636
:class="{
3737
'text-sm px-4 py-2': size === 'medium',
3838
'text-xs px-2 py-0.5': size === 'small',

app/components/Link/Base.vue

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ 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'
13+
'variant'?: 'button-primary' | 'button-secondary' | 'link' | 'link-block'
1414
'size'?: 'small' | 'medium'
1515
1616
'keyshortcut'?: string
@@ -52,17 +52,20 @@ const isLinkAnchor = computed(
5252
)
5353
5454
/** size is only applicable for button like links */
55-
const isLink = computed(() => props.variant === 'link')
56-
const isButton = computed(() => props.variant !== 'link')
57-
const isButtonSmall = computed(() => props.size === 'small' && props.variant !== 'link')
58-
const isButtonMedium = computed(() => props.size === 'medium' && props.variant !== 'link')
55+
const isLink = computed(() => props.variant === 'link' || props.variant === 'link-block')
56+
const isButton = computed(() => !isLink.value)
57+
const isButtonSmall = computed(() => props.size === 'small' && !isLink.value)
58+
const isButtonMedium = computed(() => props.size === 'medium' && !isLink.value)
59+
const isBlock = computed(() => isButton || props.variant === 'link-block')
5960
</script>
6061

6162
<template>
6263
<span
6364
v-if="disabled"
6465
:class="{
65-
'opacity-50 inline-flex gap-x-1 items-center justify-center font-mono border border-transparent rounded-md':
66+
'flex': isBlock,
67+
'inline-flex': !isBlock,
68+
'opacity-50 gap-x-1 items-center justify-center font-mono border border-transparent rounded-md':
6669
isButton,
6770
'text-sm px-4 py-2': isButtonMedium,
6871
'text-xs px-2 py-0.5': isButtonSmall,
@@ -73,12 +76,14 @@ const isButtonMedium = computed(() => props.size === 'medium' && props.variant !
7376
/></span>
7477
<NuxtLink
7578
v-else
76-
class="group/link inline-flex gap-x-1 items-center justify-center"
79+
class="group/link gap-x-1 items-center"
7780
:class="{
81+
'flex': isBlock,
82+
'inline-flex': !isBlock,
7883
'underline-offset-[0.2rem] underline decoration-1 decoration-fg/30': !isLinkAnchor && isLink,
79-
'font-mono text-fg hover:(decoration-accent text-accent) focus-visible:(decoration-accent text-accent) transition-colors duration-200':
84+
'justify-start font-mono text-fg hover:(decoration-accent text-accent) focus-visible:(decoration-accent text-accent) transition-colors duration-200':
8085
isLink,
81-
'font-mono border border-border rounded-md transition-all duration-200': isButton,
86+
'justify-center font-mono border border-border rounded-md transition-all duration-200': isButton,
8287
'text-sm px-4 py-2': isButtonMedium,
8388
'text-xs px-2 py-0.5': isButtonSmall,
8489
'bg-transparent text-fg hover:(bg-fg/10) focus-visible:(bg-fg/10)':

app/components/Package/Versions.vue

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,8 @@ function getTagVersions(tag: string): VersionDisplay[] {
356356
<div class="overflow-hidden">
357357
<LinkBase
358358
:to="versionRoute(row.primaryVersion.version)"
359-
class="text-sm flex!"
359+
variant="link-block"
360+
class="text-sm"
360361
:class="
361362
row.primaryVersion.deprecated ? 'text-red-400 hover:text-red-300' : undefined
362363
"
@@ -412,7 +413,8 @@ function getTagVersions(tag: string): VersionDisplay[] {
412413
<div class="flex items-center justify-between gap-2">
413414
<LinkBase
414415
:to="versionRoute(v.version)"
415-
class="text-xs flex!"
416+
variant="link-block"
417+
class="text-xs"
416418
:class="v.deprecated ? 'text-red-400 hover:text-red-300' : undefined"
417419
:title="
418420
v.deprecated
@@ -509,7 +511,8 @@ function getTagVersions(tag: string): VersionDisplay[] {
509511
<div class="flex items-center justify-between gap-2">
510512
<LinkBase
511513
:to="versionRoute(row.primaryVersion.version)"
512-
class="text-xs flex!"
514+
variant="link-block"
515+
class="text-xs"
513516
:class="
514517
row.primaryVersion.deprecated ? 'text-red-400 hover:text-red-300' : undefined
515518
"
@@ -581,7 +584,8 @@ function getTagVersions(tag: string): VersionDisplay[] {
581584
<LinkBase
582585
v-if="group.versions[0]?.version"
583586
:to="versionRoute(group.versions[0]?.version)"
584-
class="text-xs flex!"
587+
variant="link-block"
588+
class="text-xs"
585589
:class="
586590
group.versions[0]?.deprecated
587591
? 'text-red-400 hover:text-red-300'
@@ -642,7 +646,8 @@ function getTagVersions(tag: string): VersionDisplay[] {
642646
<LinkBase
643647
v-if="group.versions[0]?.version"
644648
:to="versionRoute(group.versions[0]?.version)"
645-
class="text-xs flex!"
649+
variant="link-block"
650+
class="text-xs"
646651
:class="
647652
group.versions[0]?.deprecated
648653
? 'text-red-400 hover:text-red-300'
@@ -701,7 +706,8 @@ function getTagVersions(tag: string): VersionDisplay[] {
701706
<div class="flex items-center justify-between gap-2">
702707
<LinkBase
703708
:to="versionRoute(v.version)"
704-
class="text-xs flex!"
709+
variant="link-block"
710+
class="text-xs"
705711
:class="v.deprecated ? 'text-red-400 hover:text-red-300' : undefined"
706712
:title="
707713
v.deprecated

0 commit comments

Comments
 (0)