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 7e643f5 commit 3953c76
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 1 deletion.
5 changes: 4 additions & 1 deletion example/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ 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={() => {}}>
<div>Login Form</div>
</BaseContainer>
</AppProvider>,
document.getElementById('root'),
);
Expand Down
15 changes: 15 additions & 0 deletions src/base-container/PrivacyPolicyFooter.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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;
47 changes: 47 additions & 0 deletions src/base-container/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React from 'react';

import { ModalDialog } from '@openedx/paragon';
import PropTypes from 'prop-types';

import LargeLayout from './layout/LargeLayout';
import PrivacyPolicy from './PrivacyPolicyFooter';
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;
}
15 changes: 15 additions & 0 deletions src/base-container/layout/LargeLayout.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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 3953c76

Please sign in to comment.