From 5865d9dbe536c936cc982a2314395391b19124b5 Mon Sep 17 00:00:00 2001 From: Andreas Weyer Date: Sat, 29 Nov 2025 18:45:30 +0000 Subject: [PATCH] Update style improvements and minor fixes --- src/App.tsx | 2 +- src/components/deviation-list.tsx | 108 +++++++++++----------- src/components/settings.tsx | 2 +- src/components/simulation-chart.tsx | 109 ++++++++++++++++++----- src/components/ui/form-numeric-input.tsx | 3 +- src/hooks/useSimulation.ts | 12 ++- src/utils/suggestions.ts | 12 ++- 7 files changed, 162 insertions(+), 86 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 572ed88..b71b7b4 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -64,7 +64,7 @@ const MedPlanAssistant = () => { removeDeviation, handleDeviationChange, applySuggestion - } = useSimulation(appState); + } = useSimulation(appState, t); return (
diff --git a/src/components/deviation-list.tsx b/src/components/deviation-list.tsx index 696f88a..e5636a0 100644 --- a/src/components/deviation-list.tsx +++ b/src/components/deviation-list.tsx @@ -36,69 +36,71 @@ const DeviationList = ({ {deviations.map((dev: any, index: number) => ( -
- +
+
+ - onDeviationChange(index, 'time', newTime)} - required={true} - errorMessage={t.timeRequired || 'Time is required'} - /> + onDeviationChange(index, 'time', newTime)} + required={true} + errorMessage={t.timeRequired || 'Time is required'} + /> - onDeviationChange(index, 'dose', newDose)} - increment={doseIncrement} - min={0} - unit={t.mg} - required={true} - errorMessage={t.doseRequired || 'Dose is required'} - /> + onDeviationChange(index, 'dose', newDose)} + increment={doseIncrement} + min={0} + unit={t.mg} + required={true} + errorMessage={t.doseRequired || 'Dose is required'} + /> + + + + +
+ onDeviationChange(index, 'isAdditional', checked)} + /> + +
+
+ +

{t.additionalTooltip}

+
+
+
+
- - - - -
- onDeviationChange(index, 'isAdditional', checked)} - /> - -
-
- -

{t.additionalTooltip}

-
-
-
))} diff --git a/src/components/settings.tsx b/src/components/settings.tsx index 836c0c9..80b21a9 100644 --- a/src/components/settings.tsx +++ b/src/components/settings.tsx @@ -35,7 +35,7 @@ const Settings = ({ {t.advancedSettings} -
+
diff --git a/src/components/simulation-chart.tsx b/src/components/simulation-chart.tsx index b80a4b8..02f4331 100644 --- a/src/components/simulation-chart.tsx +++ b/src/components/simulation-chart.tsx @@ -12,6 +12,27 @@ import React from 'react'; import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ReferenceLine, ResponsiveContainer } from 'recharts'; +// Chart color scheme +const CHART_COLORS = { + // d-Amphetamine profiles + idealDamph: '#2563eb', // blue-600 (primary, solid, bold) + deviatedDamph: '#f59e0b', // amber-500 (warning, dashed) + correctedDamph: '#10b981', // emerald-500 (success, dash-dot) + + // Lisdexamfetamine profiles + idealLdx: '#7c3aed', // violet-600 (primary, dashed) + deviatedLdx: '#f97316', // orange-500 (warning, dashed) + correctedLdx: '#059669', // emerald-600 (success, dash-dot) + + // Reference lines + therapeuticMin: '#22c55e', // green-500 + therapeuticMax: '#ef4444', // red-500 + dayDivider: '#9ca3af', // gray-400 + + // Tooltip cursor + cursor: '#6b7280' // gray-500 +} as const; + const SimulationChart = ({ idealProfile, deviatedProfile, @@ -46,11 +67,47 @@ const SimulationChart = ({ return [domainMin, domainMax]; }, [yAxisMin, yAxisMax]); + // Merge all profiles into a single dataset for proper tooltip synchronization + const mergedData = React.useMemo(() => { + const dataMap = new Map(); + + // Add ideal profile data + idealProfile?.forEach((point: any) => { + dataMap.set(point.timeHours, { + timeHours: point.timeHours, + idealDamph: point.damph, + idealLdx: point.ldx + }); + }); + + // Add deviated profile data + deviatedProfile?.forEach((point: any) => { + const existing = dataMap.get(point.timeHours) || { timeHours: point.timeHours }; + dataMap.set(point.timeHours, { + ...existing, + deviatedDamph: point.damph, + deviatedLdx: point.ldx + }); + }); + + // Add corrected profile data + correctedProfile?.forEach((point: any) => { + const existing = dataMap.get(point.timeHours) || { timeHours: point.timeHours }; + dataMap.set(point.timeHours, { + ...existing, + correctedDamph: point.damph, + correctedLdx: point.ldx + }); + }); + + return Array.from(dataMap.values()).sort((a, b) => a.timeHours - b.timeHours); + }, [idealProfile, deviatedProfile, correctedProfile]); + return ( -
+
- + [`${typeof value === 'number' ? value.toFixed(1) : value} ${t.ngml}`, name]} labelFormatter={(label) => `${t.hour.replace('h', 'Hour')}: ${label}${t.hour}`} + wrapperStyle={{ pointerEvents: 'none', zIndex: 200 }} + allowEscapeViewBox={{ x: false, y: false }} + cursor={{ stroke: CHART_COLORS.cursor, strokeWidth: 1, strokeDasharray: '1 1' }} + position={{ y: 0 }} /> - + {(chartView === 'damph' || chartView === 'both') && ( @@ -92,7 +153,7 @@ const SimulationChart = ({ @@ -103,7 +164,7 @@ const SimulationChart = ({ @@ -113,80 +174,80 @@ const SimulationChart = ({ {(chartView === 'damph' || chartView === 'both') && ( )} {(chartView === 'ldx' || chartView === 'both') && ( )} {deviatedProfile && (chartView === 'damph' || chartView === 'both') && ( )} {deviatedProfile && (chartView === 'ldx' || chartView === 'both') && ( )} {correctedProfile && (chartView === 'damph' || chartView === 'both') && ( )} {correctedProfile && (chartView === 'ldx' || chartView === 'both') && ( )} diff --git a/src/components/ui/form-numeric-input.tsx b/src/components/ui/form-numeric-input.tsx index e045479..64973c8 100644 --- a/src/components/ui/form-numeric-input.tsx +++ b/src/components/ui/form-numeric-input.tsx @@ -136,7 +136,7 @@ const FormNumericInput = React.forwardRef( return (
-
+