Rearranged graph vs timeline
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import React from 'react'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { FileText, ChevronRight } from 'lucide-react'
|
||||
import { CardHeader } from '../Card'
|
||||
import { ParentSection } from '../ParentSection'
|
||||
import { kpis } from '@/data/kpis'
|
||||
@@ -11,20 +12,26 @@ const colorMap: Record<KPI['colorVariant'], string> = {
|
||||
teal: '#0D6E6E',
|
||||
}
|
||||
|
||||
const KPI_COACHMARK_KEY = 'kpi-evidence-coachmark-dismissed-v1'
|
||||
|
||||
interface MetricCardProps {
|
||||
kpi: KPI
|
||||
showCoachmark?: boolean
|
||||
onOpen: () => void
|
||||
}
|
||||
|
||||
function MetricCard({ kpi }: MetricCardProps) {
|
||||
function MetricCard({ kpi, showCoachmark = false, onOpen }: MetricCardProps) {
|
||||
const { openPanel } = useDetailPanel()
|
||||
|
||||
const handleClick = () => {
|
||||
onOpen()
|
||||
openPanel({ type: 'kpi', kpi })
|
||||
}
|
||||
|
||||
const handleKeyDown = (e: React.KeyboardEvent) => {
|
||||
if (e.key === 'Enter' || e.key === ' ') {
|
||||
e.preventDefault()
|
||||
onOpen()
|
||||
openPanel({ type: 'kpi', kpi })
|
||||
}
|
||||
}
|
||||
@@ -37,7 +44,11 @@ function MetricCard({ kpi }: MetricCardProps) {
|
||||
border: '1px solid var(--border-light)',
|
||||
borderRadius: 'var(--radius-sm)',
|
||||
cursor: 'pointer',
|
||||
transition: 'border-color 150ms ease-out, box-shadow 150ms ease-out',
|
||||
transition: 'border-color 160ms ease-out, box-shadow 160ms ease-out, transform 120ms ease-out',
|
||||
position: 'relative',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: '2px',
|
||||
}
|
||||
|
||||
const valueStyles: React.CSSProperties = {
|
||||
@@ -63,28 +74,71 @@ function MetricCard({ kpi }: MetricCardProps) {
|
||||
}
|
||||
|
||||
return (
|
||||
<button
|
||||
onClick={handleClick}
|
||||
onKeyDown={handleKeyDown}
|
||||
style={buttonStyles}
|
||||
aria-label={`${kpi.label}: ${kpi.value}. Click to view details.`}
|
||||
onMouseEnter={(e) => {
|
||||
e.currentTarget.style.borderColor = 'var(--accent-border)'
|
||||
e.currentTarget.style.boxShadow = 'var(--shadow-md)'
|
||||
}}
|
||||
onMouseLeave={(e) => {
|
||||
e.currentTarget.style.borderColor = 'var(--border-light)'
|
||||
e.currentTarget.style.boxShadow = 'none'
|
||||
}}
|
||||
>
|
||||
<div style={valueStyles}>{kpi.value}</div>
|
||||
<div style={labelStyles}>{kpi.label}</div>
|
||||
<div style={subStyles}>{kpi.sub}</div>
|
||||
</button>
|
||||
<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
|
||||
onClick={handleClick}
|
||||
onKeyDown={handleKeyDown}
|
||||
style={buttonStyles}
|
||||
className={`metric-card ${showCoachmark ? 'metric-card-pulse' : ''}`}
|
||||
aria-label={`${kpi.label}: ${kpi.value}. Click to view details.`}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
position: 'absolute',
|
||||
top: '14px',
|
||||
right: '14px',
|
||||
color: 'var(--accent)',
|
||||
opacity: 0.85,
|
||||
}}
|
||||
aria-hidden="true"
|
||||
>
|
||||
<FileText size={14} />
|
||||
</div>
|
||||
<div style={valueStyles}>{kpi.value}</div>
|
||||
<div style={labelStyles}>{kpi.label}</div>
|
||||
<div style={subStyles}>{kpi.sub}</div>
|
||||
<div
|
||||
style={{
|
||||
marginTop: '10px',
|
||||
display: 'inline-flex',
|
||||
alignItems: 'center',
|
||||
gap: '6px',
|
||||
fontSize: '12px',
|
||||
fontWeight: 600,
|
||||
color: 'var(--accent)',
|
||||
fontFamily: 'var(--font-geist-mono)',
|
||||
}}
|
||||
>
|
||||
Click to view evidence
|
||||
<ChevronRight size={13} />
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
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 = {
|
||||
fontSize: '15px',
|
||||
lineHeight: '1.65',
|
||||
@@ -111,10 +165,20 @@ export function PatientSummaryTile() {
|
||||
|
||||
{/* Latest Results subsection */}
|
||||
<div style={{ marginTop: '28px' }}>
|
||||
<CardHeader dotColor="teal" title="LATEST RESULTS" rightText="Updated May 2025" />
|
||||
<CardHeader dotColor="teal" title="LATEST RESULTS (CLICK TO VIEW FULL REFERENCE RANGE)" rightText="Updated May 2025" />
|
||||
<p
|
||||
style={{
|
||||
margin: '0 0 12px 0',
|
||||
fontSize: '12px',
|
||||
color: 'var(--text-secondary)',
|
||||
fontFamily: 'var(--font-geist-mono)',
|
||||
}}
|
||||
>
|
||||
Select a metric to inspect methodology, impact, and outcomes.
|
||||
</p>
|
||||
<div className="grid-cols-1 xs:grid-cols-2" style={kpiGridStyles}>
|
||||
{kpis.map((kpi) => (
|
||||
<MetricCard key={kpi.id} kpi={kpi} />
|
||||
{kpis.map((kpi, index) => (
|
||||
<MetricCard key={kpi.id} kpi={kpi} onOpen={handleMetricOpen} showCoachmark={showCoachmark && index === 0} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user