From 60d0ddfcf1518167873b45b1d8d22fc8b346b382 Mon Sep 17 00:00:00 2001 From: Razvan Stoenescu Date: Sun, 2 Oct 2022 20:06:27 +0300 Subject: [PATCH] feat(docs): Update QBtn/QBreadcrumbs/QItem/QRouteTab pages for the updated router-link specs --- .../src/examples/QBreadcrumbs/LinksWithGo.vue | 43 +++++++++++++ docs/src/examples/QBtn/LinksWithGo.vue | 40 ++++++++++++ docs/src/examples/QItem/LinksWithGo.vue | 48 +++++++++++++++ docs/src/pages/vue-components/breadcrumbs.md | 17 +++++- docs/src/pages/vue-components/button.md | 6 +- .../vue-components/list-and-list-items.md | 4 ++ docs/src/pages/vue-components/tabs.md | 61 +++++++++++++------ ui/src/components/tabs/QTabs.js | 9 ++- 8 files changed, 200 insertions(+), 28 deletions(-) create mode 100644 docs/src/examples/QBreadcrumbs/LinksWithGo.vue create mode 100644 docs/src/examples/QBtn/LinksWithGo.vue create mode 100644 docs/src/examples/QItem/LinksWithGo.vue diff --git a/docs/src/examples/QBreadcrumbs/LinksWithGo.vue b/docs/src/examples/QBreadcrumbs/LinksWithGo.vue new file mode 100644 index 00000000000..0199584bc0c --- /dev/null +++ b/docs/src/examples/QBreadcrumbs/LinksWithGo.vue @@ -0,0 +1,43 @@ + + + diff --git a/docs/src/examples/QBtn/LinksWithGo.vue b/docs/src/examples/QBtn/LinksWithGo.vue new file mode 100644 index 00000000000..7ba00638993 --- /dev/null +++ b/docs/src/examples/QBtn/LinksWithGo.vue @@ -0,0 +1,40 @@ + + + diff --git a/docs/src/examples/QItem/LinksWithGo.vue b/docs/src/examples/QItem/LinksWithGo.vue new file mode 100644 index 00000000000..a324a26fbb8 --- /dev/null +++ b/docs/src/examples/QItem/LinksWithGo.vue @@ -0,0 +1,48 @@ + + + diff --git a/docs/src/pages/vue-components/breadcrumbs.md b/docs/src/pages/vue-components/breadcrumbs.md index 4ce0381f59d..78797ac3cf3 100644 --- a/docs/src/pages/vue-components/breadcrumbs.md +++ b/docs/src/pages/vue-components/breadcrumbs.md @@ -12,16 +12,27 @@ The QBreadcrumbs component is used as a navigational aid in UI. It allows users ## Usage + +### Basic + +### Design + -The example below won't work with UMD version (so in Codepen/jsFiddle too) because it depends on Vue Router. + + + + +### Connecting with Vue Router + +The examples below won't work with UMD version (so in Codepen/jsFiddle too) because they depend on Vue Router. - +You can also delay, cancel or redirect navigation, as seen below. For a more in-depth description of the `@click` event being used below, please refer to QBreadcrumbsEl API card at the top of the page. - + diff --git a/docs/src/pages/vue-components/button.md b/docs/src/pages/vue-components/button.md index 79cadbadc0f..a12bd83b616 100644 --- a/docs/src/pages/vue-components/button.md +++ b/docs/src/pages/vue-components/button.md @@ -71,7 +71,7 @@ Should you wish, you can also display a deterministic progress within the button -### Handling navigation +### Connecting to Vue Router ::: warning UMD usage * If you will be using `to` & `replace` props, make sure that you also inject Vue Router in your project. Otherwise use the alternative `href` prop. @@ -84,6 +84,10 @@ Prefer the Vue Router props over `href` when you can, because with `href` you wi +You can also delay, cancel or redirect navigation, as seen below. For a more in-depth description of the `@click` event being used below, please refer to QBtn API card at the top of the page. + + + For more convoluted use-cases, you can also directly use the native Vue `` component to wrap a QBtn. This also gives the opportunity to control the state according to app's current route: diff --git a/docs/src/pages/vue-components/list-and-list-items.md b/docs/src/pages/vue-components/list-and-list-items.md index 937b5a30121..5d04d6c0c26 100644 --- a/docs/src/pages/vue-components/list-and-list-items.md +++ b/docs/src/pages/vue-components/list-and-list-items.md @@ -94,3 +94,7 @@ You can use QItems together with Vue Router through `` properties b ``` + +You can also delay, cancel or redirect navigation, as seen below. For a more in-depth description of the `@click` event being used below, please refer to QItem API card at the top of the page. + + diff --git a/docs/src/pages/vue-components/tabs.md b/docs/src/pages/vue-components/tabs.md index 25545c0ebd2..893429b11db 100644 --- a/docs/src/pages/vue-components/tabs.md +++ b/docs/src/pages/vue-components/tabs.md @@ -112,6 +112,7 @@ QTabPanels can be used as standalone too. They do not depend on the presence of More info: [Tab Panels](/vue-components/tab-panels). ## Connecting to Vue Router + You can use tabs together with Vue Router through `QRouteTab` component. This component inherits everything from QTab, however it also has `router-link` properties bound to it. These allow for listening to the current app route and also triggering a route when clicked/tapped. @@ -131,33 +132,48 @@ This component inherits everything from QTab, however it also has `router-link` ``` ::: warning -QRouteTab becomes "active" depending on your app's route and not due to the v-model. So the initial value of v-model or changing the v-model directly will not also change the route of your app. +When using QTabs with QRouteTab, it is not recommended to also use a v-model (though you still can), because the source of truth for the current active tab is determined by the current route instead of the v-model. Each QRouteTab becomes "active" depending on your app's route and not due to the v-model. So the initial value of v-model or changing the v-model directly will not also change the route of your app. ::: +### Matching QRouteTab to current route + +* If it is set to `exact` matching: + 1. The route that it points to must be considered "exact-active" by Vue Router (exactly matches route, hash & query). + 2. Is it pointing to a route that does NOT get redirected to another one? Then it wins. + 3. Otherwise, we keep on looking only for other "exact-active" matching QRouteTabs. Maybe we'll find one that does NOT redirect. +* Else, if it is NOT set to `exact` matching: + 1. The route that it points to must be considered "active" by Vue Router (loosely matches route, hash & query). + 2. If there are still multiple QRouteTabs matching the criteria above, then the ones NOT pointing to a route that gets redirected win. + 3. If multiple QRouteTab still match the current route (ex: route is /cars/brands/tesla and we have QRouteTabs pointing to non-exact /cars, non-exact /cars/brands, non-exact /cars/brands/tesla), then the most specific one that matches current route wins (in this case /cars/brands/tesla) + 4. If there are still multiple QRouteTabs matching the criteria above, then the one with the query that is closest to the current route query wins (has the configured query and the current route query has the least number of extra params). + 5. If there are still multiple QRouteTabs matching the criteria above, then the one with the resulting href that is the lengthier one wins. + +The `exact` configured QRouteTabs always win over loose-matching (non-exact) ones. + ### Handling custom navigation +::: tip +Please refer to the QRouteTab API card at the top of the page for a more in-depth description of the `@click` event being used below. +::: + ```html