@@ -10,7 +10,8 @@ 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' | ' tag' | ' link'
13+ ' variant' ?: ' button-primary' | ' button-secondary' | ' link'
14+ ' size' ?: ' small' | ' medium'
1415
1516 ' keyshortcut' ?: string
1617
@@ -37,7 +38,7 @@ const props = withDefaults(
3738 ' href' ?: never
3839 } & NuxtLinkProps
3940 > (),
40- { variant: ' link' },
41+ { variant: ' link' , size: ' medium ' },
4142)
4243
4344const isLinkExternal = computed (
@@ -49,17 +50,22 @@ const isLinkExternal = computed(
4950const isLinkAnchor = computed (
5051 () => !! props .to && typeof props .to === ' string' && props .to .startsWith (' #' ),
5152)
53+
54+ /** 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' )
5259 </script >
5360
5461<template >
5562 <span
5663 v-if =" disabled"
5764 :class =" {
5865 'opacity-50 inline-flex gap-x-1 items-center justify-center font-mono border border-transparent rounded-md':
59- variant !== 'link',
60- 'text-sm px-4 py-2': variant !== 'tag' && variant !== 'link',
61- 'text-xs px-2 py-0.5': variant === 'tag',
62- 'bg-bg-muted text-fg-muted': variant === 'tag',
66+ isButton,
67+ 'text-sm px-4 py-2': isButtonMedium,
68+ 'text-xs px-2 py-0.5': isButtonSmall,
6369 'text-bg bg-fg': variant === 'button-primary',
6470 'bg-transparent text-fg': variant === 'button-secondary',
6571 }"
@@ -69,16 +75,15 @@ const isLinkAnchor = computed(
6975 v-else
7076 class =" group inline-flex gap-x-1 items-center justify-center"
7177 :class =" {
72- 'underline-offset-[0.2rem] underline decoration-1 decoration-fg/50':
73- !isLinkAnchor && variant === 'link',
78+ 'underline-offset-[0.2rem] underline decoration-1 decoration-fg/50': !isLinkAnchor && isLink,
7479 'text-fg hover:(no-underline text-accent) focus-visible:(no-underline text-accent) transition-colors duration-200':
75- variant === 'link' ,
80+ isLink ,
7681 'font-mono border border-border rounded-md transition-all duration-200 aria-current:(bg-fg text-bg border-fg hover:(text-bg/50)) bg-gradient-to-t dark:bg-gradient-to-b':
77- variant !== 'link' ,
78- 'text-sm px-4 py-2': variant !== 'tag' && variant !== 'link' ,
79- 'text-xs px-2 py-0.5': variant === 'tag' ,
82+ isButton ,
83+ 'text-sm px-4 py-2': isButtonMedium ,
84+ 'text-xs px-2 py-0.5': isButtonSmall ,
8085 'from-fg/10 via-transparent to-transparent text-fg hover:(bg-accent/20 border-accent) focus-visible:(bg-accent/20 border-accent)':
81- variant === 'tag' || variant === ' button-secondary',
86+ variant === 'button-secondary',
8287 'text-black from-accent via-accent to-accent/30 hover:(bg-accent/50) focus-visible:(bg-accent/50)':
8388 variant === 'button-primary',
8489 }"
@@ -91,7 +96,7 @@ const isLinkAnchor = computed(
9196 >
9297 <span
9398 v-if =" classicon"
94- :class =" [variant === 'tag' ? 'size-3' : 'size-4', classicon]"
99+ :class =" [isButtonSmall ? 'size-3' : 'size-4', classicon]"
95100 aria-hidden =" true"
96101 />
97102 <slot />
@@ -102,7 +107,7 @@ const isLinkAnchor = computed(
102107 aria-hidden =" true"
103108 />
104109 <span
105- v-else-if =" isLinkAnchor && variant === 'link' "
110+ v-else-if =" isLinkAnchor && isLink "
106111 class =" i-carbon:link w-3 h-3 opacity-0 group-hover:opacity-100 transition-opacity duration-200"
107112 aria-hidden =" true"
108113 />
0 commit comments