From 1ab5a1699e8340601ca82cf008c028b8d7a8ff9a Mon Sep 17 00:00:00 2001 From: RYGRIT Date: Tue, 10 Feb 2026 15:58:36 +0800 Subject: [PATCH 1/3] refactor(link-base): update size and tests --- app/components/Link/Base.vue | 94 ++++++++++++++++----------- test/nuxt/a11y.spec.ts | 29 +++++++-- test/nuxt/components/LinkBase.spec.ts | 53 +++++++++++++++ 3 files changed, 131 insertions(+), 45 deletions(-) create mode 100644 test/nuxt/components/LinkBase.spec.ts diff --git a/app/components/Link/Base.vue b/app/components/Link/Base.vue index eeb1b9bf9..fc0cda230 100644 --- a/app/components/Link/Base.vue +++ b/app/components/Link/Base.vue @@ -7,12 +7,11 @@ const props = withDefaults( /** Disabled links will be displayed as plain text */ disabled?: boolean /** - * `type` should never be used, because this will always be a link. - * */ - type?: never - variant?: 'button-primary' | 'button-secondary' | 'link' - size?: 'small' | 'medium' - block?: boolean + * Controls whether the link is styled as text or as a button. + */ + type?: 'button' | 'link' + size?: 'xs' | 'sm' | 'md' | 'lg' + inline?: boolean ariaKeyshortcuts?: string @@ -37,7 +36,7 @@ const props = withDefaults( noUnderline?: boolean } & NuxtLinkProps >(), - { variant: 'link', size: 'medium' }, + { type: 'link', size: 'md', inline: true }, ) const isLinkExternal = computed( @@ -50,47 +49,66 @@ const isLinkAnchor = computed( () => !!props.to && typeof props.to === 'string' && props.to.startsWith('#'), ) -/** size is only applicable for button like links */ -const isLink = computed(() => props.variant === 'link') -const isButton = computed(() => !isLink.value) -const isButtonSmall = computed(() => props.size === 'small' && !isLink.value) -const isButtonMedium = computed(() => props.size === 'medium' && !isLink.value) +const isLink = computed(() => props.type === 'link') +const isButton = computed(() => props.type === 'button') +const sizeClass = computed(() => { + if (isButton.value) { + switch (props.size) { + case 'xs': + return 'text-xs px-2 py-0.5' + case 'sm': + return 'text-sm px-4 py-2' + case 'md': + return 'text-base px-5 py-2.5' + case 'lg': + return 'text-lg px-6 py-3' + } + } + + switch (props.size) { + case 'xs': + return 'text-xs' + case 'sm': + return 'text-sm' + case 'md': + return 'text-base' + case 'lg': + return 'text-lg' + } +})