|
1 | 1 | <script setup lang="ts"> |
2 | 2 | import type { NuxtLinkProps } from '#app' |
3 | 3 |
|
4 | | -const props = defineProps< |
5 | | - { |
6 | | - /** Disabled links will be displayed as plain text */ |
7 | | - disabled?: boolean |
8 | | - /** |
9 | | - * `type` should never be used, because this will always be a link. |
10 | | - * |
11 | | - * If you want a button use `TagButton` instead. |
12 | | - * */ |
13 | | - type?: never |
14 | | - } & |
15 | | - /** This makes sure the link always has either `to` or `href` */ |
16 | | - (Required<Pick<NuxtLinkProps, 'to'>> | Required<Pick<NuxtLinkProps, 'href'>>) & |
17 | | - NuxtLinkProps |
18 | | ->() |
| 4 | +const props = withDefaults( |
| 5 | + defineProps< |
| 6 | + { |
| 7 | + /** Disabled links will be displayed as plain text */ |
| 8 | + disabled?: boolean |
| 9 | + /** |
| 10 | + * `type` should never be used, because this will always be a link. |
| 11 | + * |
| 12 | + * If you want a button use `TagButton` instead. |
| 13 | + * */ |
| 14 | + type?: never |
| 15 | + variant?: 'primary' | 'secondary' |
| 16 | + } & |
| 17 | + /** This makes sure the link always has either `to` or `href` */ |
| 18 | + (Required<Pick<NuxtLinkProps, 'to'>> | Required<Pick<NuxtLinkProps, 'href'>>) & |
| 19 | + NuxtLinkProps |
| 20 | + >(), |
| 21 | + { variant: 'secondary' }, |
| 22 | +) |
19 | 23 | </script> |
20 | 24 |
|
21 | 25 | <template> |
22 | 26 | <!-- This is only a placeholder implementation yet. It will probably need some additional styling, but note: A disabled link is just text. --> |
23 | 27 | <span v-if="disabled" class="opacity-50"><slot /></span> |
24 | 28 | <NuxtLink |
25 | 29 | v-else |
26 | | - class="inline-flex items-center justify-center px-4 py-2 font-mono text-sm border border-border rounded-md bg-transparent text-fg transition-all duration-200 hover:(bg-fg hover:text-bg border-fg) focus-ring active:scale-98 disabled:(opacity-40 cursor-not-allowed hover:bg-transparent hover:text-fg)" |
27 | | - :class=" |
28 | | - { |
29 | | - 'opacity-50 cursor-not-allowed': disabled, |
30 | | - } |
31 | | - " |
| 30 | + class="inline-flex gap-x-1 items-center justify-center px-4 py-2 font-mono text-sm border border-border rounded-md transition-all duration-200" |
| 31 | + :class="[ |
| 32 | + variant === 'primary' |
| 33 | + ? 'text-bg bg-fg hover:enabled:(bg-fg/90)' |
| 34 | + : 'bg-transparent text-fg hover:enabled:(bg-fg text-bg border-fg)', |
| 35 | + ]" |
32 | 36 | > |
33 | 37 | <slot /> |
34 | 38 | </NuxtLink> |
|
0 commit comments