diff --git a/front/src/components/ui/Link.vue b/front/src/components/ui/Link.vue
index 3086fc324..c7de506e0 100644
--- a/front/src/components/ui/Link.vue
+++ b/front/src/components/ui/Link.vue
@@ -1,11 +1,13 @@
- = { on: (value : T | null) => string | null, isOn: (value: LocationQuery[string]) => boolean }
+
+export const exactlyNull:Assignment = ({ on: (_) => null, isOn: (value) => value === null })
+export const notUndefined:Assignment = ({ on: (_) => null, isOn: (value) => value !== undefined })
+
/**
* Bind a modal to a single query parameter in the URL (and vice versa)
*
@@ -13,8 +18,7 @@ import { useRouter, type RouteLocationRaw, type LocationQuery } from "vue-router
*/
export const useModal = (
flag: string,
- assignment: { on: (value : T | null) => string | null, isOn: (value: LocationQuery[string]) => boolean } =
- { on: (_) => null, isOn: (value) => value === null }
+ assignment: Assignment = exactlyNull
) => {
const router = useRouter();
const query = computed(() =>
@@ -113,3 +117,9 @@ export const useModal = (
return { value, isOpen, to, asAttribute, toggle };
}
+
+/* All possible useModals that produce a given `RouterLink` destination */
+export const fromProps = ({to} : { to?: RouteLocationRaw }, assignment: Assignment = exactlyNull): ReturnType[] =>
+ to && typeof to !== 'string' && 'query' in to && to.query ?
+ Object.keys(to.query).map( k => useModal(k, assignment) )
+ : []
diff --git a/front/ui-docs/components/ui/link.md b/front/ui-docs/components/ui/link.md
index 68c595ba0..f406aaed0 100644
--- a/front/ui-docs/components/ui/link.md
+++ b/front/ui-docs/components/ui/link.md
@@ -1,9 +1,14 @@
```ts
@@ -30,6 +35,26 @@ This component will render as [an `` element [MDN]](https://developer.mozil
Instead of a route, you can set the prop `to` to any web address starting with `http`.
+## `Active` states
+
+- If any ancestor path matches, the `.router-link-active` class is added
+- If the whole path matches, the `.router-link-exact-active` class is added
+
+See the [Vue docs](https://router.vuejs.org/guide/essentials/active-links) for a primer on Path matching.
+
+In addition to the standard Vue `RouterLink` path matching function, we use this algorithm:
+
+- If the destination of the link contains any query parameter _and_ none of these is set (i.e. they are all `undefined`), then the class `.router-link-no-matching-query-flags` is added.
+
+This is particularly useful for modals.
+
+
+ Open modal
+
+
+
+
+
## Colors and Variants
See [Using color](/using-color)