Skip to content

Commit 7326258

Browse files
CopilotAlexLipp
andcommitted
Refine downstream impact popup: tabs, coordinate subtitle, narrower width, renamed fields
Co-authored-by: AlexLipp <10188895+AlexLipp@users.noreply.github.com> Agent-Logs-Url: https://github.com/JonnyDawe/UK-Sewage-Map/sessions/73347395-07e0-45ae-9d74-f4a233b4a978
1 parent c5fc7a3 commit 7326258

3 files changed

Lines changed: 84 additions & 37 deletions

File tree

src/components/DownstreamImpactPopup/DownstreamImpactPopupBody.tsx

Lines changed: 52 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import styled from '@emotion/styled';
2-
import { Box, Heading, ScrollArea, Text } from '@radix-ui/themes';
2+
import { Box, ScrollArea, Text } from '@radix-ui/themes';
33
import Wave from 'react-wavify';
44

55
import { usePrefersReducedMotion } from '../../lib/hooks/usePrefersReducedMotion';
6+
import Tabs from '../common/Tabs/Tabs';
67
import { Em } from '../common/Text';
78
import { DownstreamImpactProperties } from './types';
89

910
const BodyWrapper = styled.div`
1011
position: relative;
1112
overflow: hidden;
13+
max-width: 280px;
1214
`;
1315

1416
const BackgroundWave = styled(Wave)`
@@ -51,6 +53,7 @@ const StatRow = styled.div`
5153
justify-content: space-between;
5254
align-items: center;
5355
padding: 2px 0;
56+
gap: 8px;
5457
`;
5558

5659
const CsoList = styled.ul`
@@ -85,38 +88,54 @@ export function DownstreamImpactPopupBody({
8588
}}
8689
/>
8790
<ContentWrapper>
88-
<DataCardWrapper>
89-
<StatRow>
90-
<Text size="2">
91-
<Em>Upstream CSOs:</Em>
92-
</Text>
93-
<Text size="3" weight="bold">
94-
{number_upstream_CSOs}
95-
</Text>
96-
</StatRow>
97-
<StatRow>
98-
<Text size="2">
99-
<Em>CSOs per km²:</Em>
100-
</Text>
101-
<Text size="3" weight="bold">
102-
{parseFloat(number_CSOs_per_km2.toPrecision(3)).toString()}
103-
</Text>
104-
</StatRow>
105-
</DataCardWrapper>
106-
{CSOs.length > 0 && (
107-
<DataCardWrapper>
108-
<Heading size="2" mb="1">
109-
Upstream CSO sources
110-
</Heading>
111-
<ScrollArea type="auto" scrollbars="vertical" style={{ maxHeight: 160 }}>
112-
<CsoList>
113-
{CSOs.map((name, index) => (
114-
<CsoListItem key={`${index}-${name}`}>{name}</CsoListItem>
115-
))}
116-
</CsoList>
117-
</ScrollArea>
118-
</DataCardWrapper>
119-
)}
91+
<Tabs.Root defaultValue="summary" aria-label="Choose which information to see:">
92+
<Tabs.List>
93+
<Tabs.Trigger value="summary">Summary</Tabs.Trigger>
94+
<Tabs.Trigger value="sources">Upstream Sources</Tabs.Trigger>
95+
</Tabs.List>
96+
<Box pt={'3'}>
97+
<Tabs.Content value="summary">
98+
<DataCardWrapper>
99+
<StatRow>
100+
<Text size="2">
101+
<Em>Number of upstream spills:</Em>
102+
</Text>
103+
<Text size="3" weight="bold">
104+
{number_upstream_CSOs}
105+
</Text>
106+
</StatRow>
107+
<StatRow>
108+
<Text size="2">
109+
<Em>Number of upstream spills per km²:</Em>
110+
</Text>
111+
<Text size="3" weight="bold">
112+
{parseFloat(number_CSOs_per_km2.toPrecision(3)).toString()}
113+
</Text>
114+
</StatRow>
115+
<Text size="1" color="gray" mt="2" as="p">
116+
Values include all spills that have occurred in the previous 48 hours
117+
</Text>
118+
</DataCardWrapper>
119+
</Tabs.Content>
120+
<Tabs.Content value="sources">
121+
<DataCardWrapper>
122+
<ScrollArea type="auto" scrollbars="vertical" style={{ maxHeight: 160 }}>
123+
{CSOs.length > 0 ? (
124+
<CsoList>
125+
{CSOs.map((name, index) => (
126+
<CsoListItem key={`${index}-${name}`}>{name}</CsoListItem>
127+
))}
128+
</CsoList>
129+
) : (
130+
<Text size="2" color="gray">
131+
No upstream sources recorded.
132+
</Text>
133+
)}
134+
</ScrollArea>
135+
</DataCardWrapper>
136+
</Tabs.Content>
137+
</Box>
138+
</Tabs.Root>
120139
</ContentWrapper>
121140
</BodyWrapper>
122141
);

