feat: compact latest results kpi section

This commit is contained in:
2026-02-16 10:36:30 +00:00
parent 2306d2ec2e
commit ab80d65958
2 changed files with 84 additions and 127 deletions
+23 -49
View File
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react' import React from 'react'
import { FileText, ChevronRight } from 'lucide-react' import { FileText, ChevronRight } from 'lucide-react'
import { CardHeader } from '../Card' import { CardHeader } from '../Card'
import { ParentSection } from '../ParentSection' import { ParentSection } from '../ParentSection'
@@ -12,26 +12,20 @@ const colorMap: Record<KPI['colorVariant'], string> = {
teal: '#0D6E6E', teal: '#0D6E6E',
} }
const KPI_COACHMARK_KEY = 'kpi-evidence-coachmark-dismissed-v1'
interface MetricCardProps { interface MetricCardProps {
kpi: KPI kpi: KPI
showCoachmark?: boolean
onOpen: () => void
} }
function MetricCard({ kpi, showCoachmark = false, onOpen }: MetricCardProps) { function MetricCard({ kpi }: MetricCardProps) {
const { openPanel } = useDetailPanel() const { openPanel } = useDetailPanel()
const handleClick = () => { const handleClick = () => {
onOpen()
openPanel({ type: 'kpi', kpi }) openPanel({ type: 'kpi', kpi })
} }
const handleKeyDown = (e: React.KeyboardEvent) => { const handleKeyDown = (e: React.KeyboardEvent) => {
if (e.key === 'Enter' || e.key === ' ') { if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault() e.preventDefault()
onOpen()
openPanel({ type: 'kpi', kpi }) openPanel({ type: 'kpi', kpi })
} }
} }
@@ -39,7 +33,7 @@ function MetricCard({ kpi, showCoachmark = false, onOpen }: MetricCardProps) {
const buttonStyles: React.CSSProperties = { const buttonStyles: React.CSSProperties = {
width: '100%', width: '100%',
textAlign: 'left', textAlign: 'left',
padding: '20px', padding: '16px 16px 14px',
background: 'var(--surface)', background: 'var(--surface)',
border: '1px solid var(--border-light)', border: '1px solid var(--border-light)',
borderRadius: 'var(--radius-sm)', borderRadius: 'var(--radius-sm)',
@@ -48,11 +42,11 @@ function MetricCard({ kpi, showCoachmark = false, onOpen }: MetricCardProps) {
position: 'relative', position: 'relative',
display: 'flex', display: 'flex',
flexDirection: 'column', flexDirection: 'column',
gap: '2px', gap: 0,
} }
const valueStyles: React.CSSProperties = { const valueStyles: React.CSSProperties = {
fontSize: '34px', fontSize: '30px',
fontWeight: 700, fontWeight: 700,
letterSpacing: '-0.02em', letterSpacing: '-0.02em',
lineHeight: 1.2, lineHeight: 1.2,
@@ -60,85 +54,62 @@ function MetricCard({ kpi, showCoachmark = false, onOpen }: MetricCardProps) {
} }
const labelStyles: React.CSSProperties = { const labelStyles: React.CSSProperties = {
fontSize: '14px', fontSize: '13px',
fontWeight: 500, fontWeight: 500,
color: 'var(--text-primary)', color: 'var(--text-primary)',
marginTop: '4px', marginTop: '4px',
} }
const subStyles: React.CSSProperties = { const subStyles: React.CSSProperties = {
fontSize: '12px', fontSize: '11px',
color: 'var(--text-tertiary)', color: 'var(--text-tertiary)',
fontFamily: 'var(--font-geist-mono)', fontFamily: 'var(--font-geist-mono)',
marginTop: '2px', marginTop: '2px',
} }
return ( return (
<div className={showCoachmark ? 'kpi-card-coachmark-target' : undefined} style={{ position: 'relative' }}>
{showCoachmark && (
<div className="kpi-coachmark" role="status" aria-live="polite">
Open any metric to see evidence
</div>
)}
<button <button
onClick={handleClick} onClick={handleClick}
onKeyDown={handleKeyDown} onKeyDown={handleKeyDown}
style={buttonStyles} style={buttonStyles}
className={`metric-card ${showCoachmark ? 'metric-card-pulse' : ''}`} className="metric-card"
aria-label={`${kpi.label}: ${kpi.value}. Click to view details.`} aria-label={`${kpi.label}: ${kpi.value}. Click to view details.`}
> >
<div <div
style={{ style={{
position: 'absolute', position: 'absolute',
top: '14px', top: '12px',
right: '14px', right: '12px',
color: 'var(--accent)', color: 'var(--accent)',
opacity: 0.85, opacity: 0.85,
}} }}
aria-hidden="true" aria-hidden="true"
> >
<FileText size={14} /> <FileText size={13} />
</div> </div>
<div style={valueStyles}>{kpi.value}</div> <div style={valueStyles}>{kpi.value}</div>
<div style={labelStyles}>{kpi.label}</div> <div style={labelStyles}>{kpi.label}</div>
<div style={subStyles}>{kpi.sub}</div> <div style={subStyles}>{kpi.sub}</div>
<div <div
style={{ style={{
marginTop: '10px', marginTop: '8px',
display: 'inline-flex', display: 'inline-flex',
alignItems: 'center', alignItems: 'center',
gap: '6px', gap: '5px',
fontSize: '12px', fontSize: '11px',
fontWeight: 600, fontWeight: 600,
color: 'var(--accent)', color: 'var(--accent)',
fontFamily: 'var(--font-geist-mono)', fontFamily: 'var(--font-geist-mono)',
}} }}
> >
Click to view evidence Click to view evidence
<ChevronRight size={13} /> <ChevronRight size={12} />
</div> </div>
</button> </button>
</div>
) )
} }
export function PatientSummaryTile() { export function PatientSummaryTile() {
const [showCoachmark, setShowCoachmark] = useState(false)
useEffect(() => {
if (typeof window === 'undefined') return
const hasDismissed = window.localStorage.getItem(KPI_COACHMARK_KEY) === '1'
if (!hasDismissed) {
setShowCoachmark(true)
}
}, [])
const handleMetricOpen = () => {
if (!showCoachmark) return
setShowCoachmark(false)
window.localStorage.setItem(KPI_COACHMARK_KEY, '1')
}
const profileTextStyles: React.CSSProperties = { const profileTextStyles: React.CSSProperties = {
fontSize: '15px', fontSize: '15px',
lineHeight: '1.65', lineHeight: '1.65',
@@ -147,7 +118,8 @@ export function PatientSummaryTile() {
const kpiGridStyles: React.CSSProperties = { const kpiGridStyles: React.CSSProperties = {
display: 'grid', display: 'grid',
gap: '16px', gap: '10px',
gridTemplateColumns: '1fr',
} }
return ( return (
@@ -165,10 +137,11 @@ export function PatientSummaryTile() {
{/* Latest Results subsection */} {/* Latest Results subsection */}
<div style={{ marginTop: '28px' }}> <div style={{ marginTop: '28px' }}>
<div className="latest-results-header">
<CardHeader dotColor="teal" title="LATEST RESULTS (CLICK TO VIEW FULL REFERENCE RANGE)" rightText="Updated May 2025" /> <CardHeader dotColor="teal" title="LATEST RESULTS (CLICK TO VIEW FULL REFERENCE RANGE)" rightText="Updated May 2025" />
<p <p
style={{ style={{
margin: '0 0 12px 0', margin: 0,
fontSize: '12px', fontSize: '12px',
color: 'var(--text-secondary)', color: 'var(--text-secondary)',
fontFamily: 'var(--font-geist-mono)', fontFamily: 'var(--font-geist-mono)',
@@ -176,9 +149,10 @@ export function PatientSummaryTile() {
> >
Select a metric to inspect methodology, impact, and outcomes. Select a metric to inspect methodology, impact, and outcomes.
</p> </p>
<div className="grid-cols-1 xs:grid-cols-2" style={kpiGridStyles}> </div>
{kpis.map((kpi, index) => ( <div className="latest-results-grid" style={kpiGridStyles}>
<MetricCard key={kpi.id} kpi={kpi} onOpen={handleMetricOpen} showCoachmark={showCoachmark && index === 0} /> {kpis.map((kpi) => (
<MetricCard key={kpi.id} kpi={kpi} />
))} ))}
</div> </div>
</div> </div>
+22 -39
View File
@@ -204,26 +204,6 @@ body {
animation: fadeIn 200ms ease-out forwards; animation: fadeIn 200ms ease-out forwards;
} }
@keyframes kpiPulse {
0%, 100% {
box-shadow: 0 0 0 0 rgba(10, 128, 128, 0.12);
}
50% {
box-shadow: 0 0 0 8px rgba(10, 128, 128, 0);
}
}
@keyframes coachmarkIn {
from {
opacity: 0;
transform: translateY(-4px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.scrollbar-hide { .scrollbar-hide {
-ms-overflow-style: none; -ms-overflow-style: none;
scrollbar-width: none; scrollbar-width: none;
@@ -314,29 +294,32 @@ html {
transform: translateY(0) scale(0.992); transform: translateY(0) scale(0.992);
} }
.metric-card-pulse { .latest-results-header {
animation: kpiPulse 1.8s ease-out infinite; display: flex;
flex-direction: column;
align-items: flex-start;
gap: 8px;
} }
.kpi-card-coachmark-target { .latest-results-header > div {
margin-top: 24px; margin-bottom: 0 !important;
} }
.kpi-coachmark { .latest-results-grid {
position: absolute; margin-top: 12px;
top: -28px; }
left: 0;
z-index: 2; @media (min-width: 768px) {
padding: 4px 8px; .latest-results-header {
border-radius: 999px; flex-direction: row;
font-size: 11px; align-items: center;
font-weight: 600; justify-content: space-between;
letter-spacing: 0.02em; gap: 12px;
font-family: var(--font-geist-mono); }
color: var(--accent);
background: rgba(10, 128, 128, 0.1); .latest-results-grid {
border: 1px solid var(--accent-border); grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
animation: coachmarkIn 180ms ease-out; }
} }
/* Dashboard card grid responsive — mobile-first */ /* Dashboard card grid responsive — mobile-first */