Skip to content

Commit

Permalink
Merge pull request #126 from axsmap/AM-331
Browse files Browse the repository at this point in the history
AM-331: Fix buggy scrolling on Mapathons info modal
  • Loading branch information
haseebk authored Jan 31, 2024
2 parents 6f79311 + 5ee60ef commit e1a7b28
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 38 deletions.
68 changes: 47 additions & 21 deletions src/components/Mapathons/InformationDialog.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,64 @@
import React from 'react'
import React, { useEffect } from 'react'
import PropTypes from 'prop-types'
import { intlShape } from 'react-intl'
import styled from 'styled-components'

import Icon from '../Icon'
import { colors, media } from '../../styles'

export default class Modal extends React.Component {
onClose = e => {
this.props.onClose && this.props.onClose(e)
const ModalWrapper = styled.div`
.modal {
background-color: rgba( 0, 0, 0, .35);
position: fixed;
width: 100%;
height: 100%;
z-index: 99999;
top: 0;
right: 0;
}
.modal-container {
background-color: white;
padding: 20px;
margin: 40px 20px;
border-radius: 15px;
height: 90%
overflow: auto;
}
`

render() {
if (!this.props.show) {
return null
}
return (
const Modal = ({ onClose, show, children }) => {
useEffect(
() => {
const handleBodyOverflow = () => {
document.body.style.overflow = show ? 'hidden' : 'auto'
}
handleBodyOverflow()
return () => {
document.body.style.overflow = 'auto'
}
},
[show]
)

if (!show) {
return null
}

return <ModalWrapper>
<div className="modal" id="modal">
<div className="modal-container">
<div className="toggle-button" onClick={this.onClose}>
<Icon
glyph="cross"
size={1}
backgroundColor={colors.white}
color={colors.black}
/>
<div onClick={onClose}>
<Icon glyph="cross" size={1} backgroundColor={colors.white} color={colors.black} />
</div>
<div className="content">{this.props.children}</div>
<div className="content">{children}</div>
</div>
</div>
)
}
</ModalWrapper>
}

Modal.propTypes = {
onClose: PropTypes.func.isRequired,
show: PropTypes.bool.isRequired
show: PropTypes.bool.isRequired,
}

export default Modal
17 changes: 0 additions & 17 deletions src/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -1773,21 +1773,4 @@ html {
}
}
}
.modal {
background-color: rgba( 0, 0, 0, .35);
position: fixed;
width: 100%;
height: 100%;
z-index: 99999;
top: 0;
}
.modal-container {
background-color: white;
padding: 20px;
margin: 40px 20px;
border-radius: 15px;
height: 90%
overflow: hidden;
}
`

0 comments on commit e1a7b28

Please sign in to comment.