Skip to content

Commit

Permalink
feat: create popup base layout for forms
Browse files Browse the repository at this point in the history
Description:
Create popup basic layout for forms
VAN-1840
  • Loading branch information
ahtesham-quraish committed Mar 26, 2024
1 parent 203d56d commit 95040a4
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 1 deletion.
4 changes: 3 additions & 1 deletion example/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import { AppProvider } from '@edx/frontend-platform/react';
import { initialize, subscribe, APP_READY } from '@edx/frontend-platform';

import './index.scss';
import BaseContainer from '../src/base-container'

subscribe(APP_READY, () => {
ReactDOM.render(
<AppProvider>
<div>Load the forms here</div>
<BaseContainer open isPrivacyPolicy onClose={() => {}}>
</BaseContainer>
</AppProvider>,
document.getElementById('root'),
);
Expand Down
13 changes: 13 additions & 0 deletions src/base-container/PrivacyPolicyFooter.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
import { useIntl } from '@edx/frontend-platform/i18n';
import messages from './messages';

const PrivacyPolicy = () => {
const { formatMessage } = useIntl();
return (
<p className="bg-dark-500 p-4 text-light-100 privacy-policy-content">
{formatMessage(messages.privacyPolicyLabel)}
</p>
);
};
export default PrivacyPolicy;
46 changes: 46 additions & 0 deletions src/base-container/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React from 'react';

import { ModalDialog } from '@openedx/paragon';
import PropTypes from 'prop-types';
import PrivacyPolicy from './PrivacyPolicyFooter';
import LargeLayout from './layout/LargeLayout';
import './index.scss';

const BaseContainer = ({
children, open, onClose, isPrivacyPolicy,
}) => (
<ModalDialog
isOpen={open}
onClose={onClose}
size="fullscreen"
variant="default"
hasCloseButton
>
<ModalDialog.Body className="modal-body-container overflow-hidden">
<div className="modal-body-content-layout">
<div className="w-50 d-flex">
{children}
</div>
<LargeLayout>
<div className="w-100 h-100 bg-dark-500" />
</LargeLayout>
</div>
</ModalDialog.Body>
<ModalDialog.Footer className="modal-footer-content">
{isPrivacyPolicy && (<PrivacyPolicy />)}
</ModalDialog.Footer>
</ModalDialog>
);

BaseContainer.defaultProps = {
isPrivacyPolicy: false,
};

BaseContainer.propTypes = {
children: PropTypes.node.isRequired,
open: PropTypes.bool.isRequired,
onClose: PropTypes.func.isRequired,
isPrivacyPolicy: PropTypes.bool,
};

export default BaseContainer;
22 changes: 22 additions & 0 deletions src/base-container/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.modal-body-container .pgn__modal-body-content {
height: 100%;
}

.modal-body-container .modal-body-content-layout {
display: flex;
width: 100%;
height: 100%;
}

.pgn__modal-close-container {
background: white;
border-radius: 50%;
}

.modal-footer-content {
padding: 0 !important;
}

.privacy-policy-content {
margin-bottom: 0px;
}
14 changes: 14 additions & 0 deletions src/base-container/layout/LargeLayout.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import PropTypes from 'prop-types';

const LargeLayout = ({ children }) => (
<div className="w-50 d-flex">
{children}
</div>
);

LargeLayout.propTypes = {
children: PropTypes.node.isRequired,
};

export default LargeLayout;
13 changes: 13 additions & 0 deletions src/base-container/messages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { defineMessages } from '@edx/frontend-platform/i18n';

const messages = defineMessages({
privacyPolicyLabel: {
id: 'privacy.policy.label',
defaultMessage: 'By creating an account, you agree to the Terms of '
+ 'Service and Honor Code and you acknowledge that edX and '
+ 'each Member process your personal data in accordance with the Privacy Policy.',
description: 'Label for Privacy Policy',
},
});

export default messages;

0 comments on commit 95040a4

Please sign in to comment.