Skip to content

Commit

Permalink
refactor: refactor the structure of base container
Browse files Browse the repository at this point in the history
Description:
Refactor the structure of base component
VAN-1840
  • Loading branch information
ahtesham-quraish committed Mar 26, 2024
1 parent 3953c76 commit 4c9485c
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 51 deletions.
6 changes: 3 additions & 3 deletions example/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +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'
import AuthnComponent from '../src/authn-component'

subscribe(APP_READY, () => {
ReactDOM.render(
<AppProvider>
<BaseContainer open isPrivacyPolicy onClose={() => {}}>
<AuthnComponent open isPrivacyPolicy onClose={() => {}}>
<div>Login Form</div>
</BaseContainer>
</AuthnComponent>
</AppProvider>,
document.getElementById('root'),
);
Expand Down
File renamed without changes.
42 changes: 42 additions & 0 deletions src/authn-component/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React from 'react';

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

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

const AuthnComponent = ({
children, open, onClose, isPrivacyPolicy,
}) => (
<ModalDialog
isOpen={open}
onClose={onClose}
size="fullscreen"
variant="default"
hasCloseButton
>
<ModalDialog.Body className="modal-body-container overflow-hidden">
<BaseContainer>
{children}
</BaseContainer>
</ModalDialog.Body>
<ModalDialog.Footer className="modal-footer-content">
{isPrivacyPolicy && (<PrivacyPolicy />)}
</ModalDialog.Footer>
</ModalDialog>
);

AuthnComponent.defaultProps = {
isPrivacyPolicy: false,
};

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

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

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

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

.privacy-policy-content {
margin-bottom: 0px;
}
File renamed without changes.
41 changes: 10 additions & 31 deletions src/base-container/index.jsx
Original file line number Diff line number Diff line change
@@ -1,47 +1,26 @@
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,
children,
}) => (
<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,
};
<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>
);

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

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

.modal-body-container .modal-body-content-layout {
.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;
}

0 comments on commit 4c9485c

Please sign in to comment.