From cefe5a76e0a4820f648d23734228540e3010b233 Mon Sep 17 00:00:00 2001 From: Benjamin Canac Date: Sun, 30 Jul 2023 19:46:27 +0200 Subject: [PATCH] feat(Link)!: rename from `LinkCustom` and add `exact-query` / `exact-hash` props --- docs/content/2.elements/9.link.md | 24 ++++++++++++++++ src/runtime/components/elements/Button.vue | 8 +++--- src/runtime/components/elements/Dropdown.vue | 8 +++--- .../elements/{LinkCustom.vue => Link.vue} | 28 ++++++++++++------- .../navigation/VerticalNavigation.vue | 8 +++--- src/runtime/types/button.d.ts | 4 ++- src/runtime/types/dropdown.d.ts | 4 +-- src/runtime/types/index.d.ts | 1 + src/runtime/types/link.d.ts | 8 ++++++ src/runtime/types/vertical-navigation.d.ts | 4 +-- 10 files changed, 70 insertions(+), 27 deletions(-) create mode 100644 docs/content/2.elements/9.link.md rename src/runtime/components/elements/{LinkCustom.vue => Link.vue} (58%) create mode 100644 src/runtime/types/link.d.ts diff --git a/docs/content/2.elements/9.link.md b/docs/content/2.elements/9.link.md new file mode 100644 index 0000000000..6b59da7aae --- /dev/null +++ b/docs/content/2.elements/9.link.md @@ -0,0 +1,24 @@ +--- +title: 'Link' +description: Render a NuxtLink but with superpowers. +links: + - label: GitHub + icon: i-simple-icons-github + to: https://github.com/nuxtlabs/ui/blob/dev/src/runtime/components/elements/Link.vue +navigation: + badge: Edge +--- + +## Usage + +The Link component is a wrapper around [``](https://nuxt.com/docs/api/components/nuxt-link) through the [custom](https://router.vuejs.org/api/interfaces/RouterLinkProps.html#Properties-custom) prop that provides a few extra props: + +- `inactive-class` prop to set a class when the link is inactive, `active-class` is used when active. +- `exact` prop to style with `active-class` when the link is active and the route is exactly the same as the current route. +- `exact-query` and `exact-hash` props to style with `active-class` when the link is active and the query or hash is exactly the same as the current query or hash. + +The incentive behind this is to provide the same API as NuxtLink back in Nuxt 2 / Vue 2. You can read more about it in the Vue Router [migration from Vue 2](https://router.vuejs.org/guide/migration/#removal-of-the-exact-prop-in-router-link) guide. + +It also renders an `` tag when a `to` prop is provided, otherwise it renders a `