Skip to content

Commit 342fb82

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

3 files changed

Lines changed: 23 additions & 13 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: 12 additions & 7 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,8 +76,10 @@ 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 justify-center"
7780
:class="{
81+
'flex': isBlock,
82+
'inline-flex': !isBlock,
7883
'underline-offset-[0.2rem] underline decoration-1 decoration-fg/30': !isLinkAnchor && isLink,
7984
'font-mono text-fg hover:(decoration-accent text-accent) focus-visible:(decoration-accent text-accent) transition-colors duration-200':
8085
isLink,

app/components/Package/Versions.vue

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,8 @@ function getTagVersions(tag: string): VersionDisplay[] {
412412
<div class="flex items-center justify-between gap-2">
413413
<LinkBase
414414
:to="versionRoute(v.version)"
415-
class="text-xs flex!"
415+
variant="link-block"
416+
class="text-xs"
416417
:class="v.deprecated ? 'text-red-400 hover:text-red-300' : undefined"
417418
:title="
418419
v.deprecated
@@ -509,7 +510,8 @@ function getTagVersions(tag: string): VersionDisplay[] {
509510
<div class="flex items-center justify-between gap-2">
510511
<LinkBase
511512
:to="versionRoute(row.primaryVersion.version)"
512-
class="text-xs flex!"
513+
variant="link-block"
514+
class="text-xs"
513515
:class="
514516
row.primaryVersion.deprecated ? 'text-red-400 hover:text-red-300' : undefined
515517
"
@@ -581,7 +583,8 @@ function getTagVersions(tag: string): VersionDisplay[] {
581583
<LinkBase
582584
v-if="group.versions[0]?.version"
583585
:to="versionRoute(group.versions[0]?.version)"
584-
class="text-xs flex!"
586+
variant="link-block"
587+
class="text-xs"
585588
:class="
586589
group.versions[0]?.deprecated
587590
? 'text-red-400 hover:text-red-300'
@@ -642,7 +645,8 @@ function getTagVersions(tag: string): VersionDisplay[] {
642645
<LinkBase
643646
v-if="group.versions[0]?.version"
644647
:to="versionRoute(group.versions[0]?.version)"
645-
class="text-xs flex!"
648+
variant="link-block"
649+
class="text-xs"
646650
:class="
647651
group.versions[0]?.deprecated
648652
? 'text-red-400 hover:text-red-300'
@@ -701,7 +705,8 @@ function getTagVersions(tag: string): VersionDisplay[] {
701705
<div class="flex items-center justify-between gap-2">
702706
<LinkBase
703707
:to="versionRoute(v.version)"
704-
class="text-xs flex!"
708+
variant="link-block"
709+
class="text-xs"
705710
:class="v.deprecated ? 'text-red-400 hover:text-red-300' : undefined"
706711
:title="
707712
v.deprecated

0 commit comments

Comments
 (0)