New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@potok/modal

Package Overview
Dependencies
Maintainers
2
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@potok/modal - npm Package Compare versions

Comparing version 0.6.0 to 0.7.0

99

components/Modal.jsx
// @flow
import React, { type Node } from 'react';
import React, { Component, type Node } from 'react';
import {

@@ -8,3 +8,2 @@ Gateway,

import Modal2 from 'react-modal2';
import Scrollbars from 'react-custom-scrollbars';

@@ -29,3 +28,3 @@ import CloseIcon from '@potok/icons/glyph/clear/close-1';

const ModalGateway = ({ children }) => {
const ModalGateway = ({ children }: any) => {
return <Gateway into={MODAL_GATEWAY_NAME}>{children}</Gateway>;

@@ -42,37 +41,67 @@ };

const Modal = ({
children,
title,
closeOnEsc,
closeOnBackdropClick,
onClose,
}: Props) => (
<ModalGateway>
<ModalWrapper>
<Modal2
closeOnEsc={closeOnEsc}
closeOnBackdropClick={closeOnBackdropClick}
onClose={onClose}
backdropClassName={backdropClass}
modalClassName={modalClass}
>
<Scrollbars autoHeight autoHeightMax={'90vh'}>
<Header>{title !== '' && <Title>{title}</Title>}</Header>
<Close onClick={onClose}>
<CloseIcon primaryColor={colors.N500} />
</Close>
<div>{children}</div>
</Scrollbars>
</Modal2>
</ModalWrapper>
</ModalGateway>
);
function getScrollbarWidth() {
return window.innerWidth - document.documentElement.clientWidth;
}
Modal.defaultProps = {
title: '',
closeOnEsc: true,
closeOnBackdropClick: true,
};
class Modal extends Component<Props> {
bodyOverflow: string;
bodyMarginLeft: string;
static defaultProps = {
title: '',
closeOnEsc: true,
closeOnBackdropClick: true,
};
componentDidMount() {
// fix body jump
this.bodyOverflow = document.body.style.overflow;
this.bodyMarginLeft = document.body.style['margin-left'];
document.body.style['margin-left'] = `-${getScrollbarWidth()}px`;
document.body.style.overflow = 'hidden';
setTimeout(() => {
const modal = document.querySelector(`.${backdropClass}`);
if (modal) {
modal.scrollTo(0, 0);
}
}, 0);
}
componentWillUnmount() {
document.body.style.overflow = this.bodyOverflow;
document.body.style['margin-left'] = this.bodyMarginLeft;
}
render() {
const {
children,
title,
closeOnEsc,
closeOnBackdropClick,
onClose,
} = this.props;
return (
<ModalGateway>
<ModalWrapper>
<Modal2
closeOnEsc={closeOnEsc}
closeOnBackdropClick={closeOnBackdropClick}
onClose={onClose}
backdropClassName={backdropClass}
modalClassName={modalClass}
>
<Header>{title !== '' && <Title>{title}</Title>}</Header>
<Close onClick={onClose}>
<CloseIcon primaryColor={colors.N500} />
</Close>
<div>{children}</div>
</Modal2>
</ModalWrapper>
</ModalGateway>
);
}
}
export default Modal;
export { ModalGateway, ModalGatewayDest, ModalGatewayProvider };

@@ -33,2 +33,4 @@ import styled, { css } from 'styled-components';

background: rgba(104, 104, 104, 0.5);
overflow-y: scroll;
padding: 20px;
}

@@ -38,3 +40,3 @@

position: relative;
padding: 25px 20px 20px;
padding: 30px;
background: ${colors.N0};

@@ -44,2 +46,3 @@ color: ${colors.N600};

outline: none;
margin: auto;
${switchProp('theme.device', {

@@ -46,0 +49,0 @@ [themeDevices.desktop]: css`

{
"name": "@potok/modal",
"version": "0.6.0",
"version": "0.7.0",
"description": "Potok.io UI Modal component",

@@ -14,3 +14,2 @@ "main": "./components/Modal.jsx",

"dependencies": {
"react-custom-scrollbars": "^4.2.1",
"react-gateway": "^3.0.0",

@@ -17,0 +16,0 @@ "react-modal2": "^5.0.0"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc