refactor: centralise color maps, org color fallback, and motion-safe transitions
Create src/lib/theme-colors.ts with DOT_COLORS, KPI_COLORS, PROJECT_STATUS_COLORS, and DEFAULT_ORG_COLOR constants. Add motionSafeTransition() utility to src/lib/utils.ts. Removes 6 duplicate color map definitions across Card, DetailPanel, PatientSummaryTile, KPIDetail, ProjectsTile, and ProjectDetail. Replaces 9 hardcoded '#0D6E6E' fallbacks and 7 inline motion ternaries. Fixes project status color inconsistency between ProjectsTile and ProjectDetail (Ongoing was teal in tile, amber in detail).
This commit is contained in:
@@ -1,16 +1,10 @@
|
||||
import type { KPI } from '@/types/pmr'
|
||||
import { KPI_COLORS } from '@/lib/theme-colors'
|
||||
|
||||
interface KPIDetailProps {
|
||||
kpi: KPI
|
||||
}
|
||||
|
||||
// Color map for KPI values
|
||||
const colorMap: Record<KPI['colorVariant'], string> = {
|
||||
green: '#059669',
|
||||
amber: '#D97706',
|
||||
teal: '#0D6E6E',
|
||||
}
|
||||
|
||||
export function KPIDetail({ kpi }: KPIDetailProps) {
|
||||
// If story exists, render rich content; otherwise fallback to explanation
|
||||
if (!kpi.story) {
|
||||
@@ -27,7 +21,7 @@ export function KPIDetail({ kpi }: KPIDetailProps) {
|
||||
style={{
|
||||
fontSize: '32px',
|
||||
fontWeight: 700,
|
||||
color: colorMap[kpi.colorVariant],
|
||||
color: KPI_COLORS[kpi.colorVariant],
|
||||
marginBottom: '16px',
|
||||
}}
|
||||
>
|
||||
@@ -55,7 +49,7 @@ export function KPIDetail({ kpi }: KPIDetailProps) {
|
||||
style={{
|
||||
fontSize: '48px',
|
||||
fontWeight: 700,
|
||||
color: colorMap[kpi.colorVariant],
|
||||
color: KPI_COLORS[kpi.colorVariant],
|
||||
lineHeight: '1',
|
||||
marginBottom: '8px',
|
||||
}}
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
import { ExternalLink } from 'lucide-react'
|
||||
import type { Investigation } from '@/types/pmr'
|
||||
import { PROJECT_STATUS_COLORS } from '@/lib/theme-colors'
|
||||
|
||||
interface ProjectDetailProps {
|
||||
investigation: Investigation
|
||||
}
|
||||
|
||||
const statusColorMap: Record<Investigation['status'], string> = {
|
||||
Complete: '#059669',
|
||||
Ongoing: '#D97706',
|
||||
Live: '#0D6E6E',
|
||||
}
|
||||
|
||||
const statusBgMap: Record<Investigation['status'], string> = {
|
||||
Complete: 'rgba(5,150,105,0.08)',
|
||||
Ongoing: 'rgba(217,119,6,0.08)',
|
||||
@@ -18,7 +13,7 @@ const statusBgMap: Record<Investigation['status'], string> = {
|
||||
}
|
||||
|
||||
export function ProjectDetail({ investigation }: ProjectDetailProps) {
|
||||
const statusColor = statusColorMap[investigation.status]
|
||||
const statusColor = PROJECT_STATUS_COLORS[investigation.status]
|
||||
const statusBg = statusBgMap[investigation.status]
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user