Initialise le front-end Vue

- Vue 3, Vite, TypeScript, Vue Router, vue-i18n, MapLibre GL JS,
  Bootstrap 5 (CSS seul), Bootstrap Icons, police Roboto.
- Pages : connexion, évaluation (adresse, carte avec couches WalOnMap,
  une carte par facteur avec badge, valeurs mesurées, onglets et
  références, état « indisponible » avec Réessayer), erreurs 403/404.
- Design repris des maquettes Penpot (charte ssmg.be), bureau et mobile.
- Garde de navigation, client API avec jeton CSRF ; l'adresse du patient
  ne quitte pas la mémoire du composant.
- 51 tests Vitest ; README et CLAUDE.md mis à jour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
boris.waaubandClaude Opus 5.5 committed 2026-11-24 11:49:23 +01:00
1 parent 7d441b11c2
commit 7f29cec2a2
52 files changed
+9347 -4

No files matched your search

+55
View File
@@ -0,0 +1,55 @@
<script setup lang="ts">
import { ref } from 'vue'
defineProps<{ loading: boolean }>()
const emit = defineEmits<{ submit: [address: string] }>()
const address = ref('')
function onSubmit() {
const value = address.value.trim()
if (value) emit('submit', value)
}
</script>
<template>
<form class="address-form prism-card" @submit.prevent="onSubmit">
<label for="address" class="form-label">{{ $t('assessment.addressLabel') }}</label>
<div class="d-flex flex-column flex-md-row gap-3">
<input
id="address"
v-model="address"
type="text"
class="form-control"
autocomplete="off"
maxlength="300"
required
:placeholder="$t('assessment.addressPlaceholder')"
/>
<button type="submit" class="btn btn-primary submit" :disabled="loading || !address.trim()">
<span
v-if="loading"
class="spinner-border spinner-border-sm me-2"
aria-hidden="true"
></span>
{{ loading ? $t('assessment.submitting') : $t('assessment.submit') }}
</button>
</div>
</form>
</template>
<style scoped>
.address-form {
padding: 22px 28px 22px;
}
@media (max-width: 767.98px) {
.address-form {
padding: 18px;
}
}
.submit {
min-width: 160px;
}
</style>
+13
View File
@@ -0,0 +1,13 @@
<script setup lang="ts">
defineProps<{ variant: 'info' | 'error' }>()
</script>
<template>
<div
:class="variant === 'info' ? 'prism-alert-info' : 'alert alert-danger mb-0'"
:role="variant === 'error' ? 'alert' : 'status'"
>
<i v-if="variant === 'error'" class="bi bi-exclamation-triangle me-2" aria-hidden="true"></i>
<slot />
</div>
</template>
+31
View File
@@ -0,0 +1,31 @@
<template>
<footer class="app-footer">
<div class="container-xxl d-flex flex-column flex-md-row justify-content-between gap-2 py-4">
<span>{{ $t('app.disclaimer') }}</span>
<span class="footer-copyright">{{ $t('app.copyright') }}</span>
</div>
</footer>
</template>
<style scoped>
.app-footer {
background: var(--prism-navy);
color: #fff;
font-size: 0.8125rem;
}
.container-xxl {
max-width: 1440px;
padding-inline: 48px;
}
@media (max-width: 767.98px) {
.container-xxl {
padding-inline: 16px;
}
}
.footer-copyright {
color: var(--prism-footer-link);
}
</style>
+143
View File
@@ -0,0 +1,143 @@
<script setup lang="ts">
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import logo from '@/assets/logo-ssmg.png'
import { useAuth } from '@/composables/useAuth'
const { user, logout } = useAuth()
const router = useRouter()
const menuOpen = ref(false)
async function onLogout() {
menuOpen.value = false
await logout()
await router.push({ name: 'login' })
}
</script>
<template>
<header class="app-header">
<div class="container-xxl d-flex align-items-center justify-content-between gap-3">
<RouterLink to="/" class="brand text-decoration-none">
<img :src="logo" :alt="$t('app.logoAlt')" width="103" height="52" />
<span class="brand-text">
<span class="brand-name">{{ $t('app.name') }}</span>
<span class="brand-tagline d-none d-sm-block">{{ $t('app.tagline') }}</span>
</span>
</RouterLink>
<template v-if="user">
<nav class="d-none d-md-flex align-items-center gap-4">
<span class="text-muted-prism">{{ $t('nav.doctor', { name: user.last_name }) }}</span>
<button type="button" class="btn btn-link nav-logout p-0" @click="onLogout">
{{ $t('nav.logout') }}
</button>
</nav>
<div class="d-md-none position-relative">
<button
type="button"
class="btn menu-toggle"
:aria-label="$t('nav.menu')"
:aria-expanded="menuOpen"
@click="menuOpen = !menuOpen"
>
<i class="bi bi-list fs-4" aria-hidden="true"></i>
</button>
<div v-if="menuOpen" class="menu-overlay prism-card">
<p class="mb-2 text-muted-prism">{{ $t('nav.doctor', { name: user.last_name }) }}</p>
<button type="button" class="btn btn-link nav-logout p-0" @click="onLogout">
{{ $t('nav.logout') }}
</button>
</div>
</div>
</template>
</div>
</header>
</template>
<style scoped>
.app-header {
background: var(--prism-surface);
border-top: 4px solid var(--prism-orange);
padding: 0.6rem 0;
}
.container-xxl {
max-width: 1440px;
padding-inline: 48px;
}
@media (max-width: 767.98px) {
.container-xxl {
padding-inline: 16px;
}
}
.brand {
display: flex;
align-items: center;
gap: 20px;
}
.brand img {
height: 52px;
width: auto;
}
.brand-text {
border-left: 1px solid var(--prism-border);
padding-left: 20px;
line-height: 1.2;
}
@media (max-width: 575.98px) {
.brand img {
height: 40px;
}
.brand-text {
border-left: 0;
padding-left: 0;
}
}
.brand-name {
display: block;
color: var(--prism-navy);
font-size: 1.375rem;
font-weight: 700;
}
.brand-tagline {
color: var(--prism-muted);
font-size: 0.75rem;
}
.text-muted-prism {
color: var(--prism-text);
}
.nav-logout {
color: var(--prism-orange);
font-weight: 500;
font-size: 0.875rem;
text-decoration: none;
}
.menu-toggle {
border: 1px solid var(--prism-border);
border-radius: 6px;
padding: 0.35rem 0.6rem;
}
.menu-overlay {
position: absolute;
right: 0;
top: calc(100% + 8px);
min-width: 220px;
padding: 1rem 1.25rem;
z-index: 1000;
box-shadow: 0 8px 24px rgb(9 41 51 / 12%);
}
</style>
+46
View File
@@ -0,0 +1,46 @@
<script setup lang="ts">
import { computed } from 'vue'
import { useI18n } from 'vue-i18n'
import type { FactorStatus } from '@/api/types'
const props = defineProps<{ level: number | null; status: FactorStatus }>()
const { t } = useI18n()
const levelClass = computed(() =>
props.status === 'ok' && props.level ? `level-${props.level}` : 'level-none',
)
const text = computed(() => {
if (props.status === 'unavailable') return t('factor.unavailableBadge')
if (props.status === 'no_data') return t('factor.noDataBadge')
return t(`factor.levels.${props.level ?? 'none'}`)
})
</script>
<template>
<span class="color-badge" :class="[levelClass, { muted: status !== 'ok' || !level }]">
{{ text }}
</span>
</template>
<style scoped>
.color-badge {
display: inline-flex;
align-items: center;
height: 28px;
padding: 0 14px;
border-radius: 14px;
background: var(--level-color);
color: #fff;
font-size: 0.8125rem;
font-weight: 500;
white-space: nowrap;
}
.color-badge.muted {
background: var(--prism-bg);
border: 1px solid var(--prism-border);
color: var(--prism-text);
}
</style>
+59
View File
@@ -0,0 +1,59 @@
<script setup lang="ts">
import type { Detail } from '@/api/types'
defineProps<{ details: Detail[] }>()
function dotClass(detail: Detail): string {
return detail.status === 'exceeded' ? 'level-4' : 'level-1'
}
</script>
<template>
<dl v-if="details.length" class="detail-list">
<div v-for="detail in details" :key="detail.label" class="detail-row">
<dt>{{ detail.label }}</dt>
<dd>
<span v-if="detail.status" class="dot" :class="dotClass(detail)" aria-hidden="true"></span>
<span>{{ detail.value }}</span>
<span v-if="detail.status === 'exceeded'" class="visually-hidden"> (dépassé)</span>
</dd>
</div>
</dl>
</template>
<style scoped>
.detail-list {
background: var(--prism-bg);
border-radius: 8px;
padding: 6px 16px;
margin: 0;
}
.detail-row {
display: flex;
justify-content: space-between;
align-items: center;
gap: 1rem;
min-height: 36px;
padding: 0.4rem 16px;
}
.detail-row + .detail-row {
border-top: 1px solid var(--prism-border);
}
dt {
font-weight: 400;
color: var(--prism-text);
}
dd {
display: flex;
align-items: center;
gap: 8px;
margin: 0;
color: var(--prism-navy);
font-weight: 500;
text-align: right;
}
</style>
+99
View File
@@ -0,0 +1,99 @@
<script setup lang="ts">
import { computed } from 'vue'
import type { FactorResult } from '@/api/types'
import ColorBadge from './ColorBadge.vue'
import DetailList from './DetailList.vue'
import InfoTabs from './InfoTabs.vue'
import ReferenceList from './ReferenceList.vue'
const props = defineProps<{ factor: FactorResult }>()
defineEmits<{ retry: [] }>()
const levelClass = computed(() =>
props.factor.status === 'ok' && props.factor.level ? `level-${props.factor.level}` : 'level-none',
)
</script>
<template>
<article
class="factor-card prism-card"
:class="{ unavailable: factor.status !== 'ok' }"
:aria-labelledby="`factor-${factor.code}`"
>
<header class="factor-header">
<span class="factor-dot" :class="levelClass" aria-hidden="true"></span>
<h2 :id="`factor-${factor.code}`" class="factor-title">{{ factor.label }}</h2>
<ColorBadge class="ms-sm-auto" :level="factor.level" :status="factor.status" />
</header>
<template v-if="factor.status === 'ok'">
<p v-if="factor.summary" class="summary">{{ factor.summary }}</p>
<DetailList :details="factor.details" />
<InfoTabs :tabs="factor.tabs" />
<ReferenceList :references="factor.references" />
</template>
<template v-else>
<p class="summary">
{{
factor.status === 'unavailable'
? $t('factor.unavailable', { label: factor.label.toLowerCase() })
: $t('factor.noData')
}}
</p>
<div v-if="factor.status === 'unavailable'">
<button type="button" class="btn btn-outline-primary" @click="$emit('retry')">
{{ $t('factor.retry') }}
</button>
</div>
</template>
</article>
</template>
<style scoped>
.factor-card {
display: flex;
flex-direction: column;
gap: 14px;
padding: 22px 24px;
}
.factor-card.unavailable {
border: 1px dashed var(--prism-level-none);
}
.factor-header {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 10px;
}
@media (max-width: 575.98px) {
.factor-header :deep(.color-badge) {
order: 3;
}
}
.factor-dot {
width: 22px;
height: 22px;
border-radius: 50%;
background: var(--level-color);
flex-shrink: 0;
}
.factor-title {
font-size: 1.25rem;
margin: 0;
}
.summary {
color: var(--prism-navy);
font-size: 0.9375rem;
font-weight: 500;
margin: 0;
}
</style>
+135
View File
@@ -0,0 +1,135 @@
<script setup lang="ts">
import { computed, ref, useId } from 'vue'
import type { FactorResult } from '@/api/types'
const props = defineProps<{ tabs: FactorResult['tabs'] }>()
type TabKey = 'health_effects' | 'actions' | 'legend'
const keys: TabKey[] = ['health_effects', 'actions', 'legend']
const active = ref<TabKey>('health_effects')
const id = useId()
/** Les textes de la SSMG sont rédigés une idée par ligne : rendus en liste à puces. */
function lines(text: string): string[] {
return text
.split('\n')
.map((line) => line.replace(/^[-•]\s*/, '').trim())
.filter(Boolean)
}
const content = computed(() =>
active.value === 'legend' ? lines(props.tabs.legend.text) : lines(props.tabs[active.value]),
)
</script>
<template>
<div>
<div class="tab-list" role="tablist">
<button
v-for="key in keys"
:id="`${id}-tab-${key}`"
:key="key"
type="button"
role="tab"
class="tab"
:class="{ active: active === key }"
:aria-selected="active === key"
:aria-controls="`${id}-panel`"
@click="active = key"
>
{{ $t(`factor.tabs.${key}`) }}
</button>
</div>
<div
:id="`${id}-panel`"
role="tabpanel"
:aria-labelledby="`${id}-tab-${active}`"
class="tab-panel"
>
<template v-if="active === 'legend'">
<ul v-if="tabs.legend.scale.length" class="list-unstyled scale">
<li v-for="item in tabs.legend.scale" :key="item.level + item.label">
<span class="dot" :class="`level-${item.level}`" aria-hidden="true"></span>
{{ item.label }}
</li>
</ul>
<p v-if="tabs.legend.source" class="source">
{{ $t('factor.source', { source: tabs.legend.source }) }}
</p>
</template>
<ul v-if="content.length" class="bullets">
<li v-for="line in content" :key="line">{{ line }}</li>
</ul>
<p v-else-if="active !== 'legend' || !tabs.legend.scale.length" class="empty">
{{ $t('factor.emptyTab') }}
</p>
</div>
</div>
</template>
<style scoped>
.tab-list {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.tab {
height: 32px;
padding: 0 14px;
border-radius: 14px;
border: 1px solid var(--prism-border);
background: var(--prism-surface);
color: var(--prism-text);
font-size: 0.8125rem;
font-weight: 500;
}
.tab.active {
background: var(--prism-navy);
border-color: var(--prism-navy);
color: #fff;
}
.tab:focus-visible {
outline: 2px solid var(--prism-orange);
outline-offset: 2px;
}
.tab-panel {
padding-top: 14px;
}
.bullets {
margin: 0;
padding-left: 0;
list-style: none;
}
.bullets li {
position: relative;
padding-left: 12px;
margin-bottom: 6px;
}
.bullets li::before {
content: '•';
position: absolute;
left: 0;
}
.scale li {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 4px;
}
.source,
.empty {
color: var(--prism-muted);
margin-bottom: 0;
}
</style>
+32
View File
@@ -0,0 +1,32 @@
<script setup lang="ts">
import type { Reference } from '@/api/types'
defineProps<{ references: Reference[] }>()
</script>
<template>
<p v-if="references.length" class="references">
{{ $t('factor.references') }}
<template v-for="ref in references" :key="ref.n">
<a v-if="ref.url" :href="ref.url" target="_blank" rel="noopener noreferrer">
{{ ref.n }}. {{ ref.title }}</a
><span v-else>{{ ref.n }}. {{ ref.title }}</span>
</template>
</p>
</template>
<style scoped>
.references {
border-top: 1px solid var(--prism-border);
padding-top: 14px;
margin: 0;
font-size: 0.75rem;
color: var(--prism-muted);
}
.references a,
.references span {
margin-left: 0.5rem;
color: var(--prism-muted);
}
</style>
+233
View File
@@ -0,0 +1,233 @@
<script setup lang="ts">
import { Map as MapLibreMap, Marker, NavigationControl, ScaleControl } from 'maplibre-gl'
import { onBeforeUnmount, onMounted, ref, watch } from 'vue'
import type { Assessment } from '@/api/types'
const props = defineProps<{ location: Assessment['location'] | null }>()
const WALONMAP_WMS = 'https://geoservices.wallonie.be/arcgis/services'
// Fond OpenStreetMap : les serveurs publics ne sont pas prévus pour la production
// (specs, risque 12). À remplacer par un fournisseur de tuiles avant la mise en production.
const OSM_TILES = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png'
const BELGIUM: [number, number] = [4.47, 50.5]
function wms(service: string, layers: string): string {
const params = new URLSearchParams({
service: 'WMS',
request: 'GetMap',
version: '1.3.0',
layers,
styles: '',
format: 'image/png',
transparent: 'true',
crs: 'EPSG:3857',
width: '256',
height: '256',
})
return `${WALONMAP_WMS}/${service}/MapServer/WMSServer?${params}&bbox={bbox-epsg-3857}`
}
const overlays = [
{ id: 'flood', url: wms('EAU/ALEA_INOND', '2'), color: '#00b0f0' },
{ id: 'noise', url: wms('INDUSTRIES_SERVICES/BRUIT_MROAD_2017', '1'), color: '#e85b25' },
] as const
type OverlayId = (typeof overlays)[number]['id']
const container = ref<HTMLDivElement>()
const layersPanel = ref<HTMLFieldSetElement>()
const visible = ref<Record<OverlayId, boolean>>({ flood: true, noise: false })
let map: MapLibreMap | null = null
let marker: Marker | null = null
onMounted(() => {
const instance = new MapLibreMap({
container: container.value!,
center: BELGIUM,
zoom: 7,
attributionControl: { compact: false },
style: {
version: 8,
sources: {
osm: {
type: 'raster',
tiles: [OSM_TILES],
tileSize: 256,
maxzoom: 19,
attribution: '© OpenStreetMap contributors',
},
...Object.fromEntries(
overlays.map((o) => [
o.id,
{ type: 'raster', tiles: [o.url], tileSize: 256, attribution: '© SPW – WalOnMap' },
]),
),
},
layers: [
{ id: 'osm', type: 'raster', source: 'osm' },
...overlays.map((o) => ({
id: o.id,
type: 'raster' as const,
source: o.id,
paint: { 'raster-opacity': 0.6 },
layout: { visibility: visible.value[o.id] ? ('visible' as const) : ('none' as const) },
})),
],
},
})
instance.addControl(new NavigationControl({ showCompass: false }), 'top-right')
instance.addControl(new ScaleControl({ unit: 'metric' }), 'bottom-left')
map = instance
showLocation()
})
onBeforeUnmount(() => {
map?.remove()
map = null
})
function showLocation() {
if (!map || !props.location) return
const lngLat: [number, number] = [props.location.lon, props.location.lat]
marker?.remove()
marker = new Marker({ color: '#e85b25' }).setLngLat(lngLat).addTo(map)
// La mise en page peut avoir changé depuis la création de la carte.
map.resize()
// Décale le centre sous le panneau des couches pour que le marqueur reste visible.
const top = (layersPanel.value?.offsetHeight ?? 0) + 12
map.jumpTo({ center: lngLat, zoom: 15, padding: { top, bottom: 0, left: 0, right: 0 } })
}
function toggle(id: OverlayId) {
visible.value[id] = !visible.value[id]
map?.setLayoutProperty(id, 'visibility', visible.value[id] ? 'visible' : 'none')
}
watch(() => props.location, showLocation, { flush: 'post' })
</script>
<template>
<div class="result-map prism-card">
<div ref="container" class="map" role="region" :aria-label="$t('map.label')"></div>
<fieldset ref="layersPanel" class="map-panel layers">
<legend>{{ $t('map.layers') }}</legend>
<div class="form-check">
<input id="layer-osm" class="form-check-input" type="checkbox" checked disabled />
<label class="form-check-label" for="layer-osm">{{ $t('map.basemap') }}</label>
</div>
<div v-for="overlay in overlays" :key="overlay.id" class="form-check">
<input
:id="`layer-${overlay.id}`"
class="form-check-input"
type="checkbox"
:checked="visible[overlay.id]"
@change="toggle(overlay.id)"
/>
<label class="form-check-label" :for="`layer-${overlay.id}`">
{{ $t(`map.${overlay.id}`) }}
</label>
</div>
</fieldset>
<div class="map-panel legend">
<strong>{{ $t('map.legend') }}</strong>
<div>
<span class="swatch round" style="background: #e85b25"></span>{{ $t('map.patient') }}
</div>
<template v-for="overlay in overlays" :key="overlay.id">
<div v-if="visible[overlay.id]">
<span class="swatch" :style="{ background: overlay.color }"></span>
{{ $t(`map.${overlay.id}`) }}
</div>
</template>
</div>
</div>
</template>
<style scoped>
.result-map {
position: relative;
overflow: hidden;
height: 720px;
}
@media (min-width: 992px) {
.result-map {
position: sticky;
top: 24px;
}
}
@media (max-width: 991.98px) {
.result-map {
height: 240px;
}
.legend {
display: none;
}
}
.map {
position: absolute;
inset: 0;
}
.map-panel {
position: absolute;
left: 12px;
z-index: 2;
background: var(--prism-surface);
border: 1px solid var(--prism-border);
border-radius: 8px;
padding: 10px 12px;
font-size: 0.6875rem;
box-shadow: 0 2px 8px rgb(9 41 51 / 10%);
}
.layers {
top: 12px;
}
.layers legend {
float: none;
font-size: 0.75rem;
font-weight: 700;
color: var(--prism-navy);
margin-bottom: 4px;
}
.form-check {
margin-bottom: 2px;
}
.form-check-input:checked {
background-color: var(--prism-orange);
border-color: var(--prism-orange);
}
.legend {
bottom: 40px;
}
.legend strong {
display: block;
font-size: 0.75rem;
color: var(--prism-navy);
margin-bottom: 4px;
}
.swatch {
display: inline-block;
width: 10px;
height: 10px;
margin-right: 8px;
border-radius: 2px;
vertical-align: middle;
}
.swatch.round {
border-radius: 50%;
}
</style>