src/components/DownstreamImpactPopup/DownstreamImpactPopupHeader.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,28 @@ import { Em } from '../common/Text';
44

55
type DownstreamImpactPopupHeaderProps = {
66
company: string;
7+
longitude: number;
8+
latitude: number;
79
};
810

9-
export function DownstreamImpactPopupHeader({ company }: DownstreamImpactPopupHeaderProps) {
11+
export function DownstreamImpactPopupHeader({
12+
company,
13+
longitude,
14+
latitude,
15+
}: DownstreamImpactPopupHeaderProps) {
16+
const lon = longitude.toFixed(4);
17+
const lat = latitude.toFixed(4);
18+
1019
return (
1120
<Flex gap="2" align="center">
1221
<div>
1322
<Heading size={'4'} as="h3">
1423
{company} Downstream Impact
1524
</Heading>
1625
<Text size={'2'}>
17-
<Em>Upstream CSO summary</Em>
26+
<Em>
27+
Downstream Impact - [{lon}, {lat}]
28+
</Em>
1829
</Text>
1930
</div>
2031
</Flex>

src/components/DownstreamImpactPopup/popupfactory.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import '@radix-ui/themes/styles.css';
22

3+
import Point from '@arcgis/core/geometry/Point';
34
import PopupTemplate from '@arcgis/core/PopupTemplate';
45
import React from 'react';
56
import { flushSync } from 'react-dom';
@@ -33,6 +34,17 @@ function getPropertiesFromGraphic(graphic: __esri.Graphic): DownstreamImpactProp
3334
};
3435
}
3536

37+
function getCoordinatesFromGraphic(graphic: __esri.Graphic): {
38+
longitude: number;
39+
latitude: number;
40+
} {
41+
const point = graphic.geometry as Point | null;
42+
return {
43+
longitude: point?.longitude ?? 0,
44+
latitude: point?.latitude ?? 0,
45+
};
46+
}
47+
3648
function createHTMLContentFn() {
3749
return function ({ graphic }: { graphic: __esri.Graphic }) {
3850
const container = document.createElement('div');
@@ -64,9 +76,10 @@ function createHTMLContentFn() {
6476
}
6577

6678
function createTitleFn(companyName: string) {
67-
return function () {
79+
return function ({ graphic }: { graphic: __esri.Graphic }) {
6880
const container = document.createElement('div');
6981
const root = createRoot(container);
82+
const { longitude, latitude } = getCoordinatesFromGraphic(graphic);
7083

7184
flushSync(() => {
7285
root.render(
@@ -80,7 +93,11 @@ function createTitleFn(companyName: string) {
8093
isChild={true}
8194
>
8295
<AppTheme>
83-
<DownstreamImpactPopupHeader company={companyName} />
96+
<DownstreamImpactPopupHeader
97+
company={companyName}
98+
longitude={longitude}
99+
latitude={latitude}
100+
/>
84101
</AppTheme>
85102
</AppThemeProvider>
86103
</React.StrictMode>,

0 commit comments

Comments
 (0)