-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adding modals with info to ASCOR All countries page
- Loading branch information
1 parent
53f4a19
commit 8761f0d
Showing
4 changed files
with
77 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import PropTypes from 'prop-types'; | ||
import CustomModal from './Modal'; | ||
import { OverlayProvider } from '@react-aria/overlays'; | ||
import React, {useEffect, useState} from 'react'; | ||
|
||
const InfoModal = ({ title, text, element }) => { | ||
const [visible, setVisible] = useState(false); | ||
|
||
useEffect(() => { | ||
const eventListeners = []; | ||
document.querySelectorAll(element).forEach((input) => { | ||
const listener = input.addEventListener('click', handleOnRequestOpen); | ||
eventListeners.push([input, listener]); | ||
}); | ||
|
||
return () => { | ||
eventListeners.forEach(([input, listener]) => { | ||
input.removeEventListener('click', listener); | ||
}); | ||
}; | ||
}); | ||
|
||
const handleOnRequestOpen = () => { | ||
setVisible(true); | ||
}; | ||
|
||
const handleOnRequestClose = () => { | ||
setVisible(false); | ||
}; | ||
|
||
return ( | ||
<OverlayProvider> | ||
<CustomModal | ||
open={visible} | ||
onClose={handleOnRequestClose} | ||
title={title} | ||
> | ||
<div> | ||
<button | ||
type="button" | ||
className="close-btn" | ||
onClick={handleOnRequestClose} | ||
aria-label="Proceed with Management Quality (MQ) methodology preview" | ||
> | ||
<div className="icon__close" /> | ||
</button> | ||
<div className="modal-title">{title}</div> | ||
<div className="content" dangerouslySetInnerHTML={{__html: text}} /> | ||
</div> | ||
</CustomModal> | ||
</OverlayProvider> | ||
); | ||
}; | ||
|
||
InfoModal.propTypes = { | ||
title: PropTypes.string.isRequired, | ||
text: PropTypes.string.isRequired, | ||
element: PropTypes.string.isRequired | ||
}; | ||
|
||
export default InfoModal; |
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 |
---|---|---|
@@ -1 +1,7 @@ | ||
<%= react_component('charts/ascor-bubble/Chart', { results: @ascor_assessment_results }) %> | ||
<%= react_component('charts/ascor-bubble/Chart', { results: @ascor_assessment_results }) %> | ||
<%= react_component('InfoModal', { | ||
title: "ASCOR country assessment results", | ||
text: "<p>Countries are assessed across the ASCOR framework’s three pillars and thirteen topic areas.</p>" \ | ||
"<p>The area-level result is Yes if all indicators within the area are assessed as Yes, Partial if some of the indicators within the area are assessed as Yes, and No if all of the indicators within the area are assessed as No.</p>", | ||
element: "#bubble-chart-info" | ||
}) %> |
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