-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DBC22-964: Updated advisories on map
- Loading branch information
Showing
10 changed files
with
199 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 0 additions & 59 deletions
59
src/frontend/src/Components/advisories/AdvisoriesAccordion.js
This file was deleted.
Oops, something went wrong.
36 changes: 0 additions & 36 deletions
36
src/frontend/src/Components/advisories/AdvisoriesAccordion.scss
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// React | ||
import React, { useCallback, useEffect, useRef, useState } from 'react'; | ||
|
||
// Redux | ||
import { useSelector, useDispatch } from 'react-redux' | ||
import { memoize } from 'proxy-memoize' | ||
import { updateAdvisories } from '../../slices/cmsSlice'; | ||
|
||
// Components and functions | ||
import { getAdvisories } from '../data/advisories.js'; | ||
import AdvisoriesList from './AdvisoriesList'; | ||
|
||
// Third party packages | ||
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome'; | ||
import { | ||
faFlag, | ||
faXmark | ||
} from '@fortawesome/free-solid-svg-icons'; | ||
import Button from 'react-bootstrap/Button'; | ||
|
||
// Styling | ||
import './AdvisoriesOnMap.scss'; | ||
|
||
export default function AdvisoriesOnMap() { | ||
// Redux | ||
const dispatch = useDispatch(); | ||
const { advisories } = useSelector(useCallback(memoize(state => ({ | ||
advisories: state.cms.advisories.list, | ||
})))); | ||
|
||
// Refs | ||
const isInitialMount = useRef(true); | ||
|
||
// Data loading | ||
const loadAdvisories = async () => { | ||
if (!advisories) { | ||
dispatch(updateAdvisories({ | ||
list: await getAdvisories(), | ||
timeStamp: new Date().getTime() | ||
})); | ||
} | ||
} | ||
|
||
useEffect(() => { | ||
if (isInitialMount.current) { // Only run on initial load | ||
loadAdvisories(); | ||
isInitialMount.current = false; | ||
} | ||
}); | ||
|
||
// States | ||
const [open, setOpen] = useState(false); | ||
|
||
// Rendering | ||
return ( | ||
(advisories && advisories.length > 0) ? ( | ||
<div className="advisories-on-map"> | ||
<Button | ||
className={'advisories-on-map__btn' + (open ? ' open' : '')} | ||
aria-label="open advisories list" | ||
onClick={() => { | ||
open ? setOpen(false) : setOpen(true) } | ||
}> | ||
<FontAwesomeIcon icon={faFlag} /> | ||
<span>Advisories in area</span> | ||
<span className="advisories-count">{advisories.length}</span> | ||
</Button> | ||
|
||
{ open && | ||
<div className="advisories-on-map__content"> | ||
<h4>Advisories</h4> | ||
<button | ||
className="close-advisories" | ||
aria-label="close advisories list" | ||
onClick={() => setOpen(false) | ||
}> | ||
<FontAwesomeIcon icon={faXmark} /> | ||
</button> | ||
<AdvisoriesList advisories={advisories} showDescription={true} showTimestamp={false} /> | ||
</div> | ||
} | ||
</div> | ||
) : null | ||
); | ||
} |
101 changes: 101 additions & 0 deletions
101
src/frontend/src/Components/advisories/AdvisoriesOnMap.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
@import "../../styles/variables.scss"; | ||
|
||
.advisories-on-map { | ||
position: relative; | ||
top: 1rem; | ||
left: 1rem; | ||
|
||
.btn.advisories-on-map__btn { | ||
background: #FAF9F8; | ||
width: fit-content; | ||
font-size: 0.875rem; | ||
font-weight: 700; | ||
color: #584215; | ||
padding: 4px 8px; | ||
border-radius: 5px; | ||
border: 1px solid #584215; | ||
|
||
&:active, &.active, &.open { | ||
color: white; | ||
background: #584215; | ||
|
||
.advisories-count { | ||
color: #584215; | ||
background: white; | ||
} | ||
} | ||
|
||
&:focus, &.focus { | ||
outline: $BC-Yellow; | ||
} | ||
|
||
svg { | ||
margin-right: 8px; | ||
} | ||
|
||
.advisories-count { | ||
margin: auto auto; | ||
margin-left: 12px; | ||
font-size: 0.625rem; | ||
color: #FAF9F8; | ||
background: #584215; | ||
padding: 2px 6px; | ||
border-radius: 4px; | ||
vertical-align: middle; | ||
} | ||
} | ||
|
||
&__content { | ||
margin-top: 6px; | ||
background: #FAF9F8; | ||
width: 100%; | ||
border-radius: 4px; | ||
box-shadow: 0px 1.937px 4.358px 0px rgba(0, 0, 0, 0.13), 0px 0.363px 1.089px 0px rgba(0, 0, 0, 0.10); | ||
padding: 1rem; | ||
position: fixed; | ||
bottom: 0; | ||
left: 0; | ||
z-index: 20; | ||
|
||
@media (min-width: 575px) { | ||
width: 360px; | ||
position: relative; | ||
} | ||
|
||
h4 { | ||
color: #584215; | ||
} | ||
|
||
.close-advisories { | ||
position: absolute; | ||
top: 1rem; | ||
right: 1rem; | ||
padding: 0; | ||
min-width: 0; | ||
line-height: 1.25rem; | ||
height: auto; | ||
background: none; | ||
border: none; | ||
font-size: 1.4rem; | ||
} | ||
.advisories-list { | ||
margin-top: 12px; | ||
|
||
.advisory-li { | ||
padding: 20px 0 16px; | ||
font-size: 0.875rem; | ||
margin-bottom: 0; | ||
width: 100%; | ||
|
||
& + .advisory-li { | ||
border-top: 1px solid $Divider; | ||
} | ||
|
||
.advisory-li-title { | ||
color: #584215; | ||
font-size: 0.875rem; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters