Skip to content

Commit 306d133

Browse files
committed
Add and style detail flyout
1 parent fc46dea commit 306d133

7 files changed

Lines changed: 85 additions & 11 deletions

File tree

demo/app/src/components/Map/DynamicMap.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ import Leaflet from 'leaflet';
33
import * as ReactLeaflet from 'react-leaflet';
44
import 'leaflet/dist/leaflet.css';
55
import Footprint from './Footprint';
6+
import { useAppContext } from 'src/context/appContext';
67

78
import styles from './Map.module.scss';
89

910
const { MapContainer } = ReactLeaflet;
1011

1112
const Map = ({ children, className, width, height, ...rest }) => {
13+
const { selectedOpportunity } = useAppContext();
1214
let mapClassName = styles.map;
1315

1416
if ( className ) {
@@ -27,7 +29,7 @@ const Map = ({ children, className, width, height, ...rest }) => {
2729
}, []);
2830

2931
return (
30-
<MapContainer className={mapClassName} {...rest}>
32+
<MapContainer className={`${mapClassName} ${selectedOpportunity && styles.mapContainerDetailView}`} {...rest}>
3133
<Footprint />
3234
{children(ReactLeaflet, Leaflet)}
3335
</MapContainer>

demo/app/src/components/Map/Map.module.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
.map {
2+
position: absolute;
23
width: 100%;
34
height: 100%;
45
}
56

7+
.mapContainerDetailView {
8+
left: 700px;
9+
width: calc(100% - 700px) !important;
10+
}
11+
612
.footprintCircle {
713
display: table-cell;
814
text-align: center;

demo/app/src/components/Sidebar/Opportunity.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ export default function Opportunity({
66
provider,
77
start,
88
end,
9+
selected,
910
onMouseEnter,
1011
onMouseLeave,
1112
onClick
1213
}) {
1314
return (
1415
<div
15-
className={styles.opportunityPreview}
16+
className={`${styles.opportunityPreview} ${selected && styles.selected}`}
1617
onClick={onClick}
1718
onMouseEnter={onMouseEnter}
1819
onMouseLeave={onMouseLeave}
Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,48 @@
11
import styles from './Sidebar.module.scss'
22
import { useAppContext } from 'src/context/appContext';
33
import Button from '@components/Button';
4+
import {
5+
ArrowRightLine
6+
} from '@vectopus/atlas-icons-react';
47

58
export default function OpportunityDetail() {
69
const { selectedOpportunity, setSelectedOpportunity, setHoveredOpportunity } = useAppContext();
7-
810
return (
911
<div className={styles.opportunityDetail}>
1012
<div className={styles.topBar}>
11-
<h3 className={styles.heading}>Detail</h3>
13+
<h3 className={styles.heading}>Tasking Request Details</h3>
1214
<Button
15+
className={`${styles.closeButton} ${styles.closeButtonDetail}`}
1316
onClick={() => {
1417
setSelectedOpportunity(null);
1518
setHoveredOpportunity(null);
1619
}}
1720
>
18-
x
21+
<ArrowRightLine size={12} />
1922
</Button>
2023
</div>
21-
<div>{selectedOpportunity.id}</div>
24+
<ul className={styles.detailList}>
25+
<li>
26+
<h3>{'ID'}</h3>
27+
<p>{selectedOpportunity.id}</p>
28+
</li>
29+
{
30+
Object.keys(selectedOpportunity.properties).map(key => {
31+
return (
32+
selectedOpportunity.properties[key] &&
33+
<li>
34+
<h3>{key}</h3>
35+
<p>{key === 'datetime' ?
36+
selectedOpportunity.properties[key].split('/').map(utc => {
37+
return new Date(utc).toLocaleString()
38+
}).join(' - ') :
39+
selectedOpportunity.properties[key]}
40+
</p>
41+
</li>
42+
)
43+
})
44+
}
45+
</ul>
2246
</div>
2347
);
2448
}

demo/app/src/components/Sidebar/OpportunityList.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ function mouseOutStyleChange(e) {
2525
provider={provider}
2626
start={start}
2727
end={end}
28+
selected={selectedOpportunity===opp}
2829
onMouseEnter={(e) => {
2930
if(!selectedOpportunity){
3031
mouseInStyleChange(e);
@@ -35,7 +36,10 @@ function mouseOutStyleChange(e) {
3536
mouseOutStyleChange(e);
3637
setHoveredOpportunity(null)}}
3738
}
38-
onClick={(e) => setSelectedOpportunity(opportunities[provider][index])}
39+
onClick={() => {
40+
(selectedOpportunity===opp) ? setSelectedOpportunity(null) :
41+
setSelectedOpportunity(opportunities[provider][index]);
42+
}}
3943
/>
4044
})
4145
})

demo/app/src/components/Sidebar/Sidebar.module.scss

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,46 @@
11
@import "@styles/settings/_settings";
22

3-
.sidebar {
3+
.sidebar,
4+
.opportunityDetail {
45
position: absolute;
56
top: 0;
67
left: 0;
78
width: 350px;
89
height: 100%;
9-
z-index: 1001;
10+
z-index: 1000;
1011
background-color: white;
1112
}
1213

14+
.opportunityDetail {
15+
left: 350px;
16+
padding: 25px;
17+
border: 3px solid #1C5F78;
18+
19+
.detailList {
20+
list-style: none;
21+
position: relative;
22+
padding: 0px;
23+
margin: 0px;
24+
text-align: left;
25+
}
26+
27+
.detailList > li {
28+
list-style: none;
29+
display: inline-block;
30+
margin-top: 20px;
31+
32+
h3, p {
33+
margin: 2px;
34+
}
35+
}
36+
}
37+
38+
.closeButtonDetail {
39+
position: absolute;
40+
top: 5px;
41+
right: 5px;
42+
}
43+
1344
.loader {
1445
position: absolute;
1546
top: 0;
@@ -118,12 +149,18 @@
118149
height: 20%;
119150
width: 100%;
120151
padding: 10px;
121-
margin-bottom: 10px;
122152
border-top: 1px solid grey;
123153
border-bottom: 1px solid grey;
124154
position: relative;
125155
}
126156

157+
.selected {
158+
border: 3px solid #1C5F78;
159+
border-right: none;
160+
box-shadow: 5px 0 0 0 white;
161+
z-index: 1001;
162+
}
163+
127164
.opportunityPreview > h1 {
128165
font-size: medium;
129166
}

demo/app/src/pages/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const DEFAULT_CENTER = [38.907132, -77.036546];
1414
const DEFAULT_ZOOM = 3;
1515

1616
export default function Home() {
17-
const { isLoadingOpps, errorOpps, opportunities } = useAppContext();
17+
const { isLoadingOpps, errorOpps, opportunities, } = useAppContext();
1818
return (
1919
<Layout>
2020
<Head>

0 commit comments

Comments
 (0)