Skip to content

Commit

Permalink
fix(Button): inherit nuxt link props without breaking `nuxt-component…
Browse files Browse the repository at this point in the history
…-meta`

Resolves #578
  • Loading branch information
benjamincanac committed Jan 10, 2024
1 parent cefa597 commit d3e19dc
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/runtime/components/elements/Button.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import UIcon from '../elements/Icon.vue'
import ULink from '../elements/Link.vue'
import { useUI } from '../../composables/useUI'
import { mergeConfig } from '../../utils'
import { nuxtLinkProps } from '../../utils/nuxt-link'
import { useInjectButtonGroup } from '../../composables/useButtonGroup'
import type { ButtonColor, ButtonSize, ButtonVariant, Strategy } from '../../types'
// @ts-expect-error
Expand All @@ -39,6 +40,7 @@ export default defineComponent({
},
inheritAttrs: false,
props: {
...nuxtLinkProps,
type: {
type: String,
default: 'button'
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/components/elements/Link.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
<script lang="ts">
import { isEqual } from 'ohash'
import { defineComponent } from 'vue'
import { NuxtLink } from '#components'
import { nuxtLinkProps } from '../../utils/nuxt-link'
export default defineComponent({
inheritAttrs: false,
props: {
...NuxtLink.props,
...nuxtLinkProps,
as: {
type: String,
default: 'button'
Expand Down
62 changes: 62 additions & 0 deletions src/runtime/utils/nuxt-link.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import type { PropType } from 'vue'
import type { RouteLocationRaw } from '#vue-router'

export const nuxtLinkProps = {
to: {
type: [String, Object] as PropType<RouteLocationRaw>,
default: undefined
},
href: {
type: [String, Object] as PropType<RouteLocationRaw>,
default: undefined
},
// Attributes
target: {
type: String as PropType<'_blank' | '_parent' | '_self' | '_top' | (string & {}) | null>,
default: undefined
},
rel: {
type: String,
default: undefined
},
noRel: {
type: Boolean,
default: undefined
},
// Prefetching
prefetch: {
type: Boolean,
default: undefined
},
noPrefetch: {
type: Boolean,
default: undefined
},
// Styling
activeClass: {
type: String,
default: undefined
},
exactActiveClass: {
type: String,
default: undefined
},
prefetchedClass: {
type: String,
default: undefined
},
// Vue Router's `<RouterLink>` additional props
replace: {
type: Boolean,
default: undefined
},
ariaCurrentValue: {
type: String,
default: undefined
},
// Edge cases handling
external: {
type: Boolean,
default: undefined
}
} as const

1 comment on commit d3e19dc

@vercel
Copy link

@vercel vercel bot commented on d3e19dc Jan 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ui – ./

ui-git-dev-nuxt-js.vercel.app
ui.nuxt.com
ui-nuxt-js.vercel.app

Please sign in to comment.