Skip to content

Commit 61e4e57

Browse files
committed
feat: change layout in impact analysis page
1 parent 05242c5 commit 61e4e57

6 files changed

Lines changed: 102 additions & 67 deletions

File tree

src/components/react/ImpactAnalysis/AnalysisConditionsFilter.tsx

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,11 @@ export const AnalysisConditionsFilter: React.FC<
2626
<AnalysisSectionDivider
2727
step={1}
2828
title="Analysis Conditions"
29-
subtitle="Select the analysis conditions: KPI group"
29+
// subtitle="Select the analysis conditions: KPI group"
3030
description="The KPIs have been grouped by scope of interest"
3131
/>
3232

3333
<div className="mt-6 flex flex-col items-center gap-2 lg:gap-4 content-center">
34-
<Tooltip
35-
content="The impact levels reported by this assessment tool are algorithmic estimates derived from implemented measures and observed KPI changes. They serve as indicative values and may not exactly reflect real-world outcomes"
36-
placement="top"
37-
tooltipClassName="w-full"
38-
>
39-
<h4 className="text-center">
40-
Available conditions for analysis
41-
<QuestionMarkCircleIcon className="inline-block w-6 h-6 ml-1 text-warning" />
42-
</h4>
43-
</Tooltip>
44-
4534
<CardFilter
4635
groups={kpiGroups.map((group) => ({
4736
id: group.id,

src/components/react/ImpactAnalysis/ImpactAnalysisDashboard.tsx

Lines changed: 68 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@ import React, { useState, useMemo } from "react";
22
import { AnalysisConditionsFilter } from "./AnalysisConditionsFilter";
33
import { MeasuresImpact } from "./MeasuresImpact";
44
import { KpiVariations } from ".";
5-
import { PageNavigation } from "../ui/PageNavigation";
5+
import { Tabs } from "../ui";
66
import type {
77
IKpiGroup,
88
IGroupAnalysisResult,
99
IKpiVariationData,
1010
IJobRunOutputData,
1111
} from "../../../types";
12+
import { PageNavigation } from "../ui/PageNavigation";
13+
14+
const MEASURES_TAB_ID = "measures-impact";
15+
const KPI_VARIATIONS_TAB_ID = "kpi-variations";
1216

1317
interface ImpactAnalysisDashboardProps {
1418
kpiGroups: IKpiGroup[];
@@ -20,13 +24,11 @@ export const ImpactAnalysisDashboard: React.FC<
2024
ImpactAnalysisDashboardProps
2125
> = ({ kpiGroups, jobRunOutput, kpiVariationsData }) => {
2226
const [selectedGroupId, setSelectedGroupId] = useState<string | number>();
27+
const [activeTabId, setActiveTabId] = useState<string>(MEASURES_TAB_ID);
2328

2429
const handleGroupSelect = (groupId: string | number) => {
2530
setSelectedGroupId(groupId);
26-
const element = document.getElementById("kpis-in-group");
27-
if (element) {
28-
element.scrollIntoView({ behavior: "smooth" });
29-
}
31+
setActiveTabId(MEASURES_TAB_ID);
3032
};
3133

3234
const selectedGroup =
@@ -55,38 +57,75 @@ export const ImpactAnalysisDashboard: React.FC<
5557
return kpiVariationsData[String(selectedGroupId)] || null;
5658
}, [selectedGroupId, kpiVariationsData]);
5759

58-
// Navigation sections configuration
5960
const navigationSections = [
60-
{ id: "analysis-conditions-filter", label: "Conditions" },
61-
{ id: "measures-impact", label: "Measures" },
62-
{ id: "kpi-variations", label: "KPI Variations" },
61+
{ id: "how-to", label: "Information about the tool" },
62+
{ id: "impact-results", label: "Impact analysis results" },
6363
];
6464

65-
return (
66-
<div className="flex flex-col gap-6">
67-
<section id="analysis-conditions-filter"></section>
68-
<AnalysisConditionsFilter
69-
kpiGroups={kpiGroups}
70-
selectedGroupId={selectedGroupId}
71-
onGroupSelect={handleGroupSelect}
72-
/>
65+
const contentTabs = useMemo(
66+
() => [
67+
{
68+
id: MEASURES_TAB_ID,
69+
label: "Measures Impact",
70+
content: (
71+
<MeasuresImpact
72+
selectedGroup={selectedGroup}
73+
analysisResult={analysisResult}
74+
kpiCount={selectedVariationsData?.allKpiVariations.length || 0}
75+
/>
76+
),
77+
},
78+
{
79+
id: KPI_VARIATIONS_TAB_ID,
80+
label: "KPI Variations",
81+
content: (
82+
<KpiVariations
83+
selectedGroup={selectedGroup}
84+
variationsData={selectedVariationsData}
85+
/>
86+
),
87+
},
88+
],
89+
[selectedGroup, analysisResult, selectedVariationsData],
90+
);
7391

74-
<section id="measures-impact"></section>
75-
<MeasuresImpact
76-
selectedGroup={selectedGroup}
77-
analysisResult={analysisResult}
78-
kpiCount={selectedVariationsData?.allKpiVariations.length || 0}
79-
/>
92+
const filterContent = (
93+
<AnalysisConditionsFilter
94+
kpiGroups={kpiGroups}
95+
selectedGroupId={selectedGroupId}
96+
onGroupSelect={handleGroupSelect}
97+
/>
98+
);
8099

81-
<section id="kpi-variations"></section>
82-
<KpiVariations
83-
selectedGroup={selectedGroup}
84-
variationsData={selectedVariationsData}
85-
/>
100+
return (
101+
<div className="space-y-6">
102+
{/* Desktop: two-column grid — sticky sidebar + tabbed content */}
103+
<div className="grid grid-cols-1 gap-6 lg:grid-cols-[350px_minmax(0,1fr)]">
104+
<aside className="sticky lg:top-6 lg:self-start lg:max-h-[calc(100vh-3rem)] lg:overflow-y-auto pr-2">
105+
{filterContent}
106+
</aside>
107+
108+
<section className="min-w-0">
109+
<div className="rounded-lg border border-gray-200 bg-white p-4 shadow-sm">
110+
{selectedVariationsData ? (
111+
<Tabs
112+
key={activeTabId}
113+
tabs={contentTabs}
114+
defaultTabId={activeTabId}
115+
onChange={setActiveTabId}
116+
/>
117+
) : (
118+
<p className="text-gray-500">
119+
Please select analysis conditions to view the results.
120+
</p>
121+
)}
122+
</div>
123+
</section>
124+
</div>
86125

87126
<PageNavigation
88127
sections={navigationSections}
89-
disclaimer="Analysis results are based on the selected KPI group and living lab conditions"
128+
disclaimer="The impact levels reported by this assessment tool are algorithmic estimates derived from implemented measures and observed KPI changes. They serve as indicative values and may not exactly reflect real-world outcomes."
90129
/>
91130
</div>
92131
);

src/components/react/ImpactAnalysis/KpiVariations.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ export const KpiVariations: React.FC<KpiVariationsProps> = ({
2222
<AnalysisSectionDivider
2323
step={3}
2424
title="KPI Variations percentage"
25-
subtitle={
26-
"Observe and compare " +
27-
selectedGroup?.name +
28-
" KPIs variations among living labs"
29-
}
25+
// subtitle={
26+
// "Observe and compare " +
27+
// selectedGroup?.name +
28+
// " KPIs variations among living labs"
29+
// }
3030
description={
3131
"Only Living Labs with enough data collected are included, for KPIs in the scope of " +
3232
selectedGroup?.name +

src/components/react/ImpactAnalysis/MeasuresImpact.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const MeasuresImpact: React.FC<MeasuresImpactProps> = ({
2727
<AnalysisSectionDivider
2828
step={2}
2929
title="Measures Impact"
30-
subtitle="Analyse how implemented measures contributed to the KPIs variations"
30+
// subtitle="Analyse how implemented measures contributed to the KPIs variations"
3131
description={
3232
"Estimation of the level of contribution for each measure to KPIs in the scope " +
3333
selectedGroup?.name +

src/components/react/ui/CardFilter.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { IKpiDefinition } from "../../../types";
33
import { KpiCard } from "../KpiCards";
44
import { getUniqueParentKpis } from "../../../lib/helpers";
55
import { InfoAlert } from "./InfoAlert";
6+
import { InfoCard } from "./InfoCard";
67

78
interface CardFilterProps {
89
groups: { id: string | number; name: string; kpis: IKpiDefinition[] }[];
@@ -39,20 +40,24 @@ export const CardFilter: React.FC<CardFilterProps> = ({
3940
<section id="kpis-in-group"></section>
4041
{selectedGroup && uniqueKpis.length > 0 && (
4142
<div className="mt-10">
42-
<InfoAlert
43-
variant="neutral"
43+
<InfoCard
4444
title={"KPIs considered for group " + selectedGroup.name}
45+
textAlign="left"
46+
variant="light"
47+
showIcon={false}
4548
>
46-
<i>
47-
We have collected data from the living labs from the following
48-
KPIs in this group:{" "}
49-
</i>
50-
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
49+
<div className="grid grid-cols-1 mt-2">
5150
{uniqueKpis.map((kpi) => (
5251
<KpiCard kpi={kpi} key={kpi.id} />
5352
))}
53+
<i>
54+
Our platform has collected living lab's data from these KPIs,
55+
which are in the scope of the selected group. The impact
56+
analysis results are based on the variations observed in these
57+
KPIs and the measures implemented in the living labs.
58+
</i>
5459
</div>
55-
</InfoAlert>
60+
</InfoCard>
5661
</div>
5762
)}
5863
</div>

src/pages/tools/impact_analysis.astro

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ const methodologyContent = `
183183
]}
184184
backHref="/"
185185
>
186-
<div class="mx-auto px-1 py-8">
186+
<div class="mx-auto px-1 py-8" id="how-to">
187187
<div class="mx-auto px-1 py-8 gap-y-4 flex flex-col">
188188
<!-- Info Section -->
189189
<InfoSection
@@ -192,11 +192,6 @@ const methodologyContent = `
192192
title="Impact Analysis Dashboard"
193193
description="Quantifying the effectiveness of mobility measures across Living Labs. This tool uses regression analysis to correlate the implementation of push/pull measures with changes in Key Performance Indicators (KPIs)."
194194
/>
195-
{
196-
formattedDate && (
197-
<p class="text-sm text-gray-500">Updated on {formattedDate}</p>
198-
)
199-
}
200195

201196
<!-- Features Grid -->
202197
<FeaturesGrid features={impactAnalysisFeatures} />
@@ -228,12 +223,19 @@ const methodologyContent = `
228223
</p>
229224
</div>
230225
) : (
231-
<ImpactAnalysisDashboard
232-
kpiGroups={kpiGroups}
233-
jobRunOutput={jobRunOutput}
234-
kpiVariationsData={kpiVariationsData}
235-
client:load
236-
/>
226+
<section id="impact-results">
227+
{formattedDate && (
228+
<p class="text-sm text-gray-500">
229+
Results where updated on {formattedDate}
230+
</p>
231+
)}
232+
<ImpactAnalysisDashboard
233+
kpiGroups={kpiGroups}
234+
jobRunOutput={jobRunOutput}
235+
kpiVariationsData={kpiVariationsData}
236+
client:load
237+
/>
238+
</section>
237239
)
238240
}
239241
</div>

0 commit comments

Comments
 (0)