Skip to content

Commit

Permalink
fix(modal): fix height constraint of modal
Browse files Browse the repository at this point in the history
  • Loading branch information
unix committed Jun 22, 2020
1 parent 89c4bf1 commit 36f6580
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions components/modal/modal-actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const ModalActions: React.FC<React.PropsWithChildren<{}>> = ({ children, ...prop
div {
height: 3.625rem;
flex-shrink: 0;
}
`}</style>
</>
Expand Down
5 changes: 3 additions & 2 deletions components/modal/modal-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ const ModalContent: React.FC<ModalContentProps> = ({ className, children, ...pro
</div>
<style jsx>{`
.content {
margin: 0;
padding: ${theme.layout.gap} 0 ${theme.layout.gapHalf} 0;
margin: 0 -${theme.layout.gap};
padding: ${theme.layout.gap} ${theme.layout.gap} ${theme.layout.gapHalf};
overflow-y: auto;
}
.content > :global(*:first-child) {
Expand Down
1 change: 1 addition & 0 deletions components/modal/modal-title.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const ModalTitle: React.FC<ModalTitleProps> = ({ className, children, ...props }
text-align: center;
margin: 0;
display: inline-flex;
flex-shrink: 0;
justify-content: center;
align-items: center;
word-break: break-word;
Expand Down
1 change: 1 addition & 0 deletions components/modal/modal-wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const ModalWrapper: React.FC<React.PropsWithChildren<ModalWrapperProps>> = ({
<style jsx>{`
.wrapper {
max-width: 85vw;
max-height: 75vh;
width: ${width};
overflow: hidden;
display: flex;
Expand Down
2 changes: 1 addition & 1 deletion components/modal/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const Modal: React.FC<React.PropsWithChildren<ModalProps>> = ({
if (!portal) return null
return createPortal(
<ModalContext.Provider value={modalConfig}>
<Backdrop onClick={closeFromBackdrop} visible={visible} offsetY={25}>
<Backdrop onClick={closeFromBackdrop} visible={visible}>
<ModalWrapper visible={visible} className={wrapClassName} width={wrapperWidth}>
{withoutActionsChildren}
{hasActions && <ModalActions>{ActionsChildren}</ModalActions>}
Expand Down
8 changes: 4 additions & 4 deletions components/shared/backdrop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import useCurrentState from '../utils/use-current-state'
interface Props {
onClick?: (event: MouseEvent<HTMLElement>) => void
visible?: boolean
offsetY?: number
}

const defaultProps = {
Expand All @@ -19,7 +18,7 @@ const defaultProps = {
export type BackdropProps = Props & typeof defaultProps

const Backdrop: React.FC<React.PropsWithChildren<BackdropProps>> = React.memo(
({ children, onClick, visible, offsetY }) => {
({ children, onClick, visible }) => {
const theme = useTheme()
const [, setIsContentMouseDown, IsContentMouseDownRef] = useCurrentState(false)
const clickHandler = (event: MouseEvent<HTMLElement>) => {
Expand Down Expand Up @@ -57,7 +56,7 @@ const Backdrop: React.FC<React.PropsWithChildren<BackdropProps>> = React.memo(
align-content: center;
align-items: center;
flex-direction: column;
justify-content: center;
justify-content: space-around;
height: 100vh;
width: 100vw;
overflow: auto;
Expand All @@ -74,8 +73,9 @@ const Backdrop: React.FC<React.PropsWithChildren<BackdropProps>> = React.memo(
}
.offset {
height: ${offsetY}vh;
height: 0;
opacity: 0;
display: flex;
background-color: transparent;
}
Expand Down

0 comments on commit 36f6580

Please sign in to comment.