refactor: centralise detail panel inline styles into detail-styles.ts

Extract 5 shared style constants (detailRootStyle, sectionHeadingStyle,
bulletListStyle, bodyTextStyle, paragraphStyle) used across 5 of 6 detail
components. Replaces ~30 inline style object definitions with imports.
Net reduction: 274 lines across detail panel components.
This commit is contained in:
2026-02-17 02:09:26 +00:00
parent 7528935d2b
commit 49c9e0cecf
6 changed files with 83 additions and 352 deletions
+11 -98
View File
@@ -1,4 +1,5 @@
import type { Consultation } from '@/types/pmr' import type { Consultation } from '@/types/pmr'
import { detailRootStyle, sectionHeadingStyle, bulletListStyle, bodyTextStyle, paragraphStyle } from './detail-styles'
interface ConsultationDetailProps { interface ConsultationDetailProps {
consultation: Consultation consultation: Consultation
@@ -6,14 +7,7 @@ interface ConsultationDetailProps {
export function ConsultationDetail({ consultation }: ConsultationDetailProps) { export function ConsultationDetail({ consultation }: ConsultationDetailProps) {
return ( return (
<div <div style={detailRootStyle}>
style={{
fontFamily: 'var(--font-ui)',
display: 'flex',
flexDirection: 'column',
gap: '24px',
}}
>
{/* Role header */} {/* Role header */}
<div> <div>
<div <div
@@ -69,26 +63,8 @@ export function ConsultationDetail({ consultation }: ConsultationDetailProps) {
{/* History (presenting complaint) */} {/* History (presenting complaint) */}
<div> <div>
<h3 <h3 style={sectionHeadingStyle}>History</h3>
style={{ <p style={paragraphStyle}>
fontSize: '12px',
fontWeight: 600,
color: 'var(--text-secondary)',
textTransform: 'uppercase',
letterSpacing: '0.05em',
marginBottom: '8px',
}}
>
History
</h3>
<p
style={{
fontSize: '14px',
lineHeight: '1.6',
color: 'var(--text-primary)',
margin: 0,
}}
>
{consultation.history} {consultation.history}
</p> </p>
</div> </div>
@@ -96,36 +72,10 @@ export function ConsultationDetail({ consultation }: ConsultationDetailProps) {
{/* Examination (achievements) */} {/* Examination (achievements) */}
{consultation.examination && consultation.examination.length > 0 && ( {consultation.examination && consultation.examination.length > 0 && (
<div> <div>
<h3 <h3 style={sectionHeadingStyle}>Key Achievements</h3>
style={{ <ul style={bulletListStyle}>
fontSize: '12px',
fontWeight: 600,
color: 'var(--text-secondary)',
textTransform: 'uppercase',
letterSpacing: '0.05em',
marginBottom: '8px',
}}
>
Key Achievements
</h3>
<ul
style={{
margin: 0,
paddingLeft: '20px',
display: 'flex',
flexDirection: 'column',
gap: '8px',
}}
>
{consultation.examination.map((item, index) => ( {consultation.examination.map((item, index) => (
<li <li key={index} style={bodyTextStyle}>
key={index}
style={{
fontSize: '14px',
lineHeight: '1.6',
color: 'var(--text-primary)',
}}
>
{item} {item}
</li> </li>
))} ))}
@@ -136,36 +86,10 @@ export function ConsultationDetail({ consultation }: ConsultationDetailProps) {
{/* Plan (outcomes) */} {/* Plan (outcomes) */}
{consultation.plan && consultation.plan.length > 0 && ( {consultation.plan && consultation.plan.length > 0 && (
<div> <div>
<h3 <h3 style={sectionHeadingStyle}>Outcomes & Impact</h3>
style={{ <ul style={bulletListStyle}>
fontSize: '12px',
fontWeight: 600,
color: 'var(--text-secondary)',
textTransform: 'uppercase',
letterSpacing: '0.05em',
marginBottom: '8px',
}}
>
Outcomes & Impact
</h3>
<ul
style={{
margin: 0,
paddingLeft: '20px',
display: 'flex',
flexDirection: 'column',
gap: '8px',
}}
>
{consultation.plan.map((item, index) => ( {consultation.plan.map((item, index) => (
<li <li key={index} style={bodyTextStyle}>
key={index}
style={{
fontSize: '14px',
lineHeight: '1.6',
color: 'var(--text-primary)',
}}
>
{item} {item}
</li> </li>
))} ))}
@@ -176,18 +100,7 @@ export function ConsultationDetail({ consultation }: ConsultationDetailProps) {
{/* Coded entries (technical environment / tags) */} {/* Coded entries (technical environment / tags) */}
{consultation.codedEntries && consultation.codedEntries.length > 0 && ( {consultation.codedEntries && consultation.codedEntries.length > 0 && (
<div> <div>
<h3 <h3 style={sectionHeadingStyle}>Coded Entries</h3>
style={{
fontSize: '12px',
fontWeight: 600,
color: 'var(--text-secondary)',
textTransform: 'uppercase',
letterSpacing: '0.05em',
marginBottom: '8px',
}}
>
Coded Entries
</h3>
<div <div
style={{ style={{
display: 'flex', display: 'flex',
+12 -58
View File
@@ -1,20 +1,12 @@
import { GraduationCap, Award, BookOpen, FlaskConical, type LucideIcon } from 'lucide-react' import { GraduationCap, Award, BookOpen, FlaskConical, type LucideIcon } from 'lucide-react'
import type { Document } from '@/types/pmr' import type { Document } from '@/types/pmr'
import { educationExtras } from '@/data/educationExtras' import { educationExtras } from '@/data/educationExtras'
import { detailRootStyle, sectionHeadingStyle, bulletListStyle, bodyTextStyle, paragraphStyle } from './detail-styles'
interface EducationDetailProps { interface EducationDetailProps {
document: Document document: Document
} }
const sectionHeaderStyle: React.CSSProperties = {
fontSize: '12px',
fontWeight: 600,
color: 'var(--text-secondary)',
textTransform: 'uppercase',
letterSpacing: '0.05em',
marginBottom: '8px',
}
const typeIconMap: Record<string, LucideIcon> = { const typeIconMap: Record<string, LucideIcon> = {
Certificate: GraduationCap, Certificate: GraduationCap,
Registration: Award, Registration: Award,
@@ -27,14 +19,7 @@ export function EducationDetail({ document }: EducationDetailProps) {
const Icon = typeIconMap[document.type] || GraduationCap const Icon = typeIconMap[document.type] || GraduationCap
return ( return (
<div <div style={detailRootStyle}>
style={{
fontFamily: 'var(--font-ui)',
display: 'flex',
flexDirection: 'column',
gap: '24px',
}}
>
{/* Header */} {/* Header */}
<div> <div>
<div <div
@@ -117,15 +102,8 @@ export function EducationDetail({ document }: EducationDetailProps) {
{/* Research project (MPharm) */} {/* Research project (MPharm) */}
{extra?.researchDescription && ( {extra?.researchDescription && (
<div> <div>
<h3 style={sectionHeaderStyle}>Research Project</h3> <h3 style={sectionHeadingStyle}>Research Project</h3>
<p <p style={paragraphStyle}>
style={{
fontSize: '14px',
lineHeight: '1.6',
color: 'var(--text-primary)',
margin: 0,
}}
>
{extra.researchDescription} {extra.researchDescription}
</p> </p>
</div> </div>
@@ -134,7 +112,7 @@ export function EducationDetail({ document }: EducationDetailProps) {
{/* OSCE score (MPharm) */} {/* OSCE score (MPharm) */}
{extra?.osceScore && ( {extra?.osceScore && (
<div> <div>
<h3 style={sectionHeaderStyle}>OSCE Performance</h3> <h3 style={sectionHeadingStyle}>OSCE Performance</h3>
<div <div
style={{ style={{
display: 'inline-flex', display: 'inline-flex',
@@ -170,25 +148,10 @@ export function EducationDetail({ document }: EducationDetailProps) {
{/* Extracurricular activities (MPharm) */} {/* Extracurricular activities (MPharm) */}
{extra?.extracurriculars && extra.extracurriculars.length > 0 && ( {extra?.extracurriculars && extra.extracurriculars.length > 0 && (
<div> <div>
<h3 style={sectionHeaderStyle}>Extracurricular Activities</h3> <h3 style={sectionHeadingStyle}>Extracurricular Activities</h3>
<ul <ul style={bulletListStyle}>
style={{
margin: 0,
paddingLeft: '20px',
display: 'flex',
flexDirection: 'column',
gap: '8px',
}}
>
{extra.extracurriculars.map((activity, index) => ( {extra.extracurriculars.map((activity, index) => (
<li <li key={index} style={bodyTextStyle}>
key={index}
style={{
fontSize: '14px',
lineHeight: '1.6',
color: 'var(--text-primary)',
}}
>
{activity} {activity}
</li> </li>
))} ))}
@@ -199,15 +162,8 @@ export function EducationDetail({ document }: EducationDetailProps) {
{/* Programme detail (Mary Seacole) */} {/* Programme detail (Mary Seacole) */}
{extra?.programmeDetail && ( {extra?.programmeDetail && (
<div> <div>
<h3 style={sectionHeaderStyle}>Programme Overview</h3> <h3 style={sectionHeadingStyle}>Programme Overview</h3>
<p <p style={paragraphStyle}>
style={{
fontSize: '14px',
lineHeight: '1.6',
color: 'var(--text-primary)',
margin: 0,
}}
>
{extra.programmeDetail} {extra.programmeDetail}
</p> </p>
</div> </div>
@@ -216,13 +172,11 @@ export function EducationDetail({ document }: EducationDetailProps) {
{/* Notes */} {/* Notes */}
{document.notes && ( {document.notes && (
<div> <div>
<h3 style={sectionHeaderStyle}>Notes</h3> <h3 style={sectionHeadingStyle}>Notes</h3>
<p <p
style={{ style={{
fontSize: '14px', ...paragraphStyle,
lineHeight: '1.6',
color: 'var(--text-secondary)', color: 'var(--text-secondary)',
margin: 0,
fontStyle: 'italic', fontStyle: 'italic',
}} }}
> >
+9 -81
View File
@@ -1,5 +1,6 @@
import type { KPI } from '@/types/pmr' import type { KPI } from '@/types/pmr'
import { KPI_COLORS } from '@/lib/theme-colors' import { KPI_COLORS } from '@/lib/theme-colors'
import { detailRootStyle, sectionHeadingStyle, bulletListStyle, bodyTextStyle, paragraphStyle } from './detail-styles'
interface KPIDetailProps { interface KPIDetailProps {
kpi: KPI kpi: KPI
@@ -35,14 +36,7 @@ export function KPIDetail({ kpi }: KPIDetailProps) {
const { context, role, outcomes, period } = kpi.story const { context, role, outcomes, period } = kpi.story
return ( return (
<div <div style={detailRootStyle}>
style={{
fontFamily: 'var(--font-ui)',
display: 'flex',
flexDirection: 'column',
gap: '24px',
}}
>
{/* Headline number */} {/* Headline number */}
<div> <div>
<div <div
@@ -98,88 +92,22 @@ export function KPIDetail({ kpi }: KPIDetailProps) {
{/* Context paragraph */} {/* Context paragraph */}
<div> <div>
<h3 <h3 style={sectionHeadingStyle}>Context</h3>
style={{ <p style={paragraphStyle}>{context}</p>
fontSize: '12px',
fontWeight: 600,
color: 'var(--text-secondary)',
textTransform: 'uppercase',
letterSpacing: '0.05em',
marginBottom: '8px',
}}
>
Context
</h3>
<p
style={{
fontSize: '14px',
lineHeight: '1.6',
color: 'var(--text-primary)',
margin: 0,
}}
>
{context}
</p>
</div> </div>
{/* Your role paragraph */} {/* Your role paragraph */}
<div> <div>
<h3 <h3 style={sectionHeadingStyle}>Your Role</h3>
style={{ <p style={paragraphStyle}>{role}</p>
fontSize: '12px',
fontWeight: 600,
color: 'var(--text-secondary)',
textTransform: 'uppercase',
letterSpacing: '0.05em',
marginBottom: '8px',
}}
>
Your Role
</h3>
<p
style={{
fontSize: '14px',
lineHeight: '1.6',
color: 'var(--text-primary)',
margin: 0,
}}
>
{role}
</p>
</div> </div>
{/* Outcome bullets */} {/* Outcome bullets */}
<div> <div>
<h3 <h3 style={sectionHeadingStyle}>Key Outcomes</h3>
style={{ <ul style={bulletListStyle}>
fontSize: '12px',
fontWeight: 600,
color: 'var(--text-secondary)',
textTransform: 'uppercase',
letterSpacing: '0.05em',
marginBottom: '8px',
}}
>
Key Outcomes
</h3>
<ul
style={{
margin: 0,
paddingLeft: '20px',
display: 'flex',
flexDirection: 'column',
gap: '8px',
}}
>
{outcomes.map((outcome, index) => ( {outcomes.map((outcome, index) => (
<li <li key={index} style={bodyTextStyle}>
key={index}
style={{
fontSize: '14px',
lineHeight: '1.6',
color: 'var(--text-primary)',
}}
>
{outcome} {outcome}
</li> </li>
))} ))}
+8 -71
View File
@@ -1,6 +1,7 @@
import { ExternalLink } from 'lucide-react' import { ExternalLink } from 'lucide-react'
import type { Investigation } from '@/types/pmr' import type { Investigation } from '@/types/pmr'
import { PROJECT_STATUS_COLORS } from '@/lib/theme-colors' import { PROJECT_STATUS_COLORS } from '@/lib/theme-colors'
import { detailRootStyle, sectionHeadingStyle, bulletListStyle, bodyTextStyle, paragraphStyle } from './detail-styles'
interface ProjectDetailProps { interface ProjectDetailProps {
investigation: Investigation investigation: Investigation
@@ -17,14 +18,7 @@ export function ProjectDetail({ investigation }: ProjectDetailProps) {
const statusBg = statusBgMap[investigation.status] const statusBg = statusBgMap[investigation.status]
return ( return (
<div <div style={detailRootStyle}>
style={{
fontFamily: 'var(--font-ui)',
display: 'flex',
flexDirection: 'column',
gap: '24px',
}}
>
{/* Header: name + year + status */} {/* Header: name + year + status */}
<div> <div>
<div <div
@@ -72,44 +66,13 @@ export function ProjectDetail({ investigation }: ProjectDetailProps) {
{/* Methodology */} {/* Methodology */}
<div> <div>
<h3 <h3 style={sectionHeadingStyle}>Methodology</h3>
style={{ <p style={paragraphStyle}>{investigation.methodology}</p>
fontSize: '12px',
fontWeight: 600,
color: 'var(--text-secondary)',
textTransform: 'uppercase',
letterSpacing: '0.05em',
marginBottom: '8px',
}}
>
Methodology
</h3>
<p
style={{
fontSize: '14px',
lineHeight: '1.6',
color: 'var(--text-primary)',
margin: 0,
}}
>
{investigation.methodology}
</p>
</div> </div>
{/* Tech stack tags */} {/* Tech stack tags */}
<div> <div>
<h3 <h3 style={sectionHeadingStyle}>Tech Stack</h3>
style={{
fontSize: '12px',
fontWeight: 600,
color: 'var(--text-secondary)',
textTransform: 'uppercase',
letterSpacing: '0.05em',
marginBottom: '8px',
}}
>
Tech Stack
</h3>
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '6px' }}> <div style={{ display: 'flex', flexWrap: 'wrap', gap: '6px' }}>
{investigation.techStack.map((tech) => ( {investigation.techStack.map((tech) => (
<span <span
@@ -133,36 +96,10 @@ export function ProjectDetail({ investigation }: ProjectDetailProps) {
{/* Results */} {/* Results */}
<div> <div>
<h3 <h3 style={sectionHeadingStyle}>Results</h3>
style={{ <ul style={bulletListStyle}>
fontSize: '12px',
fontWeight: 600,
color: 'var(--text-secondary)',
textTransform: 'uppercase',
letterSpacing: '0.05em',
marginBottom: '8px',
}}
>
Results
</h3>
<ul
style={{
margin: 0,
paddingLeft: '20px',
display: 'flex',
flexDirection: 'column',
gap: '8px',
}}
>
{investigation.results.map((result, index) => ( {investigation.results.map((result, index) => (
<li <li key={index} style={bodyTextStyle}>
key={index}
style={{
fontSize: '14px',
lineHeight: '1.6',
color: 'var(--text-primary)',
}}
>
{result} {result}
</li> </li>
))} ))}
+5 -44
View File
@@ -1,5 +1,6 @@
import type { SkillMedication } from '@/types/pmr' import type { SkillMedication } from '@/types/pmr'
import { roleSkillMappings, constellationNodes } from '@/data/constellation' import { roleSkillMappings, constellationNodes } from '@/data/constellation'
import { detailRootStyle, sectionHeadingStyle } from './detail-styles'
interface SkillDetailProps { interface SkillDetailProps {
skill: SkillMedication skill: SkillMedication
@@ -32,14 +33,7 @@ export function SkillDetail({ skill }: SkillDetailProps) {
.sort((a, b) => (a!.startYear ?? 0) - (b!.startYear ?? 0)) .sort((a, b) => (a!.startYear ?? 0) - (b!.startYear ?? 0))
return ( return (
<div <div style={detailRootStyle}>
style={{
fontFamily: 'var(--font-ui)',
display: 'flex',
flexDirection: 'column',
gap: '24px',
}}
>
{/* Skill header */} {/* Skill header */}
<div> <div>
<div <div
@@ -104,18 +98,7 @@ export function SkillDetail({ skill }: SkillDetailProps) {
{/* Proficiency bar */} {/* Proficiency bar */}
<div> <div>
<h3 <h3 style={sectionHeadingStyle}>Proficiency</h3>
style={{
fontSize: '12px',
fontWeight: 600,
color: 'var(--text-secondary)',
textTransform: 'uppercase',
letterSpacing: '0.05em',
marginBottom: '8px',
}}
>
Proficiency
</h3>
<div style={{ display: 'flex', alignItems: 'center', gap: '12px' }}> <div style={{ display: 'flex', alignItems: 'center', gap: '12px' }}>
<div <div
style={{ style={{
@@ -153,18 +136,7 @@ export function SkillDetail({ skill }: SkillDetailProps) {
{/* Years of experience */} {/* Years of experience */}
<div> <div>
<h3 <h3 style={sectionHeadingStyle}>Experience</h3>
style={{
fontSize: '12px',
fontWeight: 600,
color: 'var(--text-secondary)',
textTransform: 'uppercase',
letterSpacing: '0.05em',
marginBottom: '8px',
}}
>
Experience
</h3>
<div style={{ display: 'flex', alignItems: 'baseline', gap: '6px' }}> <div style={{ display: 'flex', alignItems: 'baseline', gap: '6px' }}>
<span <span
style={{ style={{
@@ -200,18 +172,7 @@ export function SkillDetail({ skill }: SkillDetailProps) {
{/* Used in roles */} {/* Used in roles */}
{usedInRoles.length > 0 && ( {usedInRoles.length > 0 && (
<div> <div>
<h3 <h3 style={{ ...sectionHeadingStyle, marginBottom: '10px' }}>Used In</h3>
style={{
fontSize: '12px',
fontWeight: 600,
color: 'var(--text-secondary)',
textTransform: 'uppercase',
letterSpacing: '0.05em',
marginBottom: '10px',
}}
>
Used In
</h3>
<div style={{ display: 'flex', flexDirection: 'column', gap: '8px' }}> <div style={{ display: 'flex', flexDirection: 'column', gap: '8px' }}>
{usedInRoles.map((node) => ( {usedInRoles.map((node) => (
<div <div
+38
View File
@@ -0,0 +1,38 @@
import type { CSSProperties } from 'react'
export const detailRootStyle: CSSProperties = {
fontFamily: 'var(--font-ui)',
display: 'flex',
flexDirection: 'column',
gap: '24px',
}
export const sectionHeadingStyle: CSSProperties = {
fontSize: '12px',
fontWeight: 600,
color: 'var(--text-secondary)',
textTransform: 'uppercase',
letterSpacing: '0.05em',
marginBottom: '8px',
}
export const bulletListStyle: CSSProperties = {
margin: 0,
paddingLeft: '20px',
display: 'flex',
flexDirection: 'column',
gap: '8px',
}
export const bodyTextStyle: CSSProperties = {
fontSize: '14px',
lineHeight: '1.6',
color: 'var(--text-primary)',
}
export const paragraphStyle: CSSProperties = {
fontSize: '14px',
lineHeight: '1.6',
color: 'var(--text-primary)',
margin: 0,
}