Skip to content

Commit

Permalink
Merge pull request #21 from betagouv/iframe-layout
Browse files Browse the repository at this point in the history
Ajoute un layout dédié à l'iframe et un middleware pour l'appliquer dynamiquement à la page
  • Loading branch information
sandcha authored Mar 3, 2025
2 parents fb99efa + d4ad6ce commit fc32d83
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## 0.1.0 [#21](https://github.com/betagouv/aides-simulateur-front/pull/21)

* Ajout de fonctionnalité.
* Détail :
* Applique un layout dédié aux pages exposées par `iframe` (sans header, footer ni padding)

### 0.0.2 [#13](https://github.com/betagouv/aides-simulateur-front/pull/13)

* Évolution technique.
Expand Down
9 changes: 9 additions & 0 deletions client/layouts/iframe.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<template>
<main
id="content"
role="main"
tabindex="0"
>
<slot />
</main>
</template>
5 changes: 5 additions & 0 deletions client/middleware/check-iframe-layout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default defineNuxtRouteMiddleware((to) => {
if (isIframeRoute(to)) {
return setPageLayout('iframe')
}
})
4 changes: 4 additions & 0 deletions client/pages/simulateurs/[simulateur_id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { simulateurs, type Simulateur } from '@/data/simulateurs'
definePageMeta({
layout: 'default',
middleware: 'check-iframe-layout',
validate ({ params }) {
return simulateurs.some(s => s.id === params.simulateur_id)
}
})
const route = useRoute()
Expand Down
8 changes: 8 additions & 0 deletions client/utils/is-iframe-route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { RouteLocationNormalizedGeneric } from 'vue-router'

export function isIframeRoute (route: RouteLocationNormalizedGeneric) {
return (
route.query.iframe === 'true'
|| route.params.iframe === 'true'
)
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "aides-simulateur-front",
"type": "module",
"version": "0.0.2",
"version": "0.1.0",
"engines": {
"node": "22"
},
Expand Down

0 comments on commit fc32d83

Please sign in to comment.