Add walkthrough
CI / backend (push) Canceled after 15s
CI / frontend (push) Successful in 1m36s

This commit is contained in:
2026-08-12 07:05:37 +08:00
parent 3680dc5ea7
commit 4fb9c95dfb
37 changed files with 1682 additions and 23 deletions
@@ -1,5 +1,5 @@
<template>
<div class="app-header">
<div class="app-header" :data-tour="tourAnchor || undefined">
<div class="app-header-title min-w-0 flex-1">
<div class="min-w-0">
<h1 class="text-lg sm:text-xl font-semibold text-ink-strong leading-tight">
@@ -25,7 +25,9 @@ withDefaults(
defineProps<{
title: string
description?: string
/** Stable walkthrough anchor, e.g. intake-header */
tourAnchor?: string
}>(),
{ description: undefined },
{ description: undefined, tourAnchor: undefined },
)
</script>
@@ -46,7 +46,7 @@
</div>
<nav class="flex-1 overflow-y-auto py-3 px-2 space-y-4">
<div v-if="workspaceItems.length">
<div v-if="workspaceItems.length" data-tour="nav-workspace">
<p
v-if="!sidebarCollapsed"
class="px-2 mb-1.5 text-[10px] font-semibold uppercase tracking-wider text-white/40"
@@ -59,6 +59,7 @@
:to="item.to"
:title="sidebarCollapsed ? item.label : undefined"
:class="navItemClass(item.to)"
:data-tour="item.tourAnchor"
@click="closeMobile"
>
<span class="shrink-0 w-5 h-5 flex items-center justify-center" aria-hidden="true">
@@ -70,7 +71,7 @@
</ul>
</div>
<div v-if="adminItems.length">
<div v-if="adminItems.length" data-tour="nav-admin">
<p
v-if="!sidebarCollapsed"
class="px-2 mb-1.5 text-[10px] font-semibold uppercase tracking-wider text-white/40"
@@ -83,6 +84,7 @@
:to="item.to"
:title="sidebarCollapsed ? item.label : undefined"
:class="navItemClass(item.to)"
:data-tour="item.tourAnchor"
@click="closeMobile"
>
<span class="shrink-0 w-5 h-5 flex items-center justify-center" aria-hidden="true">
@@ -251,6 +253,7 @@ interface NavItem {
to: string
icon: () => ReturnType<typeof h>
show: boolean
tourAnchor?: string
}
const workspaceItems = computed<NavItem[]>(() =>
@@ -261,7 +264,13 @@ const workspaceItems = computed<NavItem[]>(() =>
{ label: 'Verification', to: '/verification', icon: icons.verify, show: auth.canVerify },
{ label: 'Clinical Approval', to: '/approval', icon: icons.approve, show: auth.canApprove },
{ label: 'Live Capture', to: '/live-capture', icon: icons.live, show: auth.canLiveCapture },
{ label: 'Patient History', to: '/patients', icon: icons.patients, show: auth.isAuthenticated },
{
label: 'Patient History',
to: '/patients',
icon: icons.patients,
show: auth.isAuthenticated,
tourAnchor: 'nav-patients',
},
].filter((item) => item.show),
)
@@ -2,6 +2,7 @@
<div
class="h-full min-h-0 flex flex-col approval-frame"
data-testid="approval-form"
data-tour="approval-form"
>
<div class="flex-1 min-h-0 overflow-y-auto p-4 space-y-4">
<div class="flex items-start justify-between gap-3">
@@ -3,6 +3,7 @@
ref="root"
class="mt-2 group workstation-form-section !p-3"
data-testid="audit-trail-panel"
data-tour="audit-trail"
@toggle="onToggle"
>
<summary
@@ -1,5 +1,5 @@
<template>
<div class="h-full min-h-0 flex flex-col" data-testid="entry-form">
<div class="h-full min-h-0 flex flex-col" data-testid="entry-form" data-tour="entry-form">
<div class="flex-1 min-h-0 overflow-y-auto p-4 space-y-4">
<div class="flex items-start justify-between gap-3">
<div>
@@ -0,0 +1,145 @@
<template>
<Teleport to="body">
<div
v-if="open"
class="fixed inset-0 z-50 flex justify-end"
data-testid="help-panel"
>
<div
class="absolute inset-0 bg-black/50"
aria-hidden="true"
data-testid="help-panel-backdrop"
@click="closePanel()"
/>
<aside
class="relative z-10 flex h-full w-full max-w-md flex-col border-l border-line bg-surface shadow-dialog"
role="dialog"
aria-modal="true"
:aria-labelledby="titleId"
data-testid="help-panel-drawer"
@keydown.esc.prevent="closePanel()"
>
<header class="flex items-start justify-between gap-3 border-b border-line px-5 py-4 shrink-0">
<div class="min-w-0">
<p class="text-[11px] font-semibold uppercase tracking-wider text-ink-secondary">
Page instructions
</p>
<h2 :id="titleId" class="mt-1 text-lg font-semibold text-ink-strong">
{{ guide.title }}
</h2>
</div>
<button
ref="closeBtnRef"
type="button"
class="shrink-0 rounded-input p-2 text-ink-secondary hover:bg-canvas hover:text-ink-strong"
aria-label="Close help"
data-testid="help-panel-close"
@click="closePanel()"
>
<svg class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
<path
d="M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"
/>
</svg>
</button>
</header>
<div class="flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-5">
<p class="text-sm text-ink leading-relaxed">{{ guide.summary }}</p>
<section>
<h3 class="text-sm font-semibold text-ink-strong mb-2">Steps</h3>
<ol class="list-decimal pl-5 space-y-2 text-sm text-ink leading-relaxed">
<li v-for="(step, index) in guide.steps" :key="index">{{ step }}</li>
</ol>
</section>
<section v-if="guide.tips?.length">
<h3 class="text-sm font-semibold text-ink-strong mb-2">Tips</h3>
<ul class="list-disc pl-5 space-y-2 text-sm text-ink-secondary leading-relaxed">
<li v-for="(tip, index) in guide.tips" :key="index">{{ tip }}</li>
</ul>
</section>
</div>
<footer
class="flex flex-col-reverse gap-3 border-t border-line px-5 py-4 sm:flex-row sm:items-center sm:justify-between shrink-0"
>
<button
type="button"
class="btn-secondary text-sm"
data-testid="help-panel-replay"
:disabled="!canReplay"
:title="replayTitle"
@click="onReplay"
>
Replay walkthrough
</button>
<button
type="button"
class="btn-primary text-sm"
data-testid="help-panel-done"
@click="closePanel()"
>
Close
</button>
</footer>
</aside>
</div>
</Teleport>
</template>
<script setup lang="ts">
import { computed, nextTick, ref, useId, watch } from 'vue'
import { useRoute } from 'vue-router'
import { useAuthStore } from '../stores/auth'
import { useTourStore } from '../stores/tour'
import { useHelpPanel } from '../composables/useHelpPanel'
import { getPageGuide } from '../help/pageGuides'
import { getTourForRole } from '../tours/definitions'
const { open, closePanel } = useHelpPanel()
const route = useRoute()
const auth = useAuthStore()
const tour = useTourStore()
const titleId = useId()
const closeBtnRef = ref<HTMLButtonElement | null>(null)
let focusRestore: HTMLElement | null = null
const guide = computed(() => getPageGuide(route.path))
const canReplay = computed(
() =>
!!auth.userRole &&
!!auth.userId &&
!!getTourForRole(auth.userRole) &&
!tour.active,
)
const replayTitle = computed(() => {
if (tour.active) return 'A walkthrough is already running'
if (!getTourForRole(auth.userRole)) return 'No walkthrough for this role'
return 'Start the guided walkthrough for your role'
})
async function onReplay() {
if (!canReplay.value) return
closePanel()
await tour.replay(auth.userRole, auth.userId)
}
watch(open, async (isOpen) => {
if (isOpen) {
focusRestore = document.activeElement as HTMLElement | null
await nextTick()
closeBtnRef.value?.focus()
return
}
if (focusRestore) {
focusRestore.focus()
focusRestore = null
}
})
</script>
@@ -7,6 +7,7 @@
: 'border-primary-100 bg-primary-50'"
role="status"
data-testid="sod-banner"
data-tour="sod-banner"
>
<template v-if="blocked">
<p class="font-semibold text-clinical-danger">
@@ -0,0 +1,17 @@
<template>
<button
type="button"
class="btn-secondary text-sm"
data-testid="tour-help"
title="Page instructions and walkthrough"
@click="togglePanel()"
>
Help
</button>
</template>
<script setup lang="ts">
import { useHelpPanel } from '../composables/useHelpPanel'
const { togglePanel } = useHelpPanel()
</script>
@@ -0,0 +1,240 @@
<template>
<Teleport to="body">
<div
v-if="tour.active && tour.currentStep"
class="fixed inset-0 z-[60]"
role="dialog"
aria-modal="true"
:aria-labelledby="titleId"
:aria-describedby="bodyId"
data-testid="tour-overlay"
@keydown.esc.prevent="tour.skip()"
>
<!-- Dimmed backdrop with cutout -->
<svg class="absolute inset-0 h-full w-full pointer-events-none" aria-hidden="true">
<defs>
<mask :id="maskId">
<rect width="100%" height="100%" fill="white" />
<rect
v-if="highlight"
:x="highlight.x"
:y="highlight.y"
:width="highlight.width"
:height="highlight.height"
rx="8"
fill="black"
/>
</mask>
</defs>
<rect
width="100%"
height="100%"
fill="rgba(0,0,0,0.5)"
:mask="`url(#${maskId})`"
class="pointer-events-auto"
@click="tour.skip()"
/>
</svg>
<!-- Highlight ring -->
<div
v-if="highlight"
class="pointer-events-none absolute rounded-input ring-2 ring-primary-500 ring-offset-2 ring-offset-transparent transition-all duration-150"
:style="highlightStyle"
aria-hidden="true"
/>
<!-- Popover -->
<div
ref="popoverRef"
class="absolute z-[61] w-[min(100vw-2rem,22rem)] rounded-card border border-line bg-surface p-5 shadow-dialog"
:style="popoverStyle"
data-testid="tour-popover"
@click.stop
>
<p class="text-[11px] font-semibold uppercase tracking-wider text-ink-secondary">
Step {{ tour.stepIndex + 1 }} of {{ tour.stepCount }}
</p>
<h3 :id="titleId" class="mt-1 text-lg font-semibold text-ink-strong">
{{ tour.currentStep.title }}
</h3>
<p :id="bodyId" class="mt-2 text-sm text-ink leading-relaxed">
{{ tour.currentStep.body }}
</p>
<div class="mt-5 flex flex-col-reverse gap-3 sm:flex-row sm:items-center sm:justify-between">
<button
type="button"
class="px-3 py-2 text-sm text-ink-secondary hover:text-ink-strong"
data-testid="tour-skip"
@click="tour.skip()"
>
Skip
</button>
<div class="flex gap-2 justify-end">
<button
v-if="!tour.isFirstStep"
type="button"
class="btn-secondary"
data-testid="tour-prev"
:disabled="tour.preparing"
@click="tour.prev()"
>
Back
</button>
<button
ref="nextBtnRef"
type="button"
class="btn-primary"
data-testid="tour-next"
:disabled="tour.preparing"
@click="tour.next()"
>
{{ tour.isLastStep ? 'Done' : 'Next' }}
</button>
</div>
</div>
</div>
</div>
</Teleport>
</template>
<script setup lang="ts">
import { computed, nextTick, onMounted, onUnmounted, ref, useId, watch } from 'vue'
import { useTourStore } from '../stores/tour'
import type { TourPlacement } from '../tours/types'
const tour = useTourStore()
const titleId = useId()
const bodyId = useId()
const maskId = useId()
const nextBtnRef = ref<HTMLButtonElement | null>(null)
const popoverRef = ref<HTMLElement | null>(null)
interface Rect {
x: number
y: number
width: number
height: number
}
const highlight = ref<Rect | null>(null)
const popoverPos = ref({ top: 16, left: 16 })
const PAD = 8
const POPOVER_GAP = 12
const highlightStyle = computed(() => {
if (!highlight.value) return {}
return {
top: `${highlight.value.y}px`,
left: `${highlight.value.x}px`,
width: `${highlight.value.width}px`,
height: `${highlight.value.height}px`,
}
})
const popoverStyle = computed(() => ({
top: `${popoverPos.value.top}px`,
left: `${popoverPos.value.left}px`,
}))
function measureTarget(selector: string): Rect | null {
const el = document.querySelector(selector)
if (!el) return null
const r = el.getBoundingClientRect()
if (r.width === 0 && r.height === 0) return null
return {
x: Math.max(0, r.left - PAD),
y: Math.max(0, r.top - PAD),
width: r.width + PAD * 2,
height: r.height + PAD * 2,
}
}
function placePopover(target: Rect, placement: TourPlacement = 'bottom') {
const popW = popoverRef.value?.offsetWidth ?? 352
const popH = popoverRef.value?.offsetHeight ?? 200
const vw = window.innerWidth
const vh = window.innerHeight
let top = target.y + target.height + POPOVER_GAP
let left = target.x
if (placement === 'top') {
top = target.y - popH - POPOVER_GAP
} else if (placement === 'left') {
top = target.y
left = target.x - popW - POPOVER_GAP
} else if (placement === 'right') {
top = target.y
left = target.x + target.width + POPOVER_GAP
}
left = Math.min(Math.max(16, left), vw - popW - 16)
top = Math.min(Math.max(16, top), vh - popH - 16)
if (placement === 'top' && target.y - popH - POPOVER_GAP < 16) {
top = Math.min(target.y + target.height + POPOVER_GAP, vh - popH - 16)
}
if (placement === 'bottom' && target.y + target.height + POPOVER_GAP + popH > vh - 16) {
top = Math.max(16, target.y - popH - POPOVER_GAP)
}
popoverPos.value = { top, left }
}
function updateLayout() {
const step = tour.currentStep
if (!step) {
highlight.value = null
return
}
const rect = measureTarget(step.selector)
highlight.value = rect
if (rect) {
nextTick(() => placePopover(rect, step.placement ?? 'bottom'))
} else {
popoverPos.value = { top: 24, left: 24 }
}
}
let focusRestore: HTMLElement | null = null
watch(
() => [tour.active, tour.stepIndex, tour.currentStep?.selector] as const,
async ([isActive]) => {
if (!isActive) {
highlight.value = null
if (focusRestore) {
focusRestore.focus()
focusRestore = null
}
return
}
if (!focusRestore) {
focusRestore = document.activeElement as HTMLElement | null
}
await nextTick()
updateLayout()
await nextTick()
nextBtnRef.value?.focus()
},
{ immediate: true },
)
function onResize() {
if (tour.active) updateLayout()
}
onMounted(() => {
window.addEventListener('resize', onResize)
window.addEventListener('scroll', onResize, true)
})
onUnmounted(() => {
window.removeEventListener('resize', onResize)
window.removeEventListener('scroll', onResize, true)
})
</script>
@@ -1,5 +1,9 @@
<template>
<div class="h-full min-h-0 flex flex-col" data-testid="verification-form">
<div
class="h-full min-h-0 flex flex-col"
data-testid="verification-form"
data-tour="verification-form"
>
<div class="flex-1 min-h-0 overflow-y-auto p-4 space-y-4">
<div class="flex items-center justify-between gap-3">
<div>
@@ -2,6 +2,7 @@
<div
class="sticky bottom-0 z-10 border-t border-line bg-surface/95 px-3 py-3 backdrop-blur-sm sm:px-4"
data-testid="workstation-action-bar"
data-tour="workstation-action-bar"
>
<div
class="flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between"
@@ -4,6 +4,7 @@
v-if="!hasBatch"
class="flex-1 min-h-0 overflow-auto p-4 sm:p-6"
data-testid="workstation-queue"
data-tour="workstation-queue"
>
<slot name="queue" />
</div>
@@ -22,7 +23,11 @@
>
<slot name="rail" />
</aside>
<section class="workstation-scan min-h-0 min-w-0" data-testid="workstation-scan">
<section
class="workstation-scan min-h-0 min-w-0"
data-testid="workstation-scan"
data-tour="workstation-scan"
>
<p class="evidence-level evidence-level--1" data-testid="evidence-level-1">
<span class="evidence-level-mark" aria-hidden="true">1</span>
Source scan