diff --git a/src/components/charts/mood-chart.tsx b/src/components/charts/mood-chart.tsx index de2b0800a..86c5aaef2 100644 --- a/src/components/charts/mood-chart.tsx +++ b/src/components/charts/mood-chart.tsx @@ -51,6 +51,17 @@ interface ChartDataPoint { interface MoodChartProps { title?: string; + /** + * v1.4.16 phase B5c — compact mode for embedding inside the + * RecommendationCard. Hides the range tabs / toggle row and shrinks + * padding. Tooltip + emoji glyphs at data points stay intact. + */ + mini?: boolean; + /** + * v1.4.16 phase B5c — pin the chart to a specific rationale data + * window regardless of any parent UI state. + */ + windowOverride?: "last7days" | "last30days" | "last90days" | "allTime"; } // --- Constants --- @@ -226,10 +237,23 @@ export function aggregateMoodEntries(entries: MoodEntryDay[]): { // --- Component --- -export function MoodChart({ title }: MoodChartProps) { +const MINI_RANGE_POINTS: Record< + NonNullable, + number +> = { + last7days: 7, + last30days: 30, + last90days: 90, + allTime: 0, +}; + +export function MoodChart({ title, mini = false, windowOverride }: MoodChartProps) { const { isAuthenticated } = useAuth(); const { t } = useTranslations(); - const [rangePoints, setRangePoints] = useState(30); + const initialRangePoints = windowOverride + ? MINI_RANGE_POINTS[windowOverride] + : 30; + const [rangePoints, setRangePoints] = useState(initialRangePoints); const [showMA, setShowMA] = useState(false); const [showTrend, setShowTrend] = useState(false); const [showBands, setShowBands] = useState(false); @@ -408,14 +432,20 @@ export function MoodChart({ title }: MoodChartProps) { if (!isLoading && !data?.entries?.length) return null; return ( - - + +
- + {displayTitle} - {activeBucket !== "day" && ( + {activeBucket !== "day" && !mini && ( {t( activeBucket === "week" @@ -425,53 +455,64 @@ export function MoodChart({ title }: MoodChartProps) { )}
-
- {TIME_RANGES_KEYS.map((r) => ( - + ))} +
+ )} +
+ {!mini && ( +
+
+ + +
+
+ + +
+
+ + +
- -
-
- - -
-
- - -
-
- - -
-
+ )}
{/* v1.4.16 B1a — sibling SVG block for the gradient @@ -506,7 +547,7 @@ export function MoodChart({ title }: MoodChartProps) { height={280} /> ) : ( -
